/* ==========================================
   1. RESET E VARIÁVEIS
========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0d0d0d;
    --card-bg: #1a1a1a;
    --primary-purple: #8a2be2;
    --accent-lila: #b19cd9;
    --error-red: #ff4d4d;
    --success-green: #00ff88;
    --text-white: #f5f5f5; 
    --gray: #333;
    --input-bg: #0b0b0b;
}

/* ==========================================
   2. BASE E TIPOGRAFIA
========================================== */
body {
    background-color: var(--bg-dark);
    color: var(--text-white);
    font-family: 'Montserrat', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

header {
    text-align: center;
    padding: 40px 20px 20px;
    width: 100%;
}

header h1 { font-size: 2.5rem; letter-spacing: 2px; }
header p { color: var(--accent-lila); font-size: 1.1rem; margin-top: 10px; }

footer { 
    width: 100%; 
    padding: 40px 0 20px; 
    text-align: center; 
    opacity: 0.7; 
    font-size: 0.9rem; 
}

footer p { 
    border-top: 1px solid var(--gray); 
    display: inline-block; 
    padding-top: 15px; 
}

/* ==========================================
   3. ESTRUTURA PRINCIPAL E PAINEL (MOBILE FIRST)
========================================== */
#dashboard {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.conteudo-monitor {
    display: flex;
    flex-direction: column; 
    gap: 20px;
    width: 100%;
}

/* CARDS GERAIS (API, Config e Logs) */
.api-card, .config-container, .logs-container {
    background-color: var(--card-bg);
    border: 1px solid var(--gray);
    border-radius: 15px;
    padding: 25px;
    width: 100%;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

/* ==========================================
   4. PAINEL GLOBAL (MINI-CARDS) - MOBILE QUADRADO
========================================== */
.painel-geral {
    display: grid;
    grid-template-columns: repeat(2, 1fr); 
    gap: 15px;
    width: 100%;
    margin-bottom: 20px;
}

.mini-card {
    background-color: var(--card-bg);
    border: 1px solid var(--gray);
    border-radius: 12px;
    padding: 15px; 
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s, border-color 0.2s;
    cursor: pointer;
    text-align: center;
}

.mini-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary-purple);
}

.mini-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem; 
}

.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-on { background-color: var(--success-green); box-shadow: 0 0 8px var(--success-green); }
.dot-off { background-color: var(--error-red); }

.mini-card-modelo { font-size: 0.75rem; color: var(--accent-lila); }
.mini-card-consumo { font-size: 0.8rem; margin-top: 2px; }

