:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-yellow: #eab308;
    --accent-blue: #3b82f6;
}

* {
    box-sizing: border-box;
}

.neon-blue {
    color: #00d4ff;
    text-shadow: 0 0 5px rgba(0, 212, 255, 0.7);
    font-style: italic;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, sans-serif;
    margin: 0;
    height: 100vh;
    overflow: hidden; /* Mantém o painel fixo no PC */
}

.dashboard-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 20px;
    gap: 20px;
}

/* Barra Superior de Estatísticas (PC) */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 10px 20px;
    border-radius: 15px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    height: auto;
}

/* Grupo de Botões (PC) */
.nav-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: auto;
    max-width: 320px;
}

/* Padronização Unificada de Todos os Botões no PC (incluindo ABANDONO) */
.nav-group button, 
.nav-group .btn-emergencia {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 6px 10px !important;
    font-size: 0.75rem !important;
    font-weight: bold !important;
    height: 32px !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
}

.stat-item {
    text-align: center;
}

.stat-item .label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.stat-item .value {
    font-size: 2rem;
    font-weight: 800;
}

.stat-item.alert .value {
    color: var(--accent-red);
}

.clock {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-blue);
}

/* Área Principal */
.main-content {
    display: flex;
    flex: 1;
    gap: 20px;
    min-height: 0; /* Essencial para o scroll interno funcionar */
}

/* Seção de Cards (Esquerda) */
.monitor-section {
    flex: 2;
    display: flex;
    flex-direction: column;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 15px;
    padding: 20px;
    overflow-y: auto; /* Scroll apenas aqui se houver muitos alunos */
}

.monitor-section h2 {
    margin-top: 0;
    font-size: 1.5rem;
    border-bottom: 2px solid var(--card-bg);
    padding-bottom: 10px;
}

.student-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    padding-top: 10px;
}

/* Card do Aluno Individual */
.student-card {
    background: var(--card-bg);
    padding: 18px;
    border-radius: 12px;
    border-left: 8px solid var(--accent-blue);
    position: relative;
    animation: slideIn 0.3s ease-out;
}

.student-card h3 {
    margin: 0;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.turma-tag {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--accent-yellow);
    font-weight: bold;
    margin-bottom: 8px;
}

.student-card p {
    margin: 10px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.time-elapsed {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text-main);
    display: block;
}

.auth-badge {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Estado Crítico (>10min) */
.student-card.critical {
    border-left-color: var(--accent-red);
    animation: pulse-red 2s infinite;
}

/* Lateral de Gráficos (Direita) */
.analytics-side {
    flex: 1;
    background: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.no-students {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-style: italic;
}

/* Animações */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Scrollbar Customizada */
.monitor-section::-webkit-scrollbar {
    width: 8px;
}
.monitor-section::-webkit-scrollbar-track {
    background: var(--bg-color);
}
.monitor-section::-webkit-scrollbar-thumb {
    background: var(--card-bg);
    border-radius: 10px;
}

/* ==========================================================================
   AJUSTES PARA DISPOSITIVOS MÓVEIS (CELULARES)
   ========================================================================== */
@media (max-width: 768px) {
    /* Destrava a rolagem VERTICAL no celular */
    html, body { 
        padding: 10px; 
        width: 100%;
        height: auto !important;
        min-height: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    .dashboard-container {
        height: auto !important;
        padding: 0 !important;
    }

    /* Empilha o cabeçalho no celular */
    .stats-bar {
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: visible !important;
        padding: 12px !important;
        gap: 12px !important;
    }

    .nav-group {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Botões ajustados no celular */
    .nav-group button, 
    .nav-group .btn-emergencia {
        font-size: 0.65rem !important;
        padding: 6px 4px !important;
        width: 100% !important;
        height: auto !important;
        box-sizing: border-box !important;
    }

    /* Carrossel de Turmas no celular */
    .cards-grid, .turmas-container, .classes-row {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
    }

    .main-content {
        flex-direction: column !important;
        height: auto !important;
    }

    .monitor-section, .analytics-side {
        width: 100% !important;
        flex: none !important;
        height: auto !important;
    }

    /* Ajustes para o Scanner no Celular */
    .controls {
        width: 100% !important;
        padding: 15px;
    }

    select, .controls button { 
        height: 55px !important; 
        font-size: 1.1rem !important; 
    }

    #reader {
        width: 100% !important;
        max-width: 100% !important;
        margin: 10px 0 !important;
    }

    #reader video {
        object-fit: cover !important;
    }

    h1, h2 {
        font-size: 1.3rem;
    }
}
