/* ============================================================
   analytics.css — SOKYO Analytics
   ============================================================ */

/* ── Hero ─────────────────────────────────────────────────── */
.ar-hero { padding: 72px 24px 56px; position: relative; overflow: hidden; }
@media (max-width: 640px) { .ar-hero { padding: 48px 16px 36px; } }
.ar-hero__blobs { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ar-hero__inner { max-width: 1280px; margin: 0 auto; position: relative; z-index: 10; }
.ar-hero__actions { display: flex; align-items: center; gap: 12px; margin-top: 28px; flex-wrap: wrap; }

/* ── Download button ──────────────────────────────────────── */
.ar-btn-download {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 22px; border-radius: var(--md-sys-shape-corner-full);
    font-size: 14px; font-weight: 700; cursor: pointer; border: none;
    background: linear-gradient(135deg, var(--c-moss) 0%, #3d5e28 100%);
    color: #fff; box-shadow: 0 4px 14px rgba(110,156,77,.30);
    transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
    text-decoration: none; white-space: nowrap;
}
.ar-btn-download:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(110,156,77,.40); }
.ar-btn-download:active { transform: translateY(0); opacity: .88; }
.ar-btn-download .material-symbols-rounded { font-size: 18px; }
.ar-btn-download.loading { opacity: .65; pointer-events: none; }

/* ── Jump nav ─────────────────────────────────────────────── */
.ar-jump-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.ar-jump-pill {
    display: inline-flex; align-items: center; gap: 5px; padding: 6px 14px;
    border-radius: var(--md-sys-shape-corner-full); font-size: 12px; font-weight: 600;
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
    cursor: pointer; text-decoration: none;
    transition: background 120ms ease, color 120ms ease;
    white-space: nowrap;
}
.ar-jump-pill:hover { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); }
.ar-jump-pill .material-symbols-rounded { font-size: 14px; }

/* ── Main content ─────────────────────────────────────────── */
.ar-main { max-width: 1280px; margin: 0 auto; padding: 0 24px 80px; }
@media (max-width: 640px) { .ar-main { padding: 0 16px 60px; } }

/* ── Section ─────────────────────────────────────────────── */
.ar-section { margin-bottom: 64px; }
.ar-section-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.ar-section-meta {
    font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
    color: var(--md-sys-color-on-surface-variant);
    text-transform: uppercase; margin-top: 5px;
}
.ar-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--md-sys-color-outline-variant), transparent);
    margin: 56px 0;
}
.ar-summary-card {
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 14px 18px; font-size: 13.5px; line-height: 1.7;
    color: var(--md-sys-color-on-surface-variant); margin-bottom: 16px;
}
.ar-empty {
    display: flex; flex-direction: column; align-items: center;
    padding: 56px 24px; text-align: center; gap: 12px;
    background: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-extra-large);
    border: 1px dashed var(--md-sys-color-outline-variant);
}
.ar-empty .material-symbols-rounded { font-size: 40px; color: var(--md-sys-color-on-surface-variant); }
.ar-empty p { font-size: 14px; color: var(--md-sys-color-on-surface-variant); max-width: 280px; }

/* ═══════════════════════════════════════════════════════════
   KPI CARDS
   ═══════════════════════════════════════════════════════════ */
.ar-kpi-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
/* Tablet: 3 + 2 */
@media (max-width: 860px) {
    .ar-kpi-row { grid-template-columns: repeat(3, 1fr); }
}
/* Mobile: 2 columns */
@media (max-width: 500px) {
    .ar-kpi-row { grid-template-columns: repeat(2, 1fr); }
    /* hide 5th card on very small screens to keep even grid */
    .ar-kpi-row > :nth-child(5) { display: none; }
}

