/* =========================================
   1. VARIAVEIS E RESET (Modern Design)
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Paleta de Cores Moderna */
    --primary: #4f46e5;       /* Indigo */
    --primary-dark: #4338ca;
    --secondary: #64748b;     /* Slate */
    --success: #10b981;       /* Emerald */
    --danger: #ef4444;        /* Red */
    --warning: #f59e0b;       /* Amber */
    --bg-body: #f1f5f9;       /* Cinza muito claro */
    --bg-card: #ffffff;
    --text-main: #0f172a;     /* Quase preto */
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    /* Sidebar */
    --sidebar-bg: #1e293b;    /* Slate Dark */
    --sidebar-text: #f8fafc;
    
    /* Tamanhos */
    --header-height-mobile: 60px;
    --sidebar-width: 250px;
    --sidebar-collapsed: 70px;
}

* { 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; /* Impede rolagem lateral da página inteira */
}

/* =========================================
   2. SIDEBAR (Navegação)
   ========================================= */
.sidebar {
    position: fixed; top: 0; left: 0; height: 100%; width: var(--sidebar-width);
    background: var(--sidebar-bg); z-index: 100;
    transition: all 0.3s ease;
    display: flex; flex-direction: column;
}

.sidebar.close { width: var(--sidebar-collapsed); }

/* Logo */
.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; }

/* Menu Links */
.nav-list { flex: 1; padding-top: 20px; list-style: none; }
.nav-list li { position: relative; margin: 5px 10px; }
.nav-list li a {
    display: flex; align-items: center; text-decoration: none;
    color: #94a3b8; 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: 30px; }
.sidebar.close .link_name { opacity: 0; pointer-events: none; }

/* Perfil no Rodapé */
.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; font-weight: 600; }
.profile-role { color: #64748b; font-size: 0.75rem; }
.sidebar.close .profile-info { display: none; }
#log_out { color: var(--danger); cursor: pointer; font-size: 1.2rem; }

/* =========================================
   3. ÁREA DE CONTEÚDO (MAIN)
   ========================================= */
.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));
}

/* Header Mobile (Só aparece no celular) */
.mobile-header {
    display: none; /* Escondido no Desktop */
    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: 99;
}

/* =========================================
   4. UI COMPONENTS (Cards, Forms, Buttons)
   ========================================= */
h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-main); margin-bottom: 20px; }

/* Cards Modernos */
.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);
}

/* Inputs */
.form-group { margin-bottom: 15px; }
label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-main); margin-bottom: 5px; }
input, select {
    width: 100%; padding: 10px 15px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.95rem; transition: 0.2s;
    background: #f8fafc;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }

/* Botões */
.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; font-size: 0.95rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }

/* Botões de Ação (Tabela) */
.action-btn {
    width: 32px; height: 32px; border-radius: 6px; border: none;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; color: #fff; transition: 0.2s; text-decoration: none;
}
.btn-edit { background: var(--warning); }
.btn-delete { background: var(--danger); }
.btn-edit:hover, .btn-delete:hover { filter: brightness(0.9); transform: translateY(-1px); }

/* =========================================
   5. TABELAS RESPONSIVAS (Correção Mobile)
   ========================================= */
.table-responsive {
    width: 100%;
    overflow-x: auto; /* Permite rolar APENAS a tabela */
    border-radius: 8px;
    border: 1px solid var(--border);
}

table {
    width: 100%; border-collapse: collapse; min-width: 600px; /* Força largura mínima */
}
thead th {
    background: #f1f5f9; color: var(--text-muted); font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.5px; padding: 12px 15px; text-align: left;
    font-weight: 600; border-bottom: 1px solid var(--border);
}
tbody td {
    padding: 12px 15px; border-bottom: 1px solid var(--border);
    color: var(--text-main); font-size: 0.9rem; vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }

/* Badge de Turma */
.badge {
    padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600;
    background: #e0e7ff; color: var(--primary);
}

/* =========================================
   6. MODAL & TOAST (Correção do Bug Visual)
   ========================================= */
/* Fundo Escuro */
.modal-backdrop {
    display: none; /* Hidden by default */
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 9999;
    backdrop-filter: blur(2px);
    justify-content: center; align-items: center;
}
.modal-backdrop.active { display: flex; }

/* Caixa Branca */
.modal-content {
    background: #fff; padding: 30px; border-radius: 12px;
    width: 90%; max-width: 400px; text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    animation: modalPop 0.3s ease;
}
@keyframes modalPop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: #fff; padding: 15px 20px; border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    border-left: 5px solid; min-width: 280px;
    display: flex; align-items: center; gap: 12px;
    animation: slideIn 0.4s ease;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* =========================================
   7. RESPONSIVIDADE (MOBILE)
   ========================================= */
@media (max-width: 768px) {
    /* Header aparece */
    .mobile-header { display: flex; }
    
    /* Sidebar some completamente */
    .sidebar { left: -100%; width: 250px; box-shadow: 5px 0 15px rgba(0,0,0,0.1); }
    .sidebar.open { left: 0; }
    .sidebar.close { width: 250px; } /* Reset no mobile */
    
    /* Conteúdo ajusta para ocupar tela toda */
    .main-content {
        left: 0; width: 100%; padding: 15px;
        margin-top: var(--header-height-mobile); /* Empurra conteúdo para baixo do header */
    }
    
    /* Ajustes Form e Tabela */
    .row { flex-direction: column; gap: 0; }
    .col { width: 100% !important; margin-bottom: 15px; }
    
    /* Abas */
    .tab-nav { flex-direction: column; }
    .tab-btn { width: 100%; text-align: left; border-radius: 6px; margin-bottom: 5px; }
}

/* Helpers Layout */
.row { display: flex; gap: 20px; }
.col { flex: 1; }
.flex-end { display: flex; justify-content: flex-end; gap: 10px; }