/* =========================================================
   SISTEMA ESCOLAR - DESIGN V116 (RESPONSIVO MOBILE)
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
    /* --- VARIÁVEIS DO TEMA --- */
    --sidebar-bg: #2c3e50;
    --sidebar-text: #ffffff;
    --body-bg: #f0f2f5;
    --text-main: #333333;
    --card-bg: #ffffff;
    --card-text: #333333;
    
    /* Cores de Estado */
    --accent: #3498db;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --shadow: 0 2px 10px rgba(0,0,0,0.05);
    --radius: 10px;
}

* { box-sizing: border-box; outline: none; }

/* LAYOUT TELA */
body { 
    font-family: 'Poppins', sans-serif; margin: 0; padding: 0; 
    background-color: var(--body-bg); color: var(--text-main); 
    height: 100vh; width: 100vw; display: auto; overflow: hidden; 
}

/* MENU LATERAL */
.sidebar { 
    width: 260px; min-width: 260px; 
    background-color: var(--sidebar-bg); color: var(--sidebar-text); 
    display: flex; flex-direction: column; height: 100vh; overflow-y: auto; 
    z-index: 1000; box-shadow: 4px 0 15px rgba(0,0,0,0.05); 
    transition: transform 0.3s ease; /* Animação para mobile */
}
.logo-area { padding: 30px 20px; text-align: center; background: rgba(0,0,0,0.2); border-bottom: 1px solid rgba(255,255,255,0.05); flex-shrink: 0; }
.logo-area h2 { font-size: 18px; margin: 10px 0 5px; font-weight: 600; color: var(--sidebar-text); }
.logo-area small { opacity: 0.7; font-size: 12px; color: var(--sidebar-text); }

.menu-scroll { flex: 1; overflow-y: auto; }
.menu-lista { list-style: none; padding: 0; margin: 0; }
.menu-lista button { 
    width: 100%; padding: 16px 25px; text-align: left; 
    background: transparent; border: none; 
    color: var(--sidebar-text); opacity: 0.8;
    font-family: inherit; font-size: 14px; cursor: pointer; 
    border-left: 4px solid transparent; transition: all 0.2s; 
}
.menu-lista button:hover { background: rgba(255,255,255,0.1); opacity: 1; border-left-color: var(--accent); }

.submenu { list-style: none; padding: 0; background: rgba(0,0,0,0.2); }
.submenu button { padding-left: 45px; font-size: 13px; opacity: 0.7; }
.submenu button:hover { opacity: 1; padding-left: 50px; }

.btn-sair { padding: 15px; background: var(--danger); color: white; border: none; font-weight: 600; cursor: pointer; flex-shrink: 0; }

/* ÁREA PRINCIPAL */
.content { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; position: relative; width: 100%; }
header { 
    height: 80px; flex-shrink: 0; 
    background: var(--card-bg); color: var(--card-text);
    padding: 0 40px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow); z-index: 10; 
}
header h2 { margin: 0; font-size: 22px; font-weight: 600; color: var(--accent); }

/* Botão Mobile (Invisível no Desktop) */
.mobile-menu-btn { display: none; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--card-text); margin-right: 15px; }
.mobile-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 900; }

#app-content { flex: 1; padding: 40px; overflow-y: auto; height: 100%; scroll-behavior: smooth; }

