/* ── Reset navbar ── */
.navbar { display: none !important; }

.dashboard {
    display: flex; height: 100vh; overflow: hidden; background: #fafafb;
    font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Sidebar (shared) ── */
.sidebar { width: 220px; background: #fff; border-right: 1.5px solid #e6ebf1; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1.5px solid #e6ebf1; }
.sidebar-logo { width: 32px; height: 32px; background: #1890ff; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: #1c1917; flex-shrink: 0; }
.sidebar-brand-name { font-size: 14px; font-weight: 700; color: #1c1917; }
.sidebar-nav { flex: 1; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 4px; font-size: 13.5px; font-weight: 500; color: #6b7280; cursor: pointer; transition: all 0.15s; border: none; background: none; text-align: left; width: 100%; text-decoration: none; font-family: inherit; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: #f5f6f7; color: #1c1917; }
.nav-item.active { background: #e6f4ff; color: #1890ff; font-weight: 600; }
.sidebar-footer { padding: 12px 10px; border-top: 1.5px solid #e6ebf1; }
.btn-logout { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 11px; border-radius: 4px; border: none; background: none; font-size: 13.5px; font-weight: 500; color: #ef4444; cursor: pointer; font-family: inherit; transition: background 0.15s; }
.btn-logout:hover { background: #fff4f4; }
.btn-logout svg { width: 15px; height: 15px; }

/* ── Main Content ── */
.main-content { margin-left: 220px; flex: 1; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.view-header { background: #fff; border-bottom: 1.5px solid #e6ebf1; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.view-header h1 { font-size: 16px; font-weight: 700; color: #1c1917; margin: 0; }
.view-body { padding: 12px 20px; flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ── Toolbar ── */
.page-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.page-toolbar h1 { font-size: 16px; margin: 0; white-space: nowrap; color: #1c1917; }
.toolbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.active-filter-count { font-size: 11px; color: #1c1917; background: #e6f4ff; border: 1px solid #e6ebf1; padding: 2px 8px; border-radius: 4px; font-weight: 600; white-space: nowrap; }

.btn-toggle-filters { background: #f5f6f7; border: 1.5px solid #e6ebf1; color: #1c1917; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; border-radius: 7px; transition: all 0.15s; white-space: nowrap; font-family: inherit; }
.btn-toggle-filters:hover { background: #e6ebf1; }
.btn-toggle-filters.active { background: #e6ebf1; }

/* ── Filter Panel ── */
.filter-panel {
    background: #fff; border: 1.5px solid #e6ebf1; border-radius: 8px;
    padding: 12px 16px; margin-bottom: 10px;
    flex-shrink: 0; max-height: 55vh; overflow-y: auto;
}

.filter-section-label {
    font-size: 9.5px; font-weight: 700; color: #c4c9d4;
    text-transform: uppercase; letter-spacing: 0.9px; margin-bottom: 8px;
}
.filter-divider { border: none; border-top: 1px solid #f0f1f3; margin: 10px 0; }

/* Two-column layout */
.filter-two-col { display: flex; gap: 0; }
.filter-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.filter-col-sep { width: 1px; background: #f0f1f3; margin: 0 18px; flex-shrink: 0; }
.filter-col-row { display: flex; gap: 10px; }
.filter-col-row .filter-group { flex: 1; min-width: 0; }
.filter-section-mt { margin-top: 10px; }

.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-group label {
    display: flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 600; color: #374151; white-space: nowrap;
}
.filter-group label svg { width: 12px; height: 12px; color: #b0b7c3; flex-shrink: 0; }
.filter-hint { font-size: 10.5px; font-weight: 400; color: #c4c9d4; margin-left: 2px; }

.filter-group input, .filter-group select {
    padding: 7px 10px; font-size: 13px;
    background: #fafafb; border: 1.5px solid #e6ebf1;
    border-radius: 6px; color: #1c1917; font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%; box-sizing: border-box;
}
.filter-group input:focus, .filter-group select:focus {
    outline: none; border-color: #1890ff;
    box-shadow: 0 0 0 3px rgba(24,144,255,0.09);
}
.filter-group input::placeholder { color: #d1d5db; }


.filter-footer-bar {
    display: flex; align-items: flex-end; gap: 10px;
    border-top: 1px solid #f0f1f3; margin-top: 12px; padding-top: 12px;
}
.filter-sort-group { flex: 0 1 200px; min-width: 150px; }
.filter-actions { display: flex; gap: 7px; flex-shrink: 0; padding-bottom: 1px; }

.btn-apply {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 16px; background: #1890ff; color: #fff;
    border: none; border-radius: 6px; font-size: 12.5px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: background 0.15s;
}
.btn-apply svg { width: 12px; height: 12px; }
.btn-apply:hover { background: #0e7ae0; }

.btn-clear {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 12px; background: #f5f6f7; color: #6b7280;
    border: 1.5px solid #e6ebf1; border-radius: 6px; font-size: 12.5px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.btn-clear svg { width: 10px; height: 10px; }
.btn-clear:hover { background: #e6ebf1; color: #374151; }

/* ── Buttons (general) ── */
.btn-primary { display: inline-flex; align-items: center; padding: 7px 14px; background: #e6ebf1; color: #1c1917; border: 1.5px solid #e6ebf1; border-radius: 4px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.15s; }
.btn-primary:hover { background: #bfbfbf; }
.btn-secondary { display: inline-flex; align-items: center; padding: 7px 14px; background: #f3f4f6; color: #374151; border: 1.5px solid #e5e7eb; border-radius: 4px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.15s; }
.btn-secondary:hover { background: #e9eaec; }

@media (max-width: 1100px) {
    .filter-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Stats Bar ── */
.stats-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; flex-shrink: 0; }
.stat-card { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; background: #fff; border: 1.5px solid #e6ebf1; border-radius: 4px; }
.stat-label { font-size: 9.5px; color: #b0b7c3; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.stat-value { font-size: 13.5px; font-weight: 700; color: #1c1917; font-family: 'SF Mono', 'Fira Code', monospace; }

/* ── Loading ── */
.loading-spinner { width: 24px; height: 24px; border: 2px solid rgba(193,211,254,0.4); border-top-color: #e6ebf1; border-radius: 50%; animation: spin 0.7s linear infinite; margin: 14px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.text-center { text-align: center; }
.text-muted { color: #9ca3af; font-size: 13px; }
.small { font-size: 12px; }

/* ── Messages ── */
.error-message { background: #fff4f4; border: 1px solid #fca5a5; color: #b91c1c; padding: 8px 12px; border-radius: 4px; margin-bottom: 8px; font-size: 13px; flex-shrink: 0; }

/* ── Table ── */
#tableContainer { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.table-wrapper { flex: 1; min-height: 0; overflow: auto; }
.card { background: #fff; border: 1.5px solid #e6ebf1; border-radius: 4px; padding: 0; }
.table-wrapper.card { overflow: auto; }

.conversations-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.conversations-table thead { background: #fafafa; position: sticky; top: 0; z-index: 1; }
.conversations-table th { padding: 7px 10px; text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #9ca3af; font-weight: 700; white-space: nowrap; border-bottom: 1.5px solid #f3f4f6; }
.conversations-table td { padding: 6px 10px; border-bottom: 1px solid #f3f4f6; color: #374151; white-space: nowrap; }
.conversations-table tbody tr { cursor: pointer; transition: background 0.1s; }
.conversations-table tbody tr:hover { background: #faf9f7; }
.conversations-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 7px; border-radius: 20px; font-size: 10.5px; font-weight: 600; }
.badge-channel { background: #f3f4f6; color: #6b7280; }
.badge-channel.inbound { background: #f5f6f7; color: #2563eb; }
.badge-channel.outbound { background: #fff7ed; color: #c2410c; }
.badge-channel.web { background: #f0fdf4; color: #16a34a; }
.badge-status { background: #f3f4f6; color: #6b7280; }
.badge-status.ended { background: #f0fdf4; color: #16a34a; }
.badge-status.active { background: #fffbeb; color: #d97706; }
.badge-status.created { background: #f9fafb; color: #9ca3af; }
.badge-status.error { background: #fff4f4; color: #dc2626; }

.user-identifier { font-family: monospace; color: #78716c; font-size: 11px; }
.cell-room { font-family: monospace; font-size: 11px; color: #9ca3af; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.cell-phone { font-family: monospace; font-size: 11.5px; color: #78716c; }
.cell-muted { color: #9ca3af; font-size: 11.5px; }
.cell-mono { font-family: monospace; font-size: 11.5px; color: #374151; }
.cell-warn { font-family: monospace; font-size: 11.5px; color: #d97706; }
.cell-reason { max-width: 140px; overflow: hidden; text-overflow: ellipsis; cursor: default; color: #9ca3af; font-size: 11.5px; }

.error-dot { display: inline-block; width: 5px; height: 5px; background: #dc2626; border-radius: 50%; vertical-align: middle; margin-left: 2px; }

.badge-terminated { font-size: 11px; color: #9ca3af; }
.badge-terminated.user { color: #2563eb; }
.badge-terminated.agent { color: #16a34a; }
.badge-terminated.system { color: #d97706; }
.badge-terminated.error { color: #dc2626; }

/* ── Pagination ── */
.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 10px 0; }
.pagination button { padding: 5px 14px; font-size: 12.5px; background: #f5f6f7; color: #1c1917; border: 1.5px solid #e6ebf1; border-radius: 7px; cursor: pointer; font-family: inherit; font-weight: 600; transition: all 0.15s; }
.pagination button:hover:not(:disabled) { background: #e6ebf1; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { font-size: 12.5px; color: #6b7280; }
.page-size-picker { display: flex; align-items: center; gap: 5px; margin-left: 8px; }
.page-size-picker label { font-size: 12px; color: #6b7280; font-weight: 500; }
.page-size-picker select { font-size: 12.5px; padding: 4px 6px; border: 1.5px solid #e6ebf1; border-radius: 7px; background: #f5f6f7; color: #1c1917; font-family: inherit; font-weight: 600; cursor: pointer; width: auto; }

/* ── Detail Modal ── */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-content { width: 100%; max-width: 860px; max-height: 88vh; overflow-y: auto; background: #fff; border: 1.5px solid #e6ebf1; border-radius: 4px; padding: 20px 24px; box-shadow: 0 8px 32px rgba(0,0,0,0.12); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1.5px solid #e6ebf1; }
.modal-header h3 { font-size: 15px; font-weight: 700; color: #1c1917; }
.btn-close { background: none; border: none; color: #9ca3af; font-size: 22px; cursor: pointer; padding: 0; line-height: 1; }
.btn-close:hover { color: #374151; }

/* ── Detail Tabs ── */
.detail-tabs { display: flex; gap: 0; border-bottom: 1.5px solid #e6ebf1; margin-bottom: 14px; }
.detail-tabs button { background: none; border: none; color: #6b7280; padding: 6px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1.5px; transition: all 0.15s; border-radius: 0; font-family: inherit; }
.detail-tabs button:hover { color: #1c1917; }
.detail-tabs button.active { color: #1c1917; border-bottom-color: #bfbfbf; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Detail Grid ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-item.full-width { grid-column: 1 / -1; }
.detail-label { font-size: 10px; color: #b0b7c3; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.detail-value { font-size: 13px; color: #1c1917; word-break: break-word; }
.detail-value.mono { font-family: monospace; font-size: 11.5px; background: #f2f1ee; color: #78716c; padding: 1px 6px; border-radius: 4px; display: inline-block; }

.detail-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid #f3f4f6; }
.detail-section-title { font-size: 10.5px; color: #bfbfbf; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; font-weight: 700; }

/* ── Cost Table ── */
.cost-table-wrap { background: #faf9f7; border: 1.5px solid #e6ebf1; border-radius: 4px; padding: 16px; }
.cost-table { width: 100%; border-collapse: collapse; }
.cost-table th { text-align: right; color: #9ca3af; font-weight: 700; padding: 0 0 8px; font-size: 10.5px; letter-spacing: 0.3px; border-bottom: 1px solid #f3f4f6; }
.cost-table th:first-child { text-align: left; }
.cost-table td { padding: 7px 0; color: #374151; text-align: right; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; border-bottom: 1px solid #f3f4f6; }
.cost-table td:first-child { text-align: left; font-family: inherit; color: #6b7280; font-size: 12px; }
.cost-table tbody tr:hover { background: #f5f6f7; }
.cost-table tr.subtotal-row td { color: #1c1917; font-weight: 600; border-bottom: 1px solid #e6ebf1; }
.cost-table tr.total-row td { color: #1c1917; font-weight: 700; font-size: 13px; padding-top: 10px; }
.cost-table tr.total-row td:first-child { color: #1c1917; }
.cost-table tr.info-row td { color: #b0b7c3; font-size: 11px; border-bottom: none; }
.cost-table tr.section-gap td { padding: 2px 0; border: none; }
.cost-footnote { font-size: 11px; color: #b0b7c3; margin-top: 10px; }

/* ── Transcript ── */
.transcript { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; padding: 4px; }
.message-bubble { max-width: 80%; padding: 7px 11px; border-radius: 4px; font-size: 13px; line-height: 1.4; }
.message-bubble.user { align-self: flex-start; background: #e6f4ff; border-radius: 4px 9px 9px 2px; }
.message-bubble.assistant, .message-bubble.agent { align-self: flex-end; background: #f0fdf4; border-radius: 4px 9px 2px 9px; }
.message-bubble.system { align-self: center; background: #f9fafb; font-size: 12px; color: #9ca3af; font-style: italic; }
.message-role { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.message-bubble.user .message-role { color: #1c1917; }
.message-bubble.assistant .message-role, .message-bubble.agent .message-role { color: #16a34a; }
.message-text { color: #374151; white-space: pre-wrap; word-break: break-word; }
.message-meta { font-size: 10px; color: #9ca3af; margin-top: 3px; display: flex; gap: 8px; }
.message-interrupted { color: #d97706; font-size: 10px; font-weight: 600; }

/* ── Telephony ── */
.telephony-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Recordings ── */
.rec-track-list { display: flex; flex-direction: column; gap: 6px; }
.rec-track-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: #fafafb; border: 1.5px solid #e6ebf1; border-radius: 4px; }
.rec-track-item:hover { background: #f5f6f7; }
.rec-track-info { flex: 1; min-width: 0; }
.rec-track-name { font-weight: 600; font-size: 13px; color: #1c1917; margin-bottom: 3px; }
.rec-track-meta { display: flex; gap: 10px; font-size: 11px; color: #9ca3af; }
.rec-track-format { background: #e6ebf1; padding: 1px 5px; border-radius: 3px; font-weight: 700; font-size: 10px; color: #6b7280; }
.rec-track-actions { display: flex; gap: 6px; flex-shrink: 0; }
.rec-btn-play { background: #e6ebf1; color: #1c1917; padding: 5px 14px; border: none; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.15s; }
.rec-btn-play:hover { background: #bfbfbf; }
.rec-btn-download { background: #f5f6f7; color: #1c1917; padding: 5px 14px; border: 1.5px solid #e6ebf1; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: none; transition: all 0.15s; }
.rec-btn-download:hover { background: #e6ebf1; }
.rec-section-title { font-size: 10px; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 10px; margin-bottom: 6px; font-weight: 700; }
.rec-inline-player { padding: 8px 12px; background: #f9fafb; border-radius: 0 0 9px 9px; margin-top: -6px; border-top: 1px solid #e6ebf1; }
.rec-audio { width: 100%; height: 32px; }

/* ── Utilities ── */
.hidden { display: none !important; }

@media (max-width: 768px) {
    .sidebar { width: 190px; }
    .main-content { margin-left: 190px; }
    .view-body { padding: 10px 12px; }
    .stats-bar { grid-template-columns: repeat(2, 1fr); }
    .detail-grid, .telephony-grid { grid-template-columns: 1fr; }
    .filter-row { flex-direction: column; }
    .filter-group { min-width: 100%; }
}