.mini-barra-fundo { width: 100%; height: 4px; background: #333; border-radius: 2px; margin-top: 3px; overflow: hidden; }
.mini-barra-fill { height: 100%; background: var(--primary-purple); }

/* ==========================================
   5. MONITOR VISUAL (GAUGE E BARRAS)
========================================= */
.clock-container { display: flex; justify-content: center; width: 100%; }
.gauge { width: 180px; height: 90px; position: relative; overflow: hidden; margin-bottom: 15px; }
.gauge-body { width: 180px; height: 180px; background: #5b5656; position: absolute; top: 0; left: 0; border-radius: 50%; }
.gauge-fill { position: absolute; top: 100%; left: 0; width: 100%; height: 100%; background: linear-gradient(to right, #9036e4, #b19cd9); transform-origin: center top; transition: transform 1.2s cubic-bezier(0.25, 1, 0.5, 1); border-radius: 0 0 90px 90px; }
.gauge-cover { width: 80%; height: 160%; background: var(--card-bg); border-radius: 50%; position: absolute; top: 20%; left: 10%; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: bold; color: white; padding-bottom: 30%; }

.nome-do-modelo { text-align: center; margin-bottom: 5px; }
.status { text-align: center; color: var(--accent-lila); margin-bottom: 15px; font-size: 0.9rem; }

.consumo-container { margin-top: 5px; padding: 12px; background: rgba(255, 255, 255, 0.03); border-radius: 10px; }
.barra-fundo { width: 100%; height: 6px; background: #333; border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
#barra-progresso { width: 0%; height: 100%; background: linear-gradient(90deg, var(--primary-purple), var(--success-green)); transition: width 1s ease; }
#valor-consumo { font-weight: bold; color: var(--success-green); }

/* ==========================================
   6. FORMULÁRIOS E INPUTS
========================================== */
.config-container h3 { margin-bottom: 20px; text-align: center; }

.input-group { margin-bottom: 15px; }
.input-group label { display: block; font-size: 0.8rem; color: var(--accent-lila); margin-bottom: 5px; }
.input-group input, .input-group select { width: 100%; padding: 10px; background: var(--input-bg); border: 1px solid var(--gray); color: white; border-radius: 8px; outline: none; transition: 0.3s; font-size: 0.9rem; }
.input-group input:focus, .input-group select:focus { border-color: var(--primary-purple); box-shadow: 0 0 8px rgba(138, 43, 226, 0.3); }

select option { background-color: var(--card-bg); color: var(--text-white); padding: 10px; }

/* ==========================================
   7. TABELA DE LOGS
========================================== */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.8rem; }
th { text-align: left; color: var(--primary-purple); padding-bottom: 8px; border-bottom: 1px solid #333; }
td { padding: 8px 0; border-bottom: 1px solid #222; }

.status-ok { color: var(--success-green); font-weight: bold; }
.token-badge { background: var(--primary-purple); padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; }

/* ==========================================
   8. BOTÕES GERAIS E GRUPO DE BOTÕES
========================================== */
#dashboard button {
    color: var(--text-white);
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
    width: 100%;
    margin-top: 10px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* DESTAQUE: Botão Verificar Agora (dentro do card central) */
.api-card button {
    background-color: var(--primary-purple) !important;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
}

/* Botão Sair (Cabeçalho - discreto e elegante) */
.btn-logout {
    background-color: transparent !important;
    border: 1px solid var(--error-red) !important;
    color: var(--error-red) !important;
    width: auto !important;
    padding: 6px 15px !important;
    font-size: 0.8rem !important;
    margin-left: 15px;
    font-weight: 600;
}

.btn-logout:hover {
    background-color: var(--error-red) !important;
    color: white !important;
}

/* Cores dos Relatórios */
.btn-salvar { background-color: var(--primary-purple) !important; }
.btn-csv { background-color: #27ae60 !important; } /* Verde Excel */
.btn-pdf { background-color: #e74c3c !important; } /* Vermelho PDF */

.btn-limpar {
    background-color: transparent !important;
    border: 1px solid var(--error-red) !important;
    color: var(--error-red);
}

.btn-limpar:hover {
    background-color: var(--error-red) !important;
    color: white;
}

/* Container dos botões de exportação */
.export-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.export-actions button {
    margin-top: 0 !important;
}

#dashboard button:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
}

/* ==========================================
   9. RESPONSIVIDADE (TABLET E DESKTOP)
========================================== */

@media (min-width: 768px) {
    #dashboard { padding: 20px; }
    .painel-geral { gap: 20px; }
    .api-card, .config-container, .logs-container { padding: 40px; }
    
    .botoes-form {
        flex-direction: column;
        gap: 15px;
    }

    .export-actions {
        flex-direction: row; 
        gap: 10px;
    }

    .botoes-form button { margin-top: 0 !important; }
    
    .nome-do-modelo { font-size: 1.2rem; }
    .gauge { width: 200px; height: 100px; }
    .gauge-body { width: 200px; height: 200px; }
    .gauge-cover { font-size: 1.5rem; }
    
    table { font-size: 0.9rem; }
    .token-badge { padding: 3px 8px; font-size: 0.8rem; }
}

@media (min-width: 1024px) {
    .painel-geral {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
    
    .mini-card {
        padding: 20px;
        gap: 10px;
        text-align: left;
    }

    .conteudo-monitor {
        flex-direction: row; 
        align-items: stretch;
    }
    
    .api-card, .config-container {
        flex: 1;
    }
}
