/* ====================================
   RESET E VARIÁVEIS GLOBAIS
   ==================================== */

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

:root {
    /* DARK THEME (Padrão) */
    --primary: #F47A20;
    --primary-glow: rgba(244, 122, 32, 0.4);
    --primary-dark: #cc6012;
    
    --bg-main: #0b0c10;
    --bg-panel: #1a202c;
    --bg-panel-light: #2d3748;
    --text-main: #f7fafc;
    --text-muted: #a0aec0;
    --border-color: #2d3748;
    --bg-glow-color: rgba(244,122,32,0.05);
    
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --transition: all 0.3s ease;
}

/* LIGHT THEME */
body.light-theme {
    --bg-main: #f8f9fa;
    --bg-panel: #ffffff;
    --bg-panel-light: #e2e8f0;
    --text-main: #1a202c;
    --text-muted: #718096;
    --border-color: #cbd5e0;
    --bg-glow-color: rgba(244,122,32,0.08);
}

html, body {
    min-height: 100vh;
    width: 100%;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-family);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Brilho de Fundo */
.bg-glow {
    position: fixed;
    top: -30%;
    left: 50%;
    transform: translateX(-50%);
    width: 80vw;
    height: 80vw;
    background: radial-gradient(circle, var(--bg-glow-color) 0%, transparent 60%);
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
    transition: background 0.4s ease;
}

/* ====================================
   NAVBAR & LOGO & TEMA
   ==================================== */
.navbar {
    position: relative;
    z-index: 10;
    padding: 24px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-img {
    height: 70px;
    width: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.logo-link:hover .logo-img {
    transform: scale(1.05);
}

.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--bg-panel);
}

.hidden {
    display: none !important;
}

/* ====================================
   CONTAINER PRINCIPAL
   ==================================== */
.container {
    position: relative;
    z-index: 2;
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ====================================
   STATUS E IP CLIENTE
   ==================================== */
.status-section {
    margin-bottom: 30px;
    text-align: center;
    min-height: 30px;
}

.status-text {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.status-text.testing {
    color: var(--primary);
}

.client-ip {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
    letter-spacing: 1px;
}

.client-ip span {
    color: var(--primary);
    font-weight: 600;
}

/* ====================================
   MÉTRICAS PRINCIPAIS
   ==================================== */
.main-display {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    margin-bottom: 40px;
}

.ping-section {
    text-align: center;
}

.speed-metrics {
    display: flex;
    width: 100%;
    gap: 30px;
    justify-content: center;
}

.metric-box {
    flex: 1;
    max-width: 300px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 30px 20px;
    text-align: center;
    transition: var(--transition);
}

.metric-box.active {
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
    transform: scale(1.02);
}

.metric-title {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.metric-huge-value {
    font-size: 3.5rem;
    font-weight: 300;
    color: var(--text-main);
    line-height: 1;
    margin-bottom: 5px;
    font-variant-numeric: tabular-nums;
}

.metric-primary-value {
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-main);
}

.metric-unit, .unit {
    color: var(--text-muted);
    font-size: 1rem;
}

.progress-track {
    width: 100%;
    height: 4px;
    background: var(--bg-panel-light);
    border-radius: 2px;
    margin-top: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    transition: width 0.2s ease-out;
}

/* ====================================
   BOTÃO INICIAR
   ==================================== */
.action-section {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.btn-start {
    position: relative;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 500;
    text-transform: uppercase;
    cursor: pointer;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    text-align: center;
}

.btn-start:hover:not(:disabled) {
    background: rgba(244, 122, 32, 0.1);
    box-shadow: 0 0 30px var(--primary-glow);
}

.btn-start:disabled {
    border-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    animation: none;
}

.btn-ring {
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    border-radius: 50%;
    border: 2px solid transparent;
}

.pulse-anim:not(:disabled) .btn-ring {
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
    border-color: var(--primary);
}

@keyframes ping {
    75%, 100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* ====================================
   RESULTADOS AVANÇADOS
   ==================================== */
.results-section {
    width: 100%;
    max-width: 700px;
    text-align: center;
    margin-bottom: 25px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

.result-data {
    display: flex;
    flex-direction: column;
}

.res-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.res-value {
    color: var(--text-main);
    font-size: 1.3rem;
    font-weight: 500;
}

/* ====================================
   SELETOR DE SERVIDOR (CORREÇÃO MOBILE)
   ==================================== */
.server-control {
    width: 100%;
    max-width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
    padding: 0 10px;
}

.server-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-panel);
    padding: 8px 16px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    max-width: 90vw; /* Garante que não estoure a tela */
    box-sizing: border-box;
}

.server-selector-wrapper:hover {
    border-color: var(--primary);
}

.gear-icon {
    color: var(--text-muted);
    transition: color 0.3s ease, transform 0.4s ease;
    flex-shrink: 0; /* Impede do ícone esmagar */
}

.server-selector-wrapper:hover .gear-icon {
    color: var(--primary);
    transform: rotate(90deg);
}

.custom-select {
    position: relative;
    flex: 1;
    min-width: 0; /* CRUCIAL: Permite truncar texto dentro do flexbox */
}

select {
    width: 100%;
    appearance: none;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 500;
    padding-right: 15px;
    cursor: pointer;
    outline: none;
    text-overflow: ellipsis; /* Corta textos enormes */
    overflow: hidden;
    white-space: nowrap;
}

select:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

select option {
    background: var(--bg-panel);
    color: var(--text-main);
}

.active-server {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

.active-server span {
    color: var(--primary);
    font-weight: 600;
}

/* ====================================
   DICAS (TIPS SECTION)
   ==================================== */
.tips-section {
    width: 100%;
    max-width: 650px;
    background: var(--bg-panel);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 30px;
    text-align: left;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.tips-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.tips-title svg {
    color: var(--primary);
}

.tips-list {
    list-style-type: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.tips-list li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 12px;
}

.tips-list li:last-child {
    margin-bottom: 0;
}

.tips-list li::before {
    content: "•";
    color: var(--primary);
    position: absolute;
    left: 0;
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1.4;
}

.tips-list li strong {
    color: var(--text-main);
    font-weight: 600;
}

/* ====================================
   FOOTER E ANIMAÇÕES
   ==================================== */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: auto;
}

.animate-fade {
    animation: fadeIn 0.8s ease-out backwards;
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

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

/* Responsividade Mobile Extra */
@media (max-width: 600px) {
    .speed-metrics {
        flex-direction: column;
        align-items: center;
    }
    .metric-box {
        width: 100%;
    }
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .navbar {
        padding: 20px;
    }
    .logo-img {
        height: 45px; /* Logo um pouco menor no celular */
    }
}
