/* ═══════════════════════════════════════════════════════════════════
   SmartTalker — Operator Dashboard Styles
   Premium dark glassmorphism design
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0a0c14;
    --surface: #12151f;
    --surface2: #1a1e2e;
    --surface3: #222740;
    --border: #2a2f45;
    --text: #e4e6ef;
    --text-dim: #7a7f96;
    --accent: #6c63ff;
    --accent-h: #857dff;
    --green: #2dd4a8;
    --red: #f44;
    --orange: #f9a825;
    --blue: #4fc3f7;
    --radius: 10px;
    --glass: rgba(26, 30, 46, 0.85);
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    background-image:
        radial-gradient(ellipse at 15% 80%, rgba(108, 99, 255, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 20%, rgba(45, 212, 168, 0.04) 0%, transparent 50%);
    color: var(--text);
    overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────────── */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.header-left h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--accent), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-left .subtitle {
    font-size: 11px;
    color: var(--blue);
    margin-left: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-dim);
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot.disconnected {
    background: var(--red);
}

.dot.connecting {
    background: var(--orange);
    animation: pulse 1s infinite;
}

.dot.connected {
    background: var(--green);
    box-shadow: 0 0 8px rgba(45, 212, 168, 0.5);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ── Main Layout ──────────────────────────────────────────────── */
#main {
    display: grid;
    grid-template-columns: 260px 1fr 380px;
    height: calc(100vh - 88px);
    gap: 1px;
    background: var(--border);
}

/* ── Session Sidebar ──────────────────────────────────────────── */
#session-sidebar {
    background: var(--surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#refresh-sessions-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

#refresh-sessions-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(108, 99, 255, 0.1);
}

#session-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.session-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    transition: all 0.25s ease;
}

.session-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(108, 99, 255, 0.1);
}

.session-card.active {
    border-color: var(--green);
    background: rgba(45, 212, 168, 0.05);
    box-shadow: 0 0 16px rgba(45, 212, 168, 0.1);
}

.session-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.session-id {
    font-size: 13px;
    font-weight: 600;
    font-family: 'Consolas', monospace;
    color: var(--text);
}

.session-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.session-badge.recording {
    background: rgba(255, 68, 68, 0.15);
    color: var(--red);
}

.session-badge.idle {
    background: rgba(138, 143, 163, 0.15);
    color: var(--text-dim);
}

.session-card-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.subscribe-btn {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: transparent;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.subscribe-btn:hover {
    background: rgba(108, 99, 255, 0.15);
    box-shadow: 0 0 12px rgba(108, 99, 255, 0.15);
}

.session-card.active .subscribe-btn {
    border-color: var(--green);
    color: var(--green);
    background: rgba(45, 212, 168, 0.1);
}

/* ── Video Section ────────────────────────────────────────────── */
#video-section {
    background: var(--bg);
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
}

#video-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#watching-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
}

#unsubscribe-btn {
    padding: 6px 14px;
    border: 1px solid var(--red);
    border-radius: 6px;
    background: transparent;
    color: var(--red);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#unsubscribe-btn:hover:not(:disabled) {
    background: rgba(255, 68, 68, 0.1);
}

#unsubscribe-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#customer-video-container {
    flex: 1;
    position: relative;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    min-height: 300px;
}

#customer-video-frame {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}

#customer-video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-dim);
}

.placeholder-icon {
    font-size: 56px;
    margin-bottom: 12px;
    opacity: 0.3;
}

#customer-video-placeholder p {
    font-size: 14px;
    opacity: 0.6;
}

/* ── Document Viewer ──────────────────────────────────────────── */
#document-viewer {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}

#document-viewer h3 {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 10px;
}

#document-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.doc-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100px;
}

.doc-thumb {
    width: 100px;
    height: 75px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s;
}

.doc-thumb:hover {
    transform: scale(1.05);
    border-color: var(--blue);
}

.doc-info {
    display: flex;
    flex-direction: column;
}

.doc-name {
    font-size: 10px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-size {
    font-size: 9px;
    color: var(--text-dim);
}

/* ── Chat Section ─────────────────────────────────────────────── */
#chat-section {
    background: var(--surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.section-title h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#session-info {
    font-size: 11px;
    font-family: 'Consolas', monospace;
    color: var(--accent);
}

#op-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg {
    max-width: 90%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 2px;
}

.msg.bot {
    align-self: flex-start;
    background: var(--surface3);
    border-bottom-left-radius: 2px;
    border-left: 3px solid var(--green);
}

.msg.operator {
    align-self: flex-end;
    background: linear-gradient(135deg, #1a6b4a, #14503a);
    color: #fff;
    border-bottom-right-radius: 2px;
    border-right: 3px solid var(--green);
}

.msg.system {
    align-self: center;
    background: transparent;
    color: var(--text-dim);
    font-size: 11px;
    font-style: italic;
    padding: 4px 8px;
}

.msg .msg-meta {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 4px;
    display: flex;
    gap: 8px;
}

.msg .msg-text {
    word-break: break-word;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-dim);
    font-size: 13px;
    opacity: 0.5;
}

/* ── Operator Input ───────────────────────────────────────────── */
#op-input-bar {
    display: flex;
    padding: 12px;
    gap: 8px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
}

#op-message-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}

#op-message-input:focus {
    border-color: var(--green);
}

#op-message-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#op-send-btn {
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--green), #1a8d6e);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#op-send-btn:hover:not(:disabled) {
    box-shadow: 0 0 16px rgba(45, 212, 168, 0.3);
    transform: translateY(-1px);
}

#op-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Training Panel ───────────────────────────────────────────── */
#training-panel {
    padding: 12px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
}

#training-panel h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.training-hint {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 10px;
    opacity: 0.7;
}

#feedback-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.fb-btn {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.fb-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.fb-good:hover:not(:disabled) {
    border-color: var(--green);
    background: rgba(45, 212, 168, 0.1);
    color: var(--green);
}

.fb-bad:hover:not(:disabled) {
    border-color: var(--red);
    background: rgba(255, 68, 68, 0.1);
    color: var(--red);
}

.fb-btn.pressed {
    transform: scale(0.95);
}

.fb-good.pressed {
    background: rgba(45, 212, 168, 0.25);
    border-color: var(--green);
}

.fb-bad.pressed {
    background: rgba(255, 68, 68, 0.25);
    border-color: var(--red);
}

#feedback-note {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}

#feedback-note:focus {
    border-color: var(--accent);
}

#feedback-note:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Footer ───────────────────────────────────────────────────── */
#footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 24px;
    font-size: 11px;
    color: var(--text-dim);
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
}

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
    #main {
        grid-template-columns: 200px 1fr 300px;
    }
}

@media (max-width: 768px) {
    #main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    #session-sidebar {
        max-height: 150px;
    }
}