/* HEAT Engine Custom Styling - Premium Dark Glassmorphism */

:root {
    --bg-base: #0a0d14;
    --bg-surface: #121622;
    --bg-glass: rgba(18, 22, 34, 0.7);
    --border-glass: rgba(255, 255, 255, 0.06);
    
    --primary: #2563eb;
    --primary-glow: rgba(37, 99, 235, 0.35);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.35);
    
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --text-main: #f1f5f9;
    --text-muted: #64748b;
    --text-bright: #ffffff;
    
    --transition: all 0.25s ease-in-out;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* LOGIN LAYOUT */

.login-body {
    display: flex;
    justify-content: center;
    align-center: center;
    min-height: 100vh;
    background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
}

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 20px;
}

.login-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #60a5fa, #2563eb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* APP MAIN LAYOUT */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    height: 100vh;
}

.sidebar-header {
    margin-bottom: 36px;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-bright);
    letter-spacing: -0.5px;
}

.sidebar-header span {
    font-size: 0.8rem;
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    padding: 2px 8px;
    border-radius: 99px;
    display: inline-block;
    margin-top: 4px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    transition: var(--transition);
}

.nav-item svg {
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    color: var(--text-bright);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    background-color: var(--primary);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.nav-item.active svg {
    stroke: var(--text-bright);
}

.sidebar-footer {
    margin-top: auto;
}

.main-content {
    flex-grow: 1;
    margin-left: 260px;
    padding: 40px;
    background-color: var(--bg-base);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 36px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 24px;
}

.user-greeting span {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.user-greeting h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-bright);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    padding: 8px 16px;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 500;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 0 0 var(--success-glow);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 var(--success-glow);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* CARDS & CONTAINERS */

.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 12px;
}

.card-header h3, .card-header h4 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-bright);
}

/* TAB VISIBILITY SYSTEM */

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.35s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* METRICS */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.metric-card {
    background: linear-gradient(135deg, var(--bg-surface) 0%, #1a1f30 100%);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.metric-card h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.metric-card .value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-bright);
    display: block;
    margin-bottom: 4px;
}

.metric-card .subtext {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* KEYWORD BADGES */

.keyword-badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 80px;
    align-content: flex-start;
}

.keyword-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.keyword-badge:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.delete-badge-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.delete-badge-btn:hover {
    color: var(--danger);
}

.keyword-lists-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* FORM ELEMENTS */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

input, select {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.horizontal-form {
    display: flex;
    gap: 16px;
    align-items: center;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.margin-self-end { align-self: flex-end; margin-bottom: 20px; }

/* BUTTONS */

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    border: none;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-bright);
}

.btn-primary:hover {
    background-color: #1d4ed8;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-danger {
    background-color: var(--danger);
    color: var(--text-bright);
}

.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.btn-outline {
    background: none;
    border: 1px solid var(--border-glass);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.03);
    border-color: var(--text-muted);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 4px;
}

/* TABLES */

.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th, .table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-glass);
}

.table th {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.table-title {
    color: var(--text-bright);
    font-weight: 500;
}

.table-time {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* BADGES */

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-red { background-color: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-blue { background-color: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.badge-purple { background-color: rgba(139, 92, 246, 0.1); color: #8b5cf6; }

/* ALERTS */

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-success { background-color: rgba(16, 185, 129, 0.1); border: 1px solid var(--success); color: var(--success); }
.alert-error, .alert-danger { background-color: rgba(239, 68, 68, 0.1); border: 1px solid var(--danger); color: var(--danger); }
.alert-warning { background-color: rgba(245, 158, 11, 0.1); border: 1px solid var(--warning); color: var(--warning); }
.alert-info { background-color: rgba(37, 99, 235, 0.1); border: 1px solid var(--primary); color: var(--primary); }

/* GRID & ALIGNMENT */

.grid-2-col {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.flex-between { justify-content: space-between; display: flex; }
.align-center { align-items: center; }
.margin-top { margin-top: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.padding-all { padding: 24px; }
.height-fit { height: fit-content; }

/* CONSOLE/TERMINAL (LOGS TAB) */

.console-output {
    background-color: #020617;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 20px;
    max-height: 480px;
    overflow-y: auto;
}

.console-output pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: #38bdf8;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
}

/* SETTINGS FORMS & TOGGLES */

.settings-board-form {
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 24px;
    margin-bottom: 24px;
}

.settings-board-form:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.settings-board-form h4 {
    margin-bottom: 16px;
}

.switch-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.switch-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* iOS SWITCH STYLE */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.08);
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-main);
  transition: .3s;
}

input:checked + .slider {
  background-color: var(--success);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* RESPONSIVENESS */

@media (max-width: 1024px) {
    .grid-2-col, .keyword-lists-grid {
        grid-template-columns: 1fr;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* UNIFIED INBOX STYLING */

.inbox-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    height: calc(100vh - 160px);
    min-height: 500px;
}

.inbox-threads-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px !important;
}

.threads-list {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.thread-item {
    padding: 14px 16px;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.01);
    transition: var(--transition);
    text-align: left;
}

.thread-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
    border-color: var(--text-muted);
}

.thread-item.active {
    background-color: rgba(37, 99, 235, 0.08);
    border-color: var(--primary);
}

.thread-item h4 {
    margin: 0 0 6px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-item p {
    margin: 0 0 6px 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
}

.inbox-chat-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px !important;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: 1px solid var(--border-glass);
    margin-bottom: 16px;
}

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.45;
    word-break: break-word;
}

.msg-customer {
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

.msg-agent {
    align-self: flex-end;
    background-color: var(--primary);
    color: var(--text-bright);
    border-bottom-right-radius: 2px;
}

.bubble-meta {
    display: block;
    font-size: 0.75rem;
    margin-top: 6px;
    opacity: 0.7;
}

.msg-agent .bubble-meta {
    text-align: right;
}

.call-log-bubble {
    align-self: center;
    background-color: rgba(245, 158, 11, 0.05);
    border: 1px dashed rgba(245, 158, 11, 0.3);
    color: var(--warning);
    padding: 12px 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    font-size: 0.88rem;
    text-align: center;
    margin: 4px 0;
    line-height: 1.5;
}

.call-recording-player {
    margin-top: 10px;
    width: 100%;
}

.call-transcript {
    margin-top: 8px;
    font-size: 0.8rem;
    font-style: italic;
    color: var(--text-main);
    background-color: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: 4px;
    text-align: left;
}

.chat-input-area {
    padding-top: 8px;
}

@media (max-width: 768px) {
    .inbox-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .inbox-threads-card {
        height: 300px;
    }
    
    .inbox-chat-card {
        height: 500px;
        margin-top: 16px;
    }
}
