/* ═══════════ SmartSurf AI Dashboard ═══════════ */
/* Design System: Dark marine theme */

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a2332;
    --bg-card-hover: #1f2b3d;
    --bg-input: #0d1421;
    --border: #1e2d3d;
    --border-light: #2a3a4d;

    --text-primary: #e4e8f1;
    --text-secondary: #8899aa;
    --text-muted: #5a6a7a;

    --accent: #00d4ff;
    --accent-dim: rgba(0, 212, 255, 0.12);
    --accent-glow: rgba(0, 212, 255, 0.3);
    --green: #34d399;
    --green-dim: rgba(52, 211, 153, 0.12);
    --yellow: #fbbf24;
    --yellow-dim: rgba(251, 191, 36, 0.12);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.12);
    --orange: #fb923c;
    --purple: #a78bfa;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ═══════════ HEADER ═══════════ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: linear-gradient(135deg, #0d1525 0%, #111d2e 100%);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 16px; }

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 28px; }
.logo h1 {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, #e4e8f1 30%, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}
.logo-ai {
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #00f0ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.version-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
}
.status-pill.ok .status-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-pill.ok { border-color: rgba(52, 211, 153, 0.25); }
.status-pill.error .status-dot { background: var(--red); box-shadow: 0 0 8px var(--red); }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--yellow);
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.status-pill.ok .status-dot { animation: none; }

.header-time {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ═══════════ MAIN ═══════════ */
.main {
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px 28px 60px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ═══════════ STATS ROW ═══════════ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.2s ease;
}
.stat-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.stat-icon {
    font-size: 28px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--accent-dim);
}

.stat-body { display: flex; flex-direction: column; gap: 2px; }
.stat-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

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

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.panel.full-width { grid-column: 1 / -1; }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.panel-header h2 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.badge {
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 20px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.badge.accent {
    background: var(--accent-dim);
    color: var(--accent);
}

.panel-body { padding: 16px 20px; }

/* ═══════════ DEVICE LIST ═══════════ */
.device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-xs);
    transition: background 0.15s;
}
.device-item:hover { background: var(--bg-input); }
.device-item + .device-item { border-top: 1px solid rgba(255,255,255,0.04); }

.device-info { display: flex; align-items: center; gap: 10px; }
.device-name { font-size: 14px; font-weight: 500; }
.device-imei { font-size: 11px; color: var(--text-muted); font-family: monospace; }

.device-status {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.device-status.online { background: var(--green-dim); color: var(--green); }
.device-status.offline { background: rgba(255,255,255,0.05); color: var(--text-muted); }
.device-status.unknown { background: var(--yellow-dim); color: var(--yellow); }

/* ═══════════ EMPTY STATE ═══════════ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; color: var(--text-secondary); font-weight: 500; }
.empty-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.loading-placeholder {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ═══════════ SESSIONS TABLE ═══════════ */
.table-wrap { overflow-x: auto; }

.sessions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.sessions-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.sessions-table td {
    padding: 12px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.sessions-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}
.sessions-table tbody tr:hover { background: var(--bg-input); }

.no-data {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px !important;
    font-size: 14px;
}

/* Status badges */
.status-badge {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
}
.status-badge.recording { background: var(--accent-dim); color: var(--accent); }
.status-badge.ended { background: var(--yellow-dim); color: var(--yellow); }
.status-badge.processing,
.status-badge.enriching,
.status-badge.analyzing { background: rgba(167, 139, 250, 0.12); color: var(--purple); }
.status-badge.completed { background: var(--green-dim); color: var(--green); }
.status-badge.error { background: var(--red-dim); color: var(--red); }

/* Score badges */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 24px;
    border-radius: var(--radius-xs);
    font-weight: 700;
    font-size: 12px;
}
.score-high { background: var(--green-dim); color: var(--green); }
.score-mid { background: var(--yellow-dim); color: var(--yellow); }
.score-low { background: var(--red-dim); color: var(--red); }

.risk-low { background: var(--green-dim); color: var(--green); }
.risk-mid { background: var(--yellow-dim); color: var(--yellow); }
.risk-high { background: var(--red-dim); color: var(--red); }

/* ═══════════ MODAL ═══════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    width: 90%;
    max-width: 680px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.modal-content { padding: 28px; }

.modal-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-right: 40px;
}

.modal-section {
    margin-bottom: 20px;
}
.modal-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 600;
}

.modal-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.modal-metric {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}
.modal-metric .value {
    font-size: 20px;
    font-weight: 700;
    display: block;
}
.modal-metric .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ai-report {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}
.ai-report.coaching { border-left: 3px solid var(--accent); }
.ai-report.safety { border-left: 3px solid var(--yellow); }

/* ═══════════ BUTTON ═══════════ */
.btn-refresh {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font);
    font-weight: 500;
    transition: all 0.15s;
}
.btn-refresh:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* ═══════════ LIVE SESSION CARD ═══════════ */
.live-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--accent-dim);
    border: 1px solid rgba(0, 212, 255, 0.15);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    animation: live-glow 2s ease-in-out infinite;
}
@keyframes live-glow {
    0%, 100% { border-color: rgba(0, 212, 255, 0.15); }
    50% { border-color: rgba(0, 212, 255, 0.35); }
}
.live-card-info { display: flex; flex-direction: column; gap: 2px; }
.live-card-device { font-size: 14px; font-weight: 600; }
.live-card-time { font-size: 12px; color: var(--text-muted); }
.live-card-badge {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}

/* ═══════════ FOOTER ═══════════ */
.footer {
    text-align: center;
    padding: 16px 28px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}
.footer-dot { margin: 0 8px; }

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 900px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .grid-2col { grid-template-columns: 1fr; }
    .modal-metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .stats-row { grid-template-columns: 1fr; }
    .header { padding: 12px 16px; }
    .main { padding: 16px; }
    .modal-metrics { grid-template-columns: 1fr; }
}
