* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; }
.auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-box { background: white; padding: 40px; border-radius: 16px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); max-width: 400px; width: 100%; }
.auth-tabs { display: flex; margin-bottom: 24px; border-bottom: 2px solid #e0e0e0; }
.auth-tab { flex: 1; padding: 12px; text-align: center; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.auth-tab.active { border-bottom-color: #008080; color: #008080; font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form input { padding: 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 15px; }
.auth-form button { padding: 14px; background: #008080; color: white; border: none; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.auth-form button:hover { background: #006666; }
.main-screen { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: white; box-shadow: 2px 0 10px rgba(0,0,0,0.05); padding: 20px 0; display: flex; flex-direction: column; }
.sidebar-header { padding: 0 20px 20px; border-bottom: 1px solid #eee; }
.sidebar-header h1 { font-size: 20px; color: #008080; }
.sidebar-header p { font-size: 13px; color: #666; margin-top: 4px; }
.menu-item { padding: 14px 20px; cursor: pointer; transition: all 0.2s; border-left: 3px solid transparent; display: flex; align-items: center; gap: 10px; font-size: 14px; color: #333; }
.menu-item:hover { background: #f5f5f5; }
.menu-item.active { background: #e0f7fa; border-left-color: #008080; color: #008080; font-weight: 600; }
.sidebar-footer { margin-top: auto; padding: 20px; border-top: 1px solid #eee; }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar { width: 36px; height: 36px; background: #008080; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.user-email { font-size: 13px; color: #666; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout { width: 100%; padding: 10px; background: #f5f5f5; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; transition: background 0.2s; }
.btn-logout:hover { background: #e0e0e0; }
.content { flex: 1; padding: 30px; overflow-y: auto; }
.view { display: none; }
.view.active { display: block; }
.view h2 { font-size: 24px; color: #333; margin-bottom: 20px; }
.card { background: white; padding: 24px; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); margin-bottom: 20px; }
.card h3 { font-size: 18px; color: #333; margin-bottom: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 14px; color: #555; font-weight: 500; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; font-family: inherit; }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.btn { padding: 12px 24px; border: none; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: #008080; color: white; }
.btn-primary:hover { background: #006666; }
.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #5a6268; }
.btn-success { background: #28a745; color: white; }
.btn-success:hover { background: #218838; }
.btn-warn { background: #ffc107; color: #333; }
.btn-warn:hover { background: #e0a800; }
.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { background: #c82333; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.prova-item { background: white; padding: 16px; border-radius: 8px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); display: flex; justify-content: space-between; align-items: center; }
.prova-item-info { flex: 1; }
.prova-item-info strong { font-size: 15px; color: #333; }
.prova-item-meta { font-size: 12px; color: #888; margin-top: 4px; }
.questao-card { background: #f9f9f9; padding: 16px; border-radius: 8px; margin-bottom: 12px; border-left: 4px solid #008080; }
.questao-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.questao-num { width: 28px; height: 28px; background: #008080; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.remove-btn { background: #dc3545; color: white; border: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.toast { position: fixed; bottom: 20px; right: 20px; padding: 14px 20px; border-radius: 8px; color: white; font-size: 14px; z-index: 10000; animation: slideIn 0.3s ease; }
.toast.success { background: #28a745; }
.toast.error { background: #dc3545; }
.toast.info { background: #008080; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal.active { display: flex; }
.modal-content { background: white; border-radius: 12px; max-width: 600px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 18px; color: #333; }
.modal-body { padding: 20px; }
.hidden { display: none !important; }
.loading { text-align: center; padding: 40px; color: #888; }
.banner-edit { background: #fff3cd; padding: 12px; border-radius: 6px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.banner-edit p { color: #856404; font-size: 14px; }
.img-status { font-size: 12px; color: #666; margin-top: 6px; }
.fab-ia { position: fixed; bottom: 30px; right: 30px; width: 56px; height: 56px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.2); z-index: 999; transition: transform 0.2s; }
.fab-ia:hover { transform: scale(1.1); }
.fab-ia span { font-size: 24px; }
.ia-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.ia-tab { padding: 10px 16px; background: #f5f5f5; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; transition: all 0.2s; }
.ia-tab.active { background: #667eea; color: white; }
.ia-preview-card { background: #f8f9fa; padding: 16px; border-radius: 8px; margin-bottom: 12px; border-left: 4px solid #667eea; }
.habilidade-item { display: block; padding: 8px; margin-bottom: 4px; background: #f9f9f9; border-radius: 4px; cursor: pointer; transition: background 0.2s; }
.habilidade-item:hover { background: #e9e9e9; }
.habilidade-item input { margin-right: 8px; }
.cartao { background: white; padding: 16px; border-radius: 8px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.cartao img { width: 100%; max-width: 150px; margin-bottom: 8px; }
.cartao-nome { font-size: 14px; font-weight: 600; color: #333; }
.cartao-turma { font-size: 12px; color: #666; margin-top: 4px; }
/* ======================================================================== */
/* 🖨️ CORREÇÃO DEFINITIVA: KATEX NA IMPRESSÃO (EVITAR SOBREPOSIÇÃO)         */
/* ======================================================================== */

@media print {
    /* 🚨 FORÇA O KATEX A USAR LAYOUT ESTÁTICO (SEM POSITION ABSOLUTE) */
    .katex, 
    .katex *,
    .katex-display {
        position: relative !important;
        display: inline-block !important;
        page-break-inside: avoid !important;
        transform: none !important;
    }
    
    /* Evita quebras de página no meio de fórmulas */
    .katex-display {
        margin: 12px 0 !important;
        page-break-before: auto !important;
        page-break-after: auto !important;
        display: block !important;
    }
    
    /* Garante que cada questão/parágrafo não seja cortado */
    .plano-aula-container p,
    .plano-aula-container li,
    .plano-aula-container h3,
    .plano-aula-container h4,
    .plano-aula-container .katex-display,
    .plano-aula-container .secao-titulo {
        page-break-inside: avoid !important;
        orphans: 3 !important;
        widows: 3 !important;
    }
    
    /* Aumenta espaçamento entre linhas para não sobrepor */
    .plano-aula-container {
        line-height: 1.8 !important;
        font-size: 12pt !important;
    }
    
    /* Remove sombras e efeitos visuais que confundem a impressão */
    .plano-aula-container * {
        box-shadow: none !important;
        text-shadow: none !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Margens seguras para impressão A4 */
    @page {
        margin: 2cm !important;
        size: A4 !important;
    }
    
    /* 🚨 CORREÇÃO CRÍTICA: Evita que o conteúdo "vaze" entre páginas */
    body {
        overflow: visible !important;
    }
    
    .plano-aula-container {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
    }
}
/* ======================================================================== */
/* ️ PLANO B: FORÇAR LAYOUT SIMPLES NA IMPRESSÃO (SEM KATEX COMPLEXO)      */
/* ======================================================================== */

@media print {
    /* Remove TODAS as classes do KaTeX e substitui por texto simples */
    .katex {
        display: inline !important;
        font-family: 'Times New Roman', Times, serif !important;
        font-size: 14pt !important;
    }
    
    .katex .frac {
        display: inline-block !important;
        vertical-align: middle !important;
    }
    
    .katex .numerator {
        display: block !important;
        text-align: center !important;
        border-bottom: 1px solid black !important;
    }
    
    .katex .denominator {
        display: block !important;
        text-align: center !important;
    }
    
    /* Garante que cada página comece limpa */
    .plano-aula-container > * {
        page-break-after: auto !important;
        page-break-before: auto !important;
    }
    
    /* Força quebra de página limpa */
    .plano-aula-container {
        display: block !important;
        width: 100% !important;
    }
}