/* ============================================================
   FEMAF - SISTEMA DE VESTIBULAR ONLINE
   Folha de Estilos Principal
   ============================================================ */

/* --- VARIÁVEIS CSS --- */
:root {
    /* Cores Base */
    --bg-main: #f0fdf4;       
    --surface: #ffffff;       
    --border: #bbf7d0;        
    
    /* Texto */
    --text-primary: #14532d;  
    --text-secondary: #4b5563;
    --text-placeholder: #9ca3af;

    /* Marca */
    --brand: #16a34a;         
    --brand-dark: #15803d;    
    --brand-light: #dcfce7;   
    
    /* Estados */
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;

    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    /* Outros */
    --radius: 12px;
}

/* --- RESET & BASE --- */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- BACKGROUND --- */
.background-mesh {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    z-index: -1;
    background: radial-gradient(circle at 50% -20%, #dcfce7 0%, var(--bg-main) 60%);
}

/* --- UTILITÁRIOS --- */
.hidden-section, 
.hidden { 
    display: none !important; 
}

/* ============================================================
   TELA DE CADASTRO (INTRO)
   ============================================================ */
.intro-screen {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    overflow-y: auto; 
    display: flex; 
    justify-content: center; 
    align-items: flex-start; 
    padding: 40px 20px;
    background: rgba(255, 255, 255, 0.7); 
    backdrop-filter: blur(8px);
    transition: opacity 0.4s ease;
    z-index: 100;
}

.intro-fade-out { 
    opacity: 0; 
    pointer-events: none; 
}

.intro-card {
    margin: auto 0;
    background: var(--surface); 
    width: 100%; 
    max-width: 480px;
    border-radius: 20px; 
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    overflow: hidden; 
    animation: floatUp 0.5s ease-out;
}

/* Header da Marca */
.brand-header {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    padding: 24px; 
    text-align: center; 
    color: white;
}

.brand-logo { 
    font-size: 42px; 
    margin-bottom: 8px; 
}

.brand-title { 
    font-weight: 400; 
    font-size: 1.25rem; 
    letter-spacing: -0.5px; 
}

/* Conteúdo */
.intro-content { 
    padding: 32px 24px; 
}

.intro-text h1 { 
    font-size: 1.1rem; 
    color: var(--text-primary); 
    margin-bottom: 8px; 
    text-align: center; 
    font-weight: 700; 
}

.intro-text p { 
    color: var(--text-secondary); 
    text-align: center; 
    font-size: 0.9rem; 
    margin-bottom: 24px; 
    line-height: 1.5; 
}

/* Badges */
.info-badges { 
    display: flex; 
    justify-content: center; 
    gap: 8px; 
    margin-bottom: 24px; 
    flex-wrap: wrap; 
}

.badge { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    padding: 6px 12px; 
    border-radius: 20px; 
    font-size: 0.75rem; 
    font-weight: 600; 
}

.badge.warning { 
    background: #fffbeb; 
    color: #b45309; 
    border: 1px solid #fcd34d; 
}

.badge.info { 
    background: #eff6ff; 
    color: #1d4ed8; 
    border: 1px solid #bfdbfe; 
}

/* ============================================================
   FORMULÁRIO
   ============================================================ */
.login-grid { 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
    margin-bottom: 24px; 
}

.input-group label { 
    display: block; 
    font-size: 0.85rem; 
    font-weight: 600; 
    color: var(--text-primary); 
    margin-bottom: 6px; 
}

.input-box { 
    position: relative; 
}

.input-box i { 
    position: absolute; 
    left: 14px; 
    top: 50%; 
    transform: translateY(-50%); 
    color: var(--brand); 
    font-size: 1.1rem; 
    pointer-events: none; 
}

.input-box input, 
.input-box select {
    width: 100%; 
    padding: 12px 14px 12px 42px; 
    border: 1px solid var(--border); 
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem; 
    background: #f8fafc;
    color: var(--text-primary);
    transition: all 0.2s;
    outline: none;
}

.input-box select { 
    appearance: none; 
    -webkit-appearance: none; 
    -moz-appearance: none; 
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2316a34a' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.input-box select:focus, 
.input-box input:focus { 
    border-color: var(--brand); 
    background: white; 
    box-shadow: 0 0 0 3px var(--brand-light); 
}

/* Validação HTML5 */
.input-box input:invalid {
    border-color: var(--danger);
}

.input-box input:valid {
    border-color: var(--success);
}

/* Dica de input */
.input-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-style: italic;
}

/* Campos Condicionais */
.conditional-fields {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
    animation: slideDown 0.3s ease;
}

.conditional-fields h3 {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toasts de Feedback */
.error-toast { 
    background: #fef2f2; 
    color: var(--danger); 
    padding: 12px; 
    border-radius: 8px; 
    font-size: 0.85rem; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    border: 1px solid #fecaca; 
    animation: shake 0.4s ease; 
}

.success-toast {
    background: #ecfdf5; 
    color: var(--success); 
    padding: 12px; 
    border-radius: 8px;
    font-size: 0.85rem; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px;
    border: 1px solid #a7f3d0; 
    animation: slideDown 0.4s ease;
}

/* ============================================================
   BOTÕES
   ============================================================ */
.btn-primary {
    width: 100%; 
    background: var(--brand); 
    color: white; 
    border: none; 
    padding: 14px; 
    border-radius: 12px;
    font-weight: 600; 
    font-size: 1rem; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px;
    transition: all 0.2s; 
    box-shadow: 0 4px 6px rgba(22, 163, 74, 0.2);
}

.btn-primary:hover { 
    background: var(--brand-dark); 
    transform: translateY(-1px); 
    box-shadow: 0 6px 10px rgba(22, 163, 74, 0.3);
}

.btn-primary:active { 
    transform: translateY(0); 
}

.btn-primary:disabled { 
    background: var(--text-placeholder); 
    cursor: not-allowed; 
    transform: none; 
    box-shadow: none; 
}

.btn-secondary {
    flex: 1;
    background: #f1f5f9;
    color: var(--text-primary);
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger { 
    background: var(--danger); 
    color: white; 
    border: none; 
    padding: 12px 24px; 
    width: 100%; 
    border-radius: 10px; 
    font-weight: 600; 
    cursor: pointer; 
    transition: background 0.2s; 
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-danger:hover { 
    background: #dc2626; 
}

/* ============================================================
   INTERFACE DA PROVA
   ============================================================ */
.exam-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: var(--surface); 
    padding: 12px 24px; 
    border-bottom: 1px solid var(--border);
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    position: sticky; 
    top: 0; 
    z-index: 50; 
    box-shadow: var(--shadow-sm);
}

.logo-mini { 
    font-weight: 800; 
    font-size: 1.2rem; 
    color: var(--brand); 
    letter-spacing: -1px; 
}

.timer-badge {
    background: var(--bg-main); 
    padding: 8px 16px; 
    border-radius: 8px; 
    border: 1px solid var(--border);
    font-variant-numeric: tabular-nums; 
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700; 
    color: var(--brand); 
    display: flex; 
    align-items: center; 
    gap: 8px;
}

.exam-workspace { 
    max-width: 1100px; 
    margin: 24px auto; 
    padding: 0 20px; 
    animation: fadeIn 0.6s ease;
    flex: 1;
}

.workspace-grid { 
    display: grid; 
    grid-template-columns: 300px 1fr; 
    gap: 24px; 
    align-items: start; 
}

/* Painéis Laterais */
.panel-card {
    background: var(--surface); 
    border: 1px solid var(--border); 
    border-radius: 16px; 
    padding: 20px;
    margin-bottom: 16px; 
    box-shadow: var(--shadow-sm);
}

.user-card { 
    border-left: 4px solid var(--brand); 
}

.theme-card { 
    border-left: 4px solid var(--warning); 
}

.info-card { 
    border-left: 4px solid var(--text-secondary); 
    background: #f8fafc; 
}

.card-label { 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    font-weight: 700; 
    color: var(--text-secondary); 
    margin-bottom: 12px; 
    display: flex; 
    align-items: center; 
    gap: 6px; 
}

#themeDisplay { 
    font-size: 1.1rem; 
    line-height: 1.3; 
    color: var(--text-primary); 
    margin-bottom: 8px; 
}

#themeSupportText { 
    font-size: 0.9rem; 
    color: var(--text-secondary); 
    font-style: italic; 
}

.user-data-list { 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
}

.data-item { 
    display: flex; 
    flex-direction: column; 
}

.data-label { 
    font-size: 0.7rem; 
    font-weight: 600; 
    color: var(--text-secondary); 
    text-transform: uppercase; 
}

.clean-input { 
    width: 100%; 
    border: none; 
    background: transparent; 
    padding: 4px 0; 
    font-size: 0.95rem; 
    font-weight: 600; 
    color: var(--text-primary); 
    outline: none; 
}

.info-card ul { 
    padding-left: 18px; 
    font-size: 0.85rem; 
    color: var(--text-secondary); 
    line-height: 1.5; 
}

.info-card li { 
    margin-bottom: 6px; 
}

/* ============================================================
   EDITOR DE REDAÇÃO
   ============================================================ */
.editor-panel { 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
}

.editor-wrapper {
    background: var(--surface); 
    border: 1px solid var(--border); 
    border-radius: 16px;
    overflow: hidden; 
    box-shadow: var(--shadow-md); 
    display: flex; 
    flex-direction: column;
    min-height: 60vh;
}

.editor-header {
    background: #f8fafc; 
    border-bottom: 1px solid var(--border); 
    padding: 10px 20px;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}

.tab-active { 
    font-size: 0.85rem; 
    font-weight: 600; 
    color: var(--text-primary); 
    background: white; 
    padding: 6px 12px; 
    border-radius: 6px; 
    border: 1px solid var(--border); 
}

.char-counter { 
    font-size: 0.8rem; 
    font-family: 'JetBrains Mono', monospace; 
    color: var(--text-secondary); 
}

textarea {
    flex: 1; 
    width: 100%; 
    padding: 24px; 
    border: none; 
    outline: none; 
    resize: none;
    font-family: 'JetBrains Mono', monospace; 
    font-size: 16px; 
    line-height: 1.8; 
    color: var(--text-primary);
    background-image: linear-gradient(transparent 31px, #f1f5f9 31px); 
    background-size: 100% 32px; 
    background-attachment: local;
    background-color: var(--surface);
}

.editor-footer { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-wrap: wrap; 
    gap: 10px;
    padding: 16px 20px;
}

.security-badge { 
    font-size: 0.8rem; 
    color: var(--success); 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    font-weight: 600; 
    background: #ecfdf5; 
    padding: 6px 12px; 
    border-radius: 20px; 
}

/* ============================================================
   MODAIS
   ============================================================ */
.modal-overlay {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(15, 23, 42, 0.8); 
    backdrop-filter: blur(4px);
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 200;
    padding: 20px; 
    animation: fadeIn 0.3s ease;
}

.modal-card {
    background: white; 
    width: 100%; 
    max-width: 440px; 
    padding: 32px; 
    border-radius: 20px;
    text-align: center; 
    box-shadow: var(--shadow-lg); 
    animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.icon-circle { 
    width: 64px; 
    height: 64px; 
    border-radius: 50%; 
    margin: 0 auto 20px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 32px; 
}

.success .icon-circle { 
    background: #dcfce7; 
    color: var(--success); 
}

.error .icon-circle { 
    background: #fee2e2; 
    color: var(--danger); 
}

.warning .icon-circle { 
    background: #fef3c7; 
    color: var(--warning); 
}

.modal-card h2 { 
    font-size: 1.4rem; 
    margin-bottom: 8px; 
    color: var(--text-primary); 
}

.modal-card p { 
    font-size: 0.95rem; 
    color: var(--text-secondary); 
    margin-bottom: 16px; 
    line-height: 1.5; 
}

.modal-rules {
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    margin: 20px 0;
    text-align: left;
}

.modal-rules h3 {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-rules ul {
    list-style: none;
    padding: 0;
}

.modal-rules li {
    padding: 8px 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.modal-rules li i {
    color: var(--danger);
    font-size: 1rem;
    margin-top: 2px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.receipt-box, 
.error-details { 
    background: #f8fafc; 
    padding: 16px; 
    border-radius: 12px; 
    margin-bottom: 24px; 
    font-size: 0.9rem; 
    border: 1px solid var(--border); 
}

.receipt-box .row { 
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 6px; 
}

/* ============================================================
   ANIMAÇÕES
   ============================================================ */
@keyframes floatUp { 
    from { 
        transform: translateY(40px); 
        opacity: 0; 
    } 
    to { 
        transform: translateY(0); 
        opacity: 1; 
    } 
}

@keyframes scaleUp { 
    from { 
        transform: scale(0.9); 
        opacity: 0; 
    } 
    to { 
        transform: scale(1); 
        opacity: 1; 
    } 
}

@keyframes fadeIn { 
    from { 
        opacity: 0; 
    } 
    to { 
        opacity: 1; 
    } 
}

@keyframes shake { 
    0%, 100% { 
        transform: translateX(0); 
    } 
    25% { 
        transform: translateX(-5px); 
    } 
    75% { 
        transform: translateX(5px); 
    } 
}

@keyframes slideDown { 
    from { 
        opacity: 0; 
        transform: translateY(-10px); 
    } 
    to { 
        opacity: 1; 
        transform: translateY(0); 
    } 
}

/* ============================================================
   RESPONSIVIDADE
   ============================================================ */
@media (max-width: 800px) {
    .workspace-grid { 
        grid-template-columns: 1fr; 
        gap: 16px; 
    }
    
    .theme-panel { 
        order: -1; 
    }
    
    .app-header { 
        padding: 10px 16px; 
    }
    
    .intro-card { 
        max-width: 100%; 
    }
    
    .editor-wrapper { 
        min-height: 50vh; 
    }
    
    .panel-card { 
        padding: 16px; 
    }
    
    .modal-buttons { 
        flex-direction: column; 
    }

    .editor-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .security-badge {
        justify-content: center;
    }
}