/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root[data-theme="light"] {
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.75);
    --card-border: rgba(226, 232, 240, 0.8);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent: #4f46e5;
    --accent-glow: rgba(79, 70, 229, 0.15);
    --success: #10b981;
    --circle-bg: rgba(241, 245, 249, 0.6);
    --metric-bg: rgba(241, 245, 249, 0.5);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
    --glow-1: rgba(79, 70, 229, 0.04);
    --glow-2: rgba(16, 185, 129, 0.02);
    --header-bg: rgba(255, 255, 255, 0.8);
}

:root[data-theme="dark"] {
    --bg-color: #020617;
    --card-bg: rgba(15, 23, 42, 0.45);
    --card-border: rgba(51, 65, 85, 0.3);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --success: #10b981;
    --circle-bg: rgba(2, 6, 23, 0.2);
    --metric-bg: rgba(15, 23, 42, 0.3);
    --shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    --glow-1: rgba(99, 102, 241, 0.08);
    --glow-2: rgba(16, 185, 129, 0.05);
    --header-bg: rgba(2, 6, 23, 0.7);
}

/* ── Reset & Base ───────────────────────────────────────────────────────────── */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

body::before,
body::after {
    content: '';
    position: fixed;
    width: 45vw;
    height: 45vw;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    pointer-events: none;
}

body::before {
    top: -10%;
    left: -10%;
    background: var(--glow-1);
}

body::after {
    bottom: -10%;
    right: -10%;
    background: var(--glow-2);
}

/* ── Header ────────────────────────────────────────────────────────────────── */
header {
    background: var(--header-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--card-border);
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.enterprise-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.brand-divider {
    width: 1px;
    height: 18px;
    background: var(--card-border);
}

.logo-text {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    background: var(--metric-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

:root[data-theme="light"] .theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.15);
    color: var(--success);
    padding: 5px 12px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--success); }
    50%       { opacity: 0.3; box-shadow: none; }
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */
main {
    flex: 1;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 1.25rem;
    padding: 1rem 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    height: calc(100vh - 100px);
    min-height: 0;
}

/* ── Test Card (Kiri) ────────────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 0;
    gap: 0.75rem;
}

.test-circle {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 2px dashed var(--card-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: var(--circle-bg);
    transition: border-color 0.3s ease;
}

.test-circle::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--accent);
    border-right-color: var(--accent);
    animation: spin 1.2s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.testing .test-circle::before { opacity: 1; }
.testing .test-circle         { border-color: transparent; }

@keyframes spin { 100% { transform: rotate(360deg); } }

.speed-large {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -2px;
    color: var(--text-main);
}

.speed-unit {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

.test-label {
    position: absolute;
    bottom: 22px;
    font-size: 0.68rem;
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.testing .test-label { opacity: 1; }

/* ── Grade Badge ────────────────────────────────────────────────────────────── */
.grade-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    animation: fadeInUp 0.5s ease both;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.grade-badge {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -1px;
    border: 2px solid;
    transition: all 0.3s ease;
}

