/* ══════════════════════════════════════════
   SPEEDTEST — MAIN LAYOUT
   ══════════════════════════════════════════ */
.speedtest-page {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    padding: 10px 0 40px;
}

/* ══════════════════════════════════════════
   GAUGE SECTION
   ══════════════════════════════════════════ */
.speedtest-gauge-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    width: 100%;
}

.speedtest-gauge-wrap {
    position: relative;
    width: 320px;
    height: 230px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.speedtest-gauge-svg {
    width: 100%;
    height: auto;
    position: absolute;
    top: 0;
    left: 0;
}

.speedtest-gauge-bg {
    stroke: rgba(255, 255, 255, 0.06);
}

.speedtest-gauge-fill {
    stroke-dasharray: 345;
    stroke-dashoffset: 345;
    transition: stroke-dashoffset 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.speedtest-gauge-value {
    position: absolute;
    top: 52%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 56px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Space Mono', monospace;
    line-height: 1;
}

.speedtest-gauge-unit {
    position: absolute;
    top: 72%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.speedtest-gauge-phase {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    color: var(--emerald);
    font-weight: 500;
    white-space: nowrap;
    opacity: 0.85;
}

/* ══════════════════════════════════════════
   START BUTTON
   ══════════════════════════════════════════ */
.speedtest-start-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 48px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--emerald) 0%, #0ea5e9 100%);
    color: #0a1a12;
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    box-shadow: 0 4px 24px rgba(52, 211, 153, 0.25);
}

.speedtest-start-btn svg {
    width: 20px;
    height: 20px;
}

.speedtest-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(52, 211, 153, 0.35);
}

.speedtest-start-btn:active {
    transform: translateY(0);
}

.speedtest-start-btn.running {
    opacity: 0.6;
    pointer-events: none;
}

/* Pulse animation while running */
.speedtest-start-btn.running span::after {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    margin-left: 6px;
    animation: speedPulse 1.2s infinite;
}

@keyframes speedPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ══════════════════════════════════════════
   RESULTS CARDS
   ══════════════════════════════════════════ */
.speedtest-results {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    width: 100%;
    animation: stFadeUp 0.5s ease;
}

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

.speedtest-result-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: border-color 0.25s, transform 0.25s;
}

.speedtest-result-card:hover {
    border-color: rgba(52, 211, 153, 0.25);
    transform: translateY(-2px);
}

.speedtest-result-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.speedtest-result-icon svg {
    width: 22px;
    height: 22px;
}

.speedtest-result-icon.download {
    background: rgba(52, 211, 153, 0.12);
    color: #34d399;
}

.speedtest-result-icon.upload {
    background: rgba(14, 165, 233, 0.12);
    color: #0ea5e9;
}

.speedtest-result-icon.ping {
    background: rgba(167, 139, 250, 0.12);
    color: #a78bfa;
}

.speedtest-result-icon.jitter {
    background: rgba(251, 191, 36, 0.12);
    color: #fbbf24;
}

.speedtest-result-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.speedtest-result-val {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Space Mono', monospace;
    line-height: 1;
}

.speedtest-result-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: -4px;
}

/* ══════════════════════════════════════════
   HISTORY
   ══════════════════════════════════════════ */
.speedtest-history {
    width: 100%;
    padding: 24px;
}

.speedtest-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.speedtest-history-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.speedtest-clear-btn {
    padding: 6px 14px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.speedtest-clear-btn:hover {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.3);
}

.speedtest-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.speedtest-history-list::-webkit-scrollbar {
    width: 4px;
}

.speedtest-history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.speedtest-hist-row {
    display: grid;
    grid-template-columns: 1fr repeat(4, auto);
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    font-size: 13px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.speedtest-hist-date {
    color: var(--text-secondary);
    font-size: 12px;
}

.speedtest-hist-val {
    font-family: 'Space Mono', monospace;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

.speedtest-hist-val.dl { color: #34d399; }
.speedtest-hist-val.ul { color: #0ea5e9; }
.speedtest-hist-val.pg { color: #a78bfa; }
.speedtest-hist-val.jt { color: #fbbf24; }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
    .speedtest-results {
        grid-template-columns: repeat(2, 1fr);
    }

    .speedtest-gauge-wrap {
        width: 280px;
        height: 210px;
    }

    .speedtest-gauge-value {
        font-size: 48px;
    }

    .speedtest-hist-row {
        grid-template-columns: 1fr repeat(2, auto);
        gap: 10px;
        font-size: 12px;
    }

    .speedtest-hist-val.pg,
    .speedtest-hist-val.jt {
        display: none;
    }
}

@media (max-width: 480px) {
    .speedtest-page {
        gap: 24px;
        padding: 6px 0 32px;
    }

    .speedtest-gauge-wrap {
        width: min(260px, calc(100vw - 48px));
        height: 190px;
    }

    .speedtest-gauge-value {
        font-size: 42px;
    }

    .speedtest-gauge-unit {
        font-size: 12px;
    }

    .speedtest-gauge-phase {
        font-size: 12px;
    }

    .speedtest-start-btn {
        padding: 14px 40px;
        font-size: 15px;
        border-radius: 14px;
    }

    .speedtest-results {
        gap: 10px;
    }

    .speedtest-result-card {
        padding: 16px 12px;
        border-radius: 14px;
        gap: 8px;
    }

    .speedtest-result-val {
        font-size: 22px;
    }

    .speedtest-result-icon {
        width: 38px;
        height: 38px;
    }

    .speedtest-result-icon svg {
        width: 18px;
        height: 18px;
    }

    .speedtest-history {
        padding: 18px;
    }
}

@media (max-width: 360px) {
    .speedtest-gauge-wrap {
        width: min(230px, calc(100vw - 32px));
        height: 170px;
    }

    .speedtest-gauge-value {
        font-size: 36px;
    }
}
