/* =========================================
   1. VARIAVEIS E RESET
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    --sidebar-width: 250px;
    --sidebar-collapsed: 78px;
    --header-height-mobile: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* =========================================
   2. SIDEBAR
   ========================================= */
.sidebar {
    position: fixed; top: 0; left: 0; height: 100%; width: var(--sidebar-width);
    background: #1e293b; z-index: 1000;
    transition: all 0.3s ease;
    display: flex; flex-direction: column;
}

.sidebar.close { width: var(--sidebar-collapsed); }

.logo-box {
    height: 60px; display: flex; align-items: center; justify-content: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.logo-text { font-size: 1.2rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; }
.sidebar.close .logo-text { display: none; }
.logo-icon { font-size: 1.5rem; color: var(--primary); margin-right: 10px; }
.sidebar.close .logo-icon { margin-right: 0; }

.nav-list { flex: 1; padding-top: 20px; list-style: none; }
.nav-list li { margin: 5px 10px; }
.nav-list li a {
    display: flex; align-items: center; text-decoration: none;
    color: #cbd5e1; padding: 12px 15px; border-radius: 8px;
    transition: 0.2s; white-space: nowrap;
}
.nav-list li a:hover, .nav-list li a.active { background: rgba(255,255,255,0.1); color: #fff; }
.nav-list li a i { font-size: 1.3rem; min-width: 35px; }
.sidebar.close .link_name { opacity: 0; pointer-events: none; }

.profile-content {
    padding: 15px; border-top: 1px solid rgba(255,255,255,0.1);
    background: #0f172a; display: flex; align-items: center; justify-content: space-between;
}
.profile-info { display: flex; flex-direction: column; white-space: nowrap; overflow: hidden; }
.profile-name { color: #fff; font-size: 0.9rem; }
.sidebar.close .profile-info { display: none; }
#log_out { color: var(--danger); cursor: pointer; font-size: 1.2rem; }

/* =========================================
   3. MAIN CONTENT
   ========================================= */
.main-content {
    position: relative;
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    padding: 30px;
    transition: all 0.3s ease;
}
.sidebar.close ~ .main-content {
    left: var(--sidebar-collapsed);
    width: calc(100% - var(--sidebar-collapsed));
}

/* Mobile Header (Default: Hidden) */
.mobile-header {
    display: none;
    background: #fff; height: var(--header-height-mobile);
    padding: 0 20px; align-items: center; justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    position: fixed; top: 0; left: 0; width: 100%; z-index: 950;
}

/* =========================================
   4. UI COMPONENTS
   ========================================= */
.card {
    background: var(--bg-card); border-radius: 12px; padding: 25px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 20px;
    border: 1px solid var(--border);
}

h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 20px; color: var(--text-main); }

/* Form Grid */
.row { display: flex; gap: 20px; flex-wrap: wrap; }
.col { flex: 1; min-width: 200px; }

.form-group { margin-bottom: 15px; }
label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 5px; }
input, select {
    width: 100%; padding: 10px 15px; border: 1px solid var(--border);
    border-radius: 8px; background: #fff; font-size: 0.95rem;
}

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; border-radius: 8px; border: none; font-weight: 500;
    cursor: pointer; transition: 0.2s; text-decoration: none; gap: 8px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-delete { background: var(--danger); color: #fff; }

.flex-end { display: flex; justify-content: flex-end; gap: 10px; }

/* --- 4.1. BOTÕES DE AÇÃO (TABELA) - CORREÇÃO AQUI --- */
.action-btn {
    width: 34px; height: 34px; 
    border-radius: 6px; 
    border: none;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; 
    color: #fff !important; 
    transition: all 0.2s; 
    text-decoration: none;
    font-size: 1.1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn-edit { background: var(--warning); }
.action-btn.btn-delete { background: var(--danger); } /* Especificidade maior */

.action-btn:hover { 
    filter: brightness(0.9); 
    transform: translateY(-2px); 
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

/* Responsive Table */
.table-responsive { width: 100%; overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th { background: #f1f5f9; padding: 12px 15px; text-align: left; font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); }
td { padding: 12px 15px; border-bottom: 1px solid var(--border); color: var(--text-main); }
.badge { padding: 4px 8px; border-radius: 4px; background: #e0e7ff; color: var(--primary); font-size: 0.75rem; font-weight: 600; }

/* Sub-tabs (Class Filter) */
.sub-tab-container {
    display: flex; gap: 10px; padding: 15px 0; margin-bottom: 15px;
    border-bottom: 1px solid #f1f5f9; overflow-x: auto;
}
.sub-tab-btn {
    padding: 6px 16px; border-radius: 20px; border: 1px solid var(--border);
    background: #fff; color: var(--text-muted); font-size: 0.85rem;
    font-weight: 600; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.sub-tab-btn:hover { border-color: var(--primary); color: var(--primary); }
.sub-tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3); }

/* =========================================
   5. RESPONSIVENESS (MOBILE LAYOUT FIX)
   ========================================= */
@media (max-width: 768px) {
    /* Show Mobile Header */
    .mobile-header { display: flex; }

    /* Hide Sidebar completely off-screen */
    .sidebar { left: -100%; width: 250px; box-shadow: none; }
    .sidebar.open { left: 0; box-shadow: 5px 0 15px rgba(0,0,0,0.2); }
    .sidebar.close { width: 250px; left: -100%; } 
    
    /* Content Centralized and Full Width */
    .main-content {
        left: 0 !important; 
        width: 100% !important; 
        margin-top: var(--header-height-mobile); 
        padding: 15px; 
    }
    .sidebar.close ~ .main-content { left: 0; width: 100%; }

    /* Layout Adjustments */
    .row { flex-direction: column; gap: 10px; }
    .col { width: 100% !important; margin-bottom: 15px; }
    
    h1 { font-size: 1.3rem; text-align: center; }
}

/* =========================================
   6. MODAL & TOAST
   ========================================= */
.modal-backdrop {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 2000;
    justify-content: center; align-items: center; backdrop-filter: blur(2px);
}
.modal-backdrop.active { display: flex; }
.modal-content {
    background: #fff; padding: 30px; border-radius: 12px;
    width: 90%; max-width: 400px; text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: #fff; padding: 15px; border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-left: 5px solid; display: flex; align-items: center; gap: 10px; min-width: 280px;
    animation: slideIn 0.3s ease;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* =========================================
   7. TELA DE LOGIN (NOVO)
   ========================================= */
.login-body {
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: #fff;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    text-align: center;
}

.logo-icon-lg {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.login-header h2 {
    font-size: 1.5rem;
    color: var(--text-main);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.input-icon {
    position: relative;
}
.input-icon i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.2rem;
}
.input-icon input {
    padding-left: 45px; /* Espaço para o ícone */
}

.btn-block {
    width: 100%;
    height: 45px;
    font-size: 1rem;
    margin-top: 10px;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #fee2e2;
}

.login-footer {
    margin-top: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =========================================
   SELETOR DE STATUS (P / F / A)
   ========================================= */
.status-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Esconde o rádio padrão feio */
.status-selector input[type="radio"] {
    display: none;
}

/* Estilo das Bolinhas */
.status-lbl {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.8rem;
    color: #ccc;
    border: 2px solid #e2e8f0;
    transition: all 0.2s;
    background: #fff;
}

/* Cores quando selecionado */
input[value="P"]:checked + .status-lbl {
    background-color: var(--success);
    color: white;
    border-color: var(--success);
    box-shadow: 0 0 5px var(--success);
}

input[value="F"]:checked + .status-lbl {
    background-color: var(--danger);
    color: white;
    border-color: var(--danger);
    box-shadow: 0 0 5px var(--danger);
}

input[value="A"]:checked + .status-lbl {
    background-color: #3498db; /* Azul */
    color: white;
    border-color: #3498db;
    box-shadow: 0 0 5px #3498db;
}

/* Cores da linha da tabela baseada no status (classes adicionadas via JS) */
tr.row-presente { background-color: #f0fdf4 !important; }
tr.row-falta { background-color: #fef2f2 !important; }
tr.row-atestado { background-color: #eff6ff !important; }

/* --- ESTILO DOS BOTÕES DE FREQUÊNCIA --- */

/* Esconde a bolinha original feia do input */
.radio-status {
    display: none; 
}

/* Container dos botões */
.status-selector {
    display: flex;
    gap: 6px; /* Espaço entre as bolinhas */
    justify-content: center;
    align-items: center;
}

/* O visual da bolinha (Label) */
.status-lbl {
    width: 32px;
    height: 32px;
    border-radius: 50%;       /* Deixa redondo */
    background: #f1f5f9;      /* Fundo cinza claro */
    border: 2px solid #cbd5e1; /* Borda cinza */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;          /* Mãozinha ao passar mouse */
    font-weight: 700;
    font-size: 0.75rem;       /* Fonte menor para caber 'LM' */
    color: #64748b;
    transition: all 0.2s;
    user-select: none;
}

/* Hover (efeito ao passar o mouse) */
.status-selector label:hover .status-lbl {
    border-color: #94a3b8;
    transform: scale(1.05);
}

/* --- CORES QUANDO SELECIONADO (CHECKED) --- */

/* P - Presença (Verde) */
input[value="P"]:checked + .status-lbl {
    background: #22c55e; border-color: #22c55e; color: #fff;
}

/* F - Falta (Vermelho) */
input[value="F"]:checked + .status-lbl {
    background: #ef4444; border-color: #ef4444; color: #fff;
}

/* A - Atestado (Azul) */
input[value="A"]:checked + .status-lbl {
    background: #3b82f6; border-color: #3b82f6; color: #fff;
}

/* LM - Licença Maternidade (Rosa) - ESTE FALTAVA */
input[value="LM"]:checked + .status-lbl {
    background: #d63384; border-color: #d63384; color: #fff;
}