.grade-S { background: rgba(251, 191, 36, 0.12); border-color: #fbbf24; color: #fbbf24; box-shadow: 0 0 18px rgba(251, 191, 36, 0.25); }
.grade-A { background: rgba(16, 185, 129, 0.12); border-color: #10b981; color: #10b981; box-shadow: 0 0 18px rgba(16, 185, 129, 0.2); }
.grade-B { background: rgba(56, 189, 248, 0.12); border-color: #38bdf8; color: #38bdf8; box-shadow: 0 0 18px rgba(56, 189, 248, 0.2); }
.grade-C { background: rgba(99, 102, 241, 0.12); border-color: #6366f1; color: #6366f1; box-shadow: 0 0 18px rgba(99, 102, 241, 0.2); }
.grade-D { background: rgba(251, 146, 60, 0.12); border-color: #fb923c; color: #fb923c; }
.grade-F { background: rgba(239, 68, 68, 0.12);  border-color: #ef4444; color: #ef4444; }

.grade-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ── Tombol ─────────────────────────────────────────────────────────────────── */
.btn-start {
    background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
    color: white;
    border: none;
    padding: 11px 34px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 20px var(--accent-glow);
    transition: filter 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-start:hover {
    filter: brightness(1.12);
    transform: translateY(-2px);
    box-shadow: 0 12px 28px var(--accent-glow);
}

.btn-start:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* ── Dashboard (Kanan) ──────────────────────────────────────────────────────── */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    height: 100%;
    min-height: 0;
}

/* ── Metric Cards Grid ──────────────────────────────────────────────────────── */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    flex-shrink: 0;
}

.metric-card {
    background: var(--metric-bg);
    border: 1px solid var(--card-border);
    padding: 0.8rem 1.1rem;
    border-radius: 12px;
    transition: border-color 0.3s ease;
}

.metric-card:hover {
    border-color: rgba(99, 102, 241, 0.25);
}

.metric-title {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.metric-value {
    font-size: 1.65rem;
    font-weight: 700;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.metric-value span:last-child {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.ping-val   { color: #f472b6; }
.jitter-val { color: #fb923c; }
.dl-val     { color: #38bdf8; }
.ul-val     { color: #a78bfa; }

/* ── AI Section ─────────────────────────────────────────────────────────────── */
.ai-section {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.06) 0%, rgba(167, 139, 250, 0.03) 100%);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 0.9rem 1.1rem;
    display: none;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1.2;
    min-height: 0;
    overflow-y: auto;
    animation: fadeInUp 0.4s ease both;
}

.ai-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.ai-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6366f1;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-profile-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid;
    white-space: nowrap;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

/* ── Score Chips ────────────────────────────────────────────────────────────── */
.ai-score-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex-shrink: 0;
}

.ai-score-item {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
    border: 1px solid;
    white-space: nowrap;
}

.chip-good {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.chip-ok {
    background: rgba(251, 146, 60, 0.1);
    border-color: rgba(251, 146, 60, 0.3);
    color: #fb923c;
}

.chip-bad {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* ── Anomaly Alert Row ──────────────────────────────────────────────────────── */
.ai-anomaly {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex-shrink: 0;
}

.anomaly-chip {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 5px;
    white-space: nowrap;
}

.anomaly-warn {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #fbbf24;
}

.anomaly-info {
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.25);
    color: #38bdf8;
}

/* ── AI Summary ─────────────────────────────────────────────────────────────── */
.ai-summary {
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-main);
    font-weight: 500;
    flex-shrink: 0;
}

/* ── Use-Case Capability Grid ───────────────────────────────────────────────── */
.use-case-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    flex-shrink: 0;
}

.use-case-card {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 7px;
    border-radius: 7px;
    border: 1px solid;
    font-size: 0.66rem;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.uc-icon { font-size: 0.8rem; flex-shrink: 0; }
.uc-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-status {
    font-size: 0.72rem;
    font-weight: 800;
    flex-shrink: 0;
}

.uc-ok {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
    color: #10b981;
}

.uc-partial {
    background: rgba(251, 146, 60, 0.08);
    border-color: rgba(251, 146, 60, 0.25);
    color: #fb923c;
}

.uc-fail {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    opacity: 0.7;
}

/* ── AI Tips ────────────────────────────────────────────────────────────────── */
.ai-tips-container {
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
}

.ai-tip-item {
    display: flex;
    gap: 7px;
    align-items: flex-start;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.ai-tip-item span:first-child {
    color: var(--success);
    flex-shrink: 0;
    margin-top: 1px;
}

/* ── Info Section ───────────────────────────────────────────────────────────── */
.info-section {
    background: var(--metric-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.9rem 1.1rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.info-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.2rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.32rem 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.06);
    gap: 6px;
}

.info-label {
    color: var(--text-muted);
    font-size: 0.74rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.info-data {
    font-weight: 600;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
    text-align: right;
}

.info-mono {
    font-family: 'Courier New', monospace;
    background: rgba(148, 163, 184, 0.1);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.73rem;
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.68rem;
    font-weight: 700;
    border: 1px solid rgba(99, 102, 241, 0.2);
    white-space: nowrap;
}

.badge-warn {
    background: rgba(251, 146, 60, 0.12);
    color: #fb923c;
    border-color: rgba(251, 146, 60, 0.25);
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
footer {
    text-align: center;
    padding: 0.5rem 2rem;
    color: #64748b;
    font-size: 0.75rem;
    border-top: 1px solid var(--card-border);
    background: var(--header-bg);
    backdrop-filter: blur(8px);
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
}

footer a:hover { color: var(--accent); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    body {
        overflow-y: auto;
        height: auto;
        max-height: none;
    }

    main {
        grid-template-columns: 1fr;
        height: auto;
        padding: 1rem;
    }

    .test-circle {
        width: 190px;
        height: 190px;
    }

    .speed-large { font-size: 3.2rem; }

    .info-grid { grid-template-columns: 1fr; }
}