.ar-kpi-card {
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 14px 14px 14px 18px;
    position: relative; overflow: hidden;
    transition: box-shadow 160ms ease, border-color 160ms ease;
    cursor: default; min-width: 0;
}
.ar-kpi-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.09); border-color: var(--md-sys-color-outline); }
.ar-kpi-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px; background: var(--ar-kpi-accent, var(--c-moss));
}
.ar-kpi-card__label {
    font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em;
    color: var(--md-sys-color-on-surface-variant);
    text-transform: uppercase; margin-bottom: 5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ar-kpi-card__value {
    font-size: 20px; font-weight: 800; letter-spacing: -0.02em;
    color: var(--md-sys-color-on-surface); line-height: 1.1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 640px) { .ar-kpi-card__value { font-size: 16px; } }
.ar-kpi-card__trend {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 11px; font-weight: 700; margin-top: 4px;
}
.ar-kpi-card__trend--up   { color: #16a34a; }
.ar-kpi-card__trend--down { color: #dc2626; }
.ar-kpi-card__trend--flat { color: var(--md-sys-color-on-surface-variant); }
.ar-kpi-card__trend .material-symbols-rounded { font-size: 13px; }
body.dark .ar-kpi-card { background: var(--md-sys-color-surface-container-high); }

/* ═══════════════════════════════════════════════════════════
   CHART PANELS
   ═══════════════════════════════════════════════════════════ */
.ar-chart-panel {
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-extra-large);
    overflow: hidden;
    margin-bottom: 16px;
    min-width: 0;
}
.ar-chart-panel__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px;
    background: var(--md-sys-color-surface-container);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    gap: 10px; flex-wrap: wrap; min-width: 0;
}
.ar-chart-panel__title {
    font-size: 13px; font-weight: 700;
    color: var(--md-sys-color-on-surface);
    display: flex; align-items: center; gap: 7px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ar-chart-panel__title .material-symbols-rounded { font-size: 15px; color: var(--c-moss); flex-shrink: 0; }
.ar-chart-panel__sub {
    font-size: 11px; color: var(--md-sys-color-on-surface-variant); margin-top: 1px;
}
.ar-chart-panel__body { padding: 16px 18px; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Legend chips */
.ar-legend-chips { display: flex; gap: 12px; flex-wrap: wrap; flex-shrink: 0; }
.ar-legend-chip { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--md-sys-color-on-surface-variant); white-space: nowrap; }
.ar-legend-chip__dot { width: 20px; height: 3px; border-radius: 2px; flex-shrink: 0; }

/* Chart canvas wrappers — always set explicit height */
.ar-chart-wrap { position: relative; }
.ar-chart-row {
    display: grid; grid-template-columns: 1fr;
    gap: 14px; margin-bottom: 16px;
}
@media (min-width: 860px) {
    .ar-chart-row--2col { grid-template-columns: 1fr 1fr; }
    .ar-chart-row--tel  { grid-template-columns: 2fr 1fr; }
}

/* Donut labels */
.ar-donut-label { text-align: center; margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--md-sys-color-on-surface); }
.ar-donut-sub   { text-align: center; font-size: 10px; color: var(--md-sys-color-on-surface-variant); margin-top: 1px; }

/* ═══════════════════════════════════════════════════════════
   UNIFIED TABLE  (SoC · Smartphone · Telco — identical)
   ═══════════════════════════════════════════════════════════ */
.ar-table-wrap {
    overflow-x: auto;
    border-radius: var(--md-sys-shape-corner-extra-large);
    border: 1px solid var(--md-sys-color-outline-variant);
    /* smooth momentum scroll on iOS */
    -webkit-overflow-scrolling: touch;
}
.ar-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ar-table thead { background: var(--md-sys-color-surface-container); }
.ar-table th {
    padding: 11px 14px; text-align: left; font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--md-sys-color-on-surface-variant);
    white-space: nowrap; border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.ar-table td {
    padding: 10px 14px; color: var(--md-sys-color-on-surface);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    vertical-align: middle;
}
.ar-table tbody tr:last-child td { border-bottom: none; }
.ar-table tbody tr { background: var(--md-sys-color-surface-container-low); transition: background 100ms ease; }
.ar-table tbody tr:hover { background: var(--md-sys-color-surface-container); }

/* ── Rank badge ──────────────────────────────────────────── */
.ar-rank {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px;
    border-radius: var(--md-sys-shape-corner-full);
    font-size: 11px; font-weight: 800; flex-shrink: 0;
}
.ar-rank--gold   { background: #FEF3C7; color: #92400E; }
.ar-rank--silver { background: #F1F5F9; color: #475569; }
.ar-rank--bronze { background: #FEF0E7; color: #9A3412; }
.ar-rank--default{ background: var(--md-sys-color-surface-container); color: var(--md-sys-color-on-surface-variant); }

/* ── Tier badge ──────────────────────────────────────────── */
.ar-tier { display: inline-block; padding: 2px 9px; border-radius: var(--md-sys-shape-corner-full); font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; }
.ar-tier--flagship  { background: color-mix(in srgb, #7C3AED 14%, transparent); color: #7C3AED; }
.ar-tier--high-end  { background: color-mix(in srgb, #3F6212 14%, transparent); color: #3F6212; }
.ar-tier--mid-range { background: color-mix(in srgb, #0284C7 14%, transparent); color: #0284C7; }
.ar-tier--budget    { background: color-mix(in srgb, #6E7566 14%, transparent); color: #6E7566; }
body.dark .ar-tier--flagship  { background: color-mix(in srgb, #A78BFA 18%, transparent); color: #A78BFA; }
body.dark .ar-tier--high-end  { background: color-mix(in srgb, #A3C77E 18%, transparent); color: #A3C77E; }
body.dark .ar-tier--mid-range { background: color-mix(in srgb, #38BDF8 18%, transparent); color: #38BDF8; }

/* ── Score bar (AnTuTu inline in tables) ─────────────────── */
.ar-score-bar { display: flex; align-items: center; gap: 8px; min-width: 100px; }
.ar-score-bar__track { flex: 1; height: 5px; background: var(--md-sys-color-surface-container-highest); border-radius: 3px; overflow: hidden; min-width: 48px; }
.ar-score-bar__fill  { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--c-moss) 0%, var(--c-moss-light, #aebf96) 100%); }
.ar-score-bar__val   { font-size: 11.5px; font-weight: 700; color: var(--md-sys-color-on-surface); white-space: nowrap; min-width: 44px; text-align: right; }

/* ── Rating dot (used in phone table) ───────────────────── */
.ar-rating {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 700;
}
.ar-rating__dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.ar-rating--high  .ar-rating__dot { background: #16A34A; }
.ar-rating--mid   .ar-rating__dot { background: #D97706; }
.ar-rating--low   .ar-rating__dot { background: #DC2626; }

/* ── Telco speed cells ───────────────────────────────────── */
.ar-speed-val  { font-size: 13px; font-weight: 700; color: var(--md-sys-color-on-surface); }
.ar-speed-unit { font-size: 10px; color: var(--md-sys-color-on-surface-variant); font-weight: 500; }
.ar-latency    { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--md-sys-shape-corner-full); font-size: 11.5px; font-weight: 700; }
.ar-latency--low    { background: color-mix(in srgb, #16A34A 12%, transparent); color: #16A34A; }
.ar-latency--medium { background: color-mix(in srgb, #D97706 12%, transparent); color: #D97706; }
.ar-latency--high   { background: color-mix(in srgb, #DC2626 12%, transparent); color: #DC2626; }

/* ── Toast ───────────────────────────────────────────────── */
.ar-toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--md-sys-color-inverse-surface, #2d3130);
    color: var(--md-sys-color-inverse-on-surface, #eff1ee);
    padding: 11px 22px; border-radius: var(--md-sys-shape-corner-full);
    font-size: 13.5px; font-weight: 500; z-index: 9999;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    transition: transform 300ms cubic-bezier(.34,1.56,.64,1);
    white-space: nowrap; display: flex; align-items: center; gap: 10px;
}
.ar-toast.visible { transform: translateX(-50%) translateY(0); }
.ar-toast .material-symbols-rounded { font-size: 17px; }

/* ── Print ───────────────────────────────────────────────── */
@media print {
    .md3-top-app-bar, .md3-drawer, .md3-scrim, .md3-footer,
    .ar-hero__blobs, .ar-btn-download, .ar-jump-nav,
    #theme-toggle, #openSidebar { display: none !important; }
    body  { background: #fff !important; color: #000 !important; }
    .ar-hero { padding: 20px 0 14px; }
    .ar-main { padding: 0 0 40px; max-width: 100%; }
    .ar-section { margin-bottom: 36px; break-inside: avoid; }
    .ar-divider { margin: 28px 0; }
    .ar-kpi-card { background: #f4f4f4 !important; border: 1px solid #ccc !important; }
    .ar-kpi-card__value { color: #000 !important; }
    .ar-chart-panel { background: #f9f9f9 !important; border: 1px solid #ddd; break-inside: avoid; }
    .ar-chart-row { grid-template-columns: 1fr !important; }
    .ar-table-wrap { border: 1px solid #ccc; border-radius: 0; }
    .ar-table thead { background: #efefef !important; }
    .ar-table th, .ar-table td { color: #000 !important; border-color: #ddd !important; }
    .ar-table tbody tr { background: #fff !important; }
}