/* UI ELEMENTS */
.card { 
    background: var(--card-bg); color: var(--card-text);
    padding: 30px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 25px; border: 1px solid #eee; 
}
.card h3 { margin-top: 0; color: var(--card-text); margin-bottom: 20px; font-size: 18px; border-bottom: 1px solid #eee; padding-bottom: 10px; }

.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { 
    background: var(--card-bg); color: var(--card-text);
    padding: 25px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); display: flex; align-items: center; justify-content: space-between; transition: transform 0.2s; border-left: 5px solid var(--accent); 
}
.stat-card:hover { transform: translateY(-3px); }
.stat-info h4 { margin: 0; font-size: 14px; opacity: 0.7; font-weight: 500; text-transform: uppercase; }
.stat-info p { margin: 5px 0 0; font-size: 24px; font-weight: 700; }
.stat-icon { font-size: 32px; opacity: 0.2; }
.card-blue { border-left-color: #3498db; } .card-green { border-left-color: #27ae60; } .card-orange { border-left-color: #f39c12; } .card-red { border-left-color: #e74c3c; }

.finance-bar-container { background: #eee; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 10px; }
.finance-bar-fill { height: 100%; background: linear-gradient(90deg, #2ecc71, #27ae60); width: 0%; transition: width 1s; }

/* ATALHOS */
.shortcuts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 15px; }
.shortcut-btn { 
    background: var(--card-bg); border: 1px solid #eee; padding: 20px; border-radius: 10px; text-align: center; cursor: pointer; transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.03); 
}
.shortcut-btn:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(52, 152, 219, 0.15); }
.shortcut-btn div { font-size: 24px; margin-bottom: 8px; }
.shortcut-btn span { font-weight: 600; font-size: 13px; color: var(--card-text); }

/* TABELAS E BOTÕES */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; } /* Wrapper para scroll */
table { width: 100%; border-collapse: collapse; margin-top: 15px; min-width: 600px; /* Força largura mínima para scroll */ }
th { text-align: left; padding: 15px; background: rgba(0,0,0,0.02); color: var(--card-text); opacity: 0.7; font-size: 12px; font-weight: 600; text-transform: uppercase; border-bottom: 2px solid #eee; }
td { padding: 15px; border-bottom: 1px solid #eee; color: var(--card-text); font-size: 14px; }
tr:hover td { background: rgba(0,0,0,0.01); }

.btn-edit, .btn-del, .btn-new-modern, .btn-primary, .btn-confirm, .btn-cancel { cursor: pointer; }
.btn-edit { background: var(--warning); color: white; border: none; padding: 6px 10px; border-radius: 4px; margin-right: 5px; }
.btn-del { background: var(--danger); color: white; border: none; padding: 6px 10px; border-radius: 4px; }
.btn-new-modern { background: var(--success); color: white; border: none; padding: 0 25px; height: 52px; border-radius: 8px; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; transition: 0.2s; white-space: nowrap; }
.btn-primary { width: 100%; padding: 12px; background: var(--accent); color: white; border: none; border-radius: 6px; font-weight: 600; margin-top: 10px; }
.btn-confirm { background: var(--success); color: white; padding: 10px 20px; border: none; border-radius: 6px; font-weight: 600; margin-left: 10px; }
.btn-cancel { background: #95a5a6; color: white; padding: 10px 20px; border: none; border-radius: 6px; }

/* MODAL */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); display: flex; justify-content: center; align-items: center; z-index: 3000; }
.modal-box { background: white; border-radius: 8px; width: 650px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 15px 40px rgba(0,0,0,0.2); }
.modal-header { padding: 20px 30px; border-bottom: 1px solid #eee; background: #f8f9fa; border-radius: 8px 8px 0 0; }
.modal-header h2 { margin: 0; font-size: 20px; color: var(--primary); }
.modal-body { padding: 30px; overflow-y: auto; flex: 1; color: #333; }
.modal-footer { padding: 20px 30px; border-top: 1px solid #eee; text-align: right; background: #f8f9fa; border-radius: 0 0 8px 8px; }

/* LOGIN */
.login-wrapper { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, var(--sidebar-bg) 0%, #000 100%); display: flex; justify-content: center; align-items: center; z-index: 2000; }
.login-box { background: white; padding: 40px; border-radius: var(--radius); width: 380px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.2); color: #333; }

/* INPUTS */
.input-group { text-align: left; margin-bottom: 15px; }
.input-group label { display: block; font-size: 13px; font-weight: 500; color: inherit; margin-bottom: 5px; opacity: 0.8; }
.input-group input, select, textarea, .search-input-modern { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; font-family: inherit; font-size: 14px; background: white; color: #333; }

/* CONFIG APARENCIA */
.theme-section { margin-bottom: 30px; padding: 20px; border: 1px solid #eee; border-radius: 10px; background: rgba(0,0,0,0.02); }
.theme-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.theme-row input[type="color"] { width: 50px; height: 35px; border: none; cursor: pointer; padding: 0; background: none; }
.shortcut-selector { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; }
.shortcut-item { display: flex; align-items: center; gap: 8px; padding: 10px; background: white; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; cursor: pointer; }

/* ---------------------------------------------------------
   MEDIA QUERIES (RESPONSIVIDADE MÓVEL)
   --------------------------------------------------------- */
@media (max-width: 768px) {
    /* Esconde sidebar por padrão */
    .sidebar { position: fixed; left: -260px; height: 100%; }
    .sidebar.active { left: 0; } /* Classe para abrir */
    
    /* Botão Menu Aparece */
    .mobile-menu-btn { display: block; }
    
    /* Header e Conteúdo */
    header { padding: 0 20px; justify-content: flex-start; }
    header h2 { font-size: 18px; margin-left: 10px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
    #app-content { padding: 20px; }
    
    /* Overlay Escuro */
    .mobile-overlay.active { display: block; }

    /* Ajustes de Grid para 1 Coluna */
    .dashboard-grid, .shortcuts-grid { grid-template-columns: 1fr; }
    
    /* Tabelas com Scroll Horizontal */
    .card { padding: 20px; width: 100%; overflow: hidden; }
    #fin-lista-area, .card table, #app-content table { display: block; overflow-x: auto; white-space: nowrap; }
    
    /* Formulários Empilhados */
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-wrapper { width: 100% !important; margin-bottom: 10px; }
    .btn-new-modern { width: 100%; justify-content: center; }
    
    /* Quebra Grids inline (style="display:grid") para block */
    div[style*="display:grid"] { display: flex !important; flex-direction: column; }
    div[style*="grid-template-columns"] { display: flex !important; flex-direction: column; }
    
    /* Modal Fullscreen */
    .modal-box { width: 95%; max-height: 95vh; }
    
    /* Login */
    .login-box { width: 90%; }
}

/* ---------------------------------------------------------
   ESTILOS DE IMPRESSÃO (V112 MANTIDA)
   --------------------------------------------------------- */
@media print {
    @page { size: A4; margin: 0; }
    html, body { width: 210mm; height: 100%; margin: 0 !important; padding: 0 !important; background: white !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color: black !important; }
    .sidebar, header, .no-print, .modal-overlay, button, .toolbar, .card:not(.print-mode), .mobile-menu-btn { display: none !important; }
    .content, #app-content { margin: 0 !important; padding: 0 !important; overflow: visible !important; height: auto !important; display: block !important; background: white !important; }
    .print-sheet { position: absolute; top: 0; left: 0; width: 100% !important; margin: 0 !important; padding: 5mm !important; box-shadow: none !important; border: none !important; }
    .doc-table { width: 100%; }
    .doc-table th { background-color: #eee !important; color: #000 !important; }
    /* Demais estilos de impressão mantidos... */
    .carne-row { height: 68mm !important; border: 2px solid #000 !important; margin-bottom: 3mm !important; }
    .carne-instructions, .doc-section, .dossie-section-title, .progress-bg { background-color: #eee !important; color: #000 !important; }
    .badge-recibo { background-color: #000 !important; color: #fff !important; }
    .progress-fill { -webkit-print-color-adjust: exact !important; }
}

/* Visual Docs Tela */
.print-sheet { background: white; width: 210mm; min-height: 297mm; padding: 10mm; margin: 20px auto; box-shadow: 0 0 15px rgba(0,0,0,0.1); font-family: 'Roboto', 'Arial', sans-serif; color: black; box-sizing: border-box; border: 1px solid #eee; }
.carne-row { display: flex; width: 100%; height: 260px; border: 1px solid #000; margin-bottom: 10px; color: black; }
.carne-canhoto { width: 30%; border-right: 1px dashed #000; padding: 5px; font-size: 9px; display: flex; flex-direction: column; justify-content: space-between; }
.carne-recibo { width: 70%; padding: 5px 8px; display: flex; flex-direction: column; position: relative; }
.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 15px; }
.doc-table td, .doc-table th { border: 1px solid #000; padding: 6px; font-size: 12px; color: #000; }
.doc-table th { background-color: #eee; font-weight: bold; }
.doc-section { background: #eee; border: 1px solid #000; padding: 5px; font-weight: bold; font-size: 13px; margin-top: 15px; text-transform: uppercase; }
.plan-input-print { border: none; width: 100%; font-family: inherit; font-size: 12px; background: transparent; }
.dossie-section-title { background: #f4f6f7; border-left: 5px solid #2c3e50; padding: 10px; font-weight: bold; color: #2c3e50; text-transform: uppercase; margin: 25px 0 15px 0; font-size: 14px; }
.kpi-container { display: flex; gap: 15px; margin-bottom: 30px; }
.kpi-card { flex: 1; border: 1px solid #ddd; border-radius: 5px; padding: 15px; text-align: center; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.kpi-label { font-size: 10px; color: #888; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.kpi-value { font-size: 22px; font-weight: bold; }
.split-row { display: flex; gap: 30px; }
.split-col { flex: 1; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table td { padding: 8px 0; border-bottom: 1px solid #eee; }
.mini-table th { text-align: left; padding-bottom: 5px; font-size: 10px; color: #888; text-transform: uppercase; border-bottom: 2px solid #eee; }
.progress-label { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 3px; margin-top: 10px; }
.progress-bg { background: #eee; height: 8px; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; }
.carne-logo-img { height: 25px; object-fit: contain; }
.carne-header-box { text-align: center; border-bottom: 1px solid #ccc; padding-bottom: 2px; margin-bottom: 2px; }
.carne-inst-name { font-size: 10px; font-weight: bold; text-transform: uppercase; }
.carne-inst-cnpj { font-size: 8px; }
.carne-label { font-size: 7px; color: #555; text-transform: uppercase; display: block; line-height: 1; margin-bottom: 1px; }
.carne-value { font-size: 10px; font-weight: bold; color: #000; display: block; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.carne-grid { display: flex; border-bottom: 1px solid #ccc; margin-bottom: 3px; }
.carne-col { flex: 1; border-right: 1px solid #ccc; padding: 2px 4px; }
.carne-col:last-child { border-right: none; }
.carne-instructions { background: #f9f9f9; border: 1px solid #ddd; padding: 4px; font-size: 9px; height: 40px; margin-bottom: 2px; line-height: 1.2; }
.carne-footer { margin-top: auto; display: flex; justify-content: space-between; align-items: flex-end; }
.carne-payer { width: 65%; font-size: 9px; }
.carne-qr { width: 30%; text-align: center; }
.badge-recibo { background: #000; color: #fff; font-size: 8px; font-weight: bold; padding: 2px 6px; border-radius: 2px; position: absolute; top: 5px; right: 5px; }
.doc-header { border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; }

/* --- NOTIFICAÇÕES TOAST (NOVO) --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 250px;
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease forwards;
    border-left: 5px solid #333;
    font-size: 14px;
    font-weight: 500;
}

.toast.success { border-left-color: #27ae60; color: #27ae60; }
.toast.error { border-left-color: #c0392b; color: #c0392b; }
.toast.info { border-left-color: #3498db; color: #3498db; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
    to { transform: translateX(100%); opacity: 0; }
}

/* --- NOTIFICAÇÕES TOAST (NOVO) --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999; /* Bem acima de tudo, inclusive modais */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 280px;
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease forwards;
    border-left: 5px solid #333;
    font-size: 14px;
    font-weight: 500;
    opacity: 0; /* Começa invisível para animação */
}

/* Cores por tipo */
.toast.success { border-left-color: #27ae60; color: #2c3e50; } /* Verde */
.toast.error { border-left-color: #c0392b; color: #c0392b; }   /* Vermelho */
.toast.info { border-left-color: #3498db; color: #2980b9; }    /* Azul */

/* Ícone dentro do toast */
.toast-icon { font-size: 18px; }

/* Animações */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { transform: translateX(10px); opacity: 0; }
}