/* ============================================================
   Livestream Manager — Analytics & Observability UI
   Shared between admin and [lsm_app] frontend
   ============================================================ */

/* ── Loading state ──────────────────────────────────────────── */
.lsm-analytics-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 60px 24px;
    color: #6b7280;
    font-size: 13.5px;
}
.lsm-analytics-spinner {
    width: 32px; height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #1d4ed8;
    border-radius: 50%;
    animation: lsmAnalyticsSpin .7s linear infinite;
}
@keyframes lsmAnalyticsSpin { to { transform: rotate(360deg); } }

/* ── Drawer body scroll ─────────────────────────────────────── */
.lsm-analytics-body {
    padding: 0 !important;
    background: #f5f7fa;
    overflow-y: auto;
}

/* ── Range + mode tabs header ───────────────────────────────── */
.lsm-an-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #ffffff;
    border-bottom: 1px solid #e3e6eb;
    gap: 10px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
}
.lsm-an-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.lsm-an-mode-tabs {
    display: flex;
    background: #f0f2f6;
    border: 1px solid #dde1e9;
    border-radius: 7px;
    padding: 3px;
    gap: 2px;
}
.lsm-an-mode-tab {
    padding: 6px 14px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: #6b7280;
    background: transparent;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 140ms ease;
    display: flex; align-items: center; gap: 6px;
}
.lsm-an-mode-tab svg { width: 13px; height: 13px; }
.lsm-an-mode-tab:hover { color: #374151; background: #ffffff; }
.lsm-an-mode-tab.active { background: #ffffff; color: #1d4ed8; box-shadow: 0 1px 3px rgba(0,0,0,.07); }
.lsm-an-mode-tab.active.vod { color: #5b21b6; }

.lsm-an-range-tabs {
    display: flex;
    gap: 4px;
}
.lsm-an-range-btn {
    padding: 5px 11px;
    font-family: inherit; font-size: 11.5px; font-weight: 600;
    color: #6b7280; background: transparent;
    border: 1px solid #dde1e9; border-radius: 6px;
    cursor: pointer; transition: all 140ms;
}
.lsm-an-range-btn:hover { color: #374151; border-color: #bec5d1; background: #ffffff; }
.lsm-an-range-btn.active { background: #1d4ed8; color: #ffffff; border-color: #1d4ed8; }

/* ── Content wrapper ────────────────────────────────────────── */
.lsm-an-content { padding: 20px; }

/* ── KPI metric cards ───────────────────────────────────────── */
.lsm-an-kpis {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}
.lsm-an-kpi {
    background: #ffffff;
    border: 1px solid #e3e6eb;
    border-radius: 10px;
    padding: 14px 16px;
    position: relative;
    overflow: hidden;
    transition: box-shadow 140ms;
}
.lsm-an-kpi:hover { box-shadow: 0 4px 16px rgba(0,0,0,.07); }
.lsm-an-kpi-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.lsm-an-kpi-icon svg { width: 15px; height: 15px; }
.lsm-an-kpi-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.lsm-an-kpi-icon.green  { background: #d1fae5; color: #047857; }
.lsm-an-kpi-icon.amber  { background: #fef3c7; color: #b45309; }
.lsm-an-kpi-icon.purple { background: #ede9fe; color: #5b21b6; }
.lsm-an-kpi-icon.red    { background: #fee2e2; color: #b91c1c; }
.lsm-an-kpi-icon.teal   { background: #ccfbf1; color: #0f766e; }
.lsm-an-kpi-val {
    font-size: 22px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -.5px;
    line-height: 1.1;
    margin-bottom: 3px;
}
.lsm-an-kpi-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #9ca3af;
}
.lsm-an-kpi-accent {
    position: absolute;
    top: 0; right: 0;
    width: 3px; height: 100%;
    border-radius: 0 10px 10px 0;
}
.lsm-an-kpi-accent.blue   { background: #1d4ed8; }
.lsm-an-kpi-accent.green  { background: #047857; }
.lsm-an-kpi-accent.amber  { background: #b45309; }
.lsm-an-kpi-accent.purple { background: #5b21b6; }
.lsm-an-kpi-accent.red    { background: #b91c1c; }
.lsm-an-kpi-accent.teal   { background: #0f766e; }

/* ── Chart panel ────────────────────────────────────────────── */
.lsm-an-chart-panel {
    background: #ffffff;
    border: 1px solid #e3e6eb;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 20px;
}
.lsm-an-chart-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.lsm-an-chart-title {
    font-size: 12.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px;
    color: #6b7280;
}
.lsm-an-chart-badge {
    font-size: 10.5px; font-weight: 700;
    padding: 2px 8px; border-radius: 20px;
    background: #dbeafe; color: #1d4ed8;
}
.lsm-an-chart-badge.vod { background: #ede9fe; color: #5b21b6; }

.lsm-an-chart-wrap {
    position: relative;
    height: 160px;
    width: 100%;
}
.lsm-an-chart-canvas {
    width: 100% !important;
    height: 100% !important;
}
.lsm-an-chart-empty {
    display: flex; align-items: center; justify-content: center;
    height: 120px;
    color: #9ca3af; font-size: 12.5px;
}

/* ── No data / error states ─────────────────────────────────── */
.lsm-an-no-data {
    text-align: center; padding: 48px 24px;
    color: #6b7280;
}
.lsm-an-no-data-icon {
    width: 48px; height: 48px; margin: 0 auto 14px;
    background: #f0f2f6; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #9ca3af;
}
.lsm-an-no-data-icon svg { width: 22px; height: 22px; }
.lsm-an-no-data h4 { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.lsm-an-no-data p  { font-size: 12.5px; max-width: 260px; margin: 0 auto; line-height: 1.5; }

.lsm-an-error {
    margin: 16px 20px;
    padding: 12px 14px;
    background: #fee2e2; border: 1px solid #fca5a5;
    border-radius: 8px; color: #b91c1c;
    font-size: 13px; font-weight: 500;
}

/* ── Section divider ────────────────────────────────────────── */
.lsm-an-section-label {
    font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .7px;
    color: #9ca3af; margin-bottom: 10px;
    display: flex; align-items: center; gap: 8px;
}
.lsm-an-section-label::after { content:''; flex:1; height:1px; background:#e3e6eb; }

/* ── Toolbar right side ──────────────────────────────────────── */
.lsm-an-toolbar-right {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

/* ── Refresh button ──────────────────────────────────────────── */
.lsm-an-refresh-group { display: flex; align-items: center; gap: 5px; }
.lsm-an-refresh-btn {
    width: 30px; height: 30px;
    border: 1px solid #dde1e9; background: #ffffff;
    border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #6b7280; transition: all 140ms; padding: 0;
}
.lsm-an-refresh-btn svg { width: 14px; height: 14px; transition: transform 140ms; }
.lsm-an-refresh-btn:hover { color: #1d4ed8; border-color: #bfdbfe; background: #dbeafe; }
.lsm-an-refresh-btn.active { color: #047857; border-color: #6ee7b7; background: #d1fae5; }
.lsm-an-refresh-btn.active:hover { background: #a7f3d0; }

@keyframes lsmAnSpin { to { transform: rotate(360deg); } }

.lsm-an-countdown {
    font-size: 11px; font-weight: 700; color: #047857;
    background: #d1fae5; border: 1px solid #6ee7b7;
    padding: 2px 8px; border-radius: 20px;
    min-width: 34px; text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ── Status bar ──────────────────────────────────────────────── */
.lsm-an-status-bar {
    padding: 5px 20px; background: #f5f7fa;
    border-bottom: 1px solid #e3e6eb; min-height: 24px;
}
.lsm-an-last-update { font-size: 10.5px; color: #9ca3af; }

/* ── Country bars ────────────────────────────────────────────── */
.lsm-an-countries { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }

.lsm-an-two-col {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px;
}
@media (max-width: 600px) { .lsm-an-two-col { grid-template-columns: 1fr; } }

.lsm-an-sessions { padding: 4px 0; }
.lsm-an-sessions-table {
    width: 100%; border-collapse: collapse; font-size: 11.5px;
}
.lsm-an-sessions-table th {
    padding: 6px 8px; text-align: left; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px; color: var(--lsm-an-tx3);
    border-bottom: 1px solid var(--lsm-an-bdr); background: var(--lsm-an-surf2);
}
.lsm-an-sessions-table td {
    padding: 6px 8px; border-bottom: 1px solid var(--lsm-an-bdr);
    color: var(--lsm-an-tx); vertical-align: middle;
}
.lsm-an-sessions-table tbody tr:last-child td { border-bottom: none; }
.lsm-an-sessions-table tbody tr:hover td { background: var(--lsm-an-surf2); }
.lsm-an-session-id { font-family: monospace; font-size: 11px; color: var(--lsm-an-tx2); }
.lsm-an-country-row {
    display: flex; align-items: center; gap: 10px;
}
.lsm-an-country-name {
    font-size: 12px; font-weight: 600; color: #374151;
    min-width: 90px; max-width: 90px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lsm-an-country-bar-wrap {
    flex: 1; height: 8px; background: #f0f2f6;
    border-radius: 4px; overflow: hidden;
}
.lsm-an-country-bar {
    height: 100%; background: #1d4ed8;
    border-radius: 4px;
    transition: width .4s ease;
    min-width: 3px;
}
.lsm-an-country-bar.vod { background: #5b21b6; }
.lsm-an-country-val {
    font-size: 11.5px; font-weight: 700; color: #6b7280;
    min-width: 36px; text-align: right;
}

/* ── Wider drawer for analytics ─────────────────────────────── */
.lsm-fe-modal-analytics { width: 700px !important; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
    .lsm-an-kpis { grid-template-columns: 1fr 1fr; }
    .lsm-an-toolbar { gap: 8px; }
    .lsm-an-toolbar-right { width: 100%; justify-content: space-between; }
}
@media (max-width: 400px) { .lsm-an-kpis { grid-template-columns: 1fr; } }

/* ── Preview toggle button ───────────────────────────────────── */
.lsm-an-preview-btn {
    width: 30px; height: 30px;
    border: 1px solid #dde1e9; background: #ffffff;
    border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #6b7280; transition: all 140ms; padding: 0;
}
.lsm-an-preview-btn svg { width: 14px; height: 14px; }
.lsm-an-preview-btn:hover { color: #1d4ed8; border-color: #bfdbfe; background: #dbeafe; }
.lsm-an-preview-btn.active { color: #047857; border-color: #6ee7b7; background: #d1fae5; }

/* ── Inline preview container ────────────────────────────────── */
.lsm-an-preview-wrap {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #0d1117;
    border-bottom: 3px solid #1d4ed8;
    position: relative;
    overflow: hidden;
}
.lsm-an-preview-offline {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,.4); font-size: 13px;
}
