/* ==========================================================================
   EJAN - camada visual sobre o AdminLTE 4 / Bootstrap 5.3
   Cores da marca: amarelo do logotipo + grafite.
   ========================================================================== */

:root {
    --brand: #ffcc00;
    --brand-strong: #f2b600;
    --brand-ink: #2b2d31;
    --brand-subtle: #fff6cc;
    --radius: .75rem;
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-border-radius: .5rem;
    --bs-border-radius-lg: .75rem;
}

[data-bs-theme="dark"] {
    --brand-subtle: rgba(255, 204, 0, .14);
    --bs-body-bg: #16181c;
    --bs-tertiary-bg: #1c1f24;
    --bs-secondary-bg: #23262c;
}

body { -webkit-font-smoothing: antialiased; }

/* ---------- Utilitários da marca ---------- */
.text-brand { color: var(--brand-strong) !important; }
.bg-brand { background-color: var(--brand) !important; }
.bg-brand-subtle { background-color: var(--brand-subtle) !important; color: #8a6a00; }
[data-bs-theme="dark"] .bg-brand-subtle { color: var(--brand); }

.btn-brand {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-color: var(--brand-ink);
    --bs-btn-hover-bg: var(--brand-strong);
    --bs-btn-hover-border-color: var(--brand-strong);
    --bs-btn-hover-color: var(--brand-ink);
    --bs-btn-active-bg: #e0a800;
    --bs-btn-active-border-color: #e0a800;
    --bs-btn-active-color: var(--brand-ink);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-disabled-color: var(--brand-ink);
    font-weight: 600;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-strong);
    box-shadow: 0 0 0 .2rem rgba(255, 204, 0, .3);
}
.form-check-input:checked { background-color: var(--brand-strong); border-color: var(--brand-strong); }
a { text-decoration: none; }

/* ---------- Cartões ---------- */
.card {
    border: 1px solid var(--bs-border-color-translucent);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.card > .card-header {
    background: transparent;
    border-bottom-color: var(--bs-border-color-translucent);
    padding: .9rem 1.25rem;
}
.card > .list-group:last-child { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }

/* ---------- Indicadores do painel ---------- */
.stat-card {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 1rem;
    align-items: center;
    padding: 1.1rem 1.25rem;
    border-radius: var(--radius);
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color-translucent);
    color: inherit;
    height: 100%;
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16, 24, 40, .08); color: inherit; }
.stat-icon {
    grid-row: span 2;
    width: 3rem; height: 3rem;
    border-radius: .75rem;
    display: grid; place-items: center;
    font-size: 1.35rem;
}
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .85rem; color: var(--bs-secondary-color); }

/* ---------- Avatares de iniciais ---------- */
.avatar-initials {
    width: 2.1rem; height: 2.1rem;
    border-radius: 50%;
    display: inline-grid; place-items: center;
    background: var(--brand);
    color: var(--brand-ink);
    font-weight: 700; font-size: .8rem;
    flex-shrink: 0;
}
.avatar-sm { width: 2rem; height: 2rem; font-size: .75rem; }
.min-w-0 { min-width: 0; }

/* ---------- Estado vazio ---------- */
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .6; }
.empty-state p { margin: 0; }

/* ---------- Barra lateral ---------- */
.app-sidebar { background: #1f2227 !important; }
.app-sidebar .sidebar-brand { border-bottom-color: rgba(255, 255, 255, .06); }
.app-sidebar .brand-image { background: #fff; border-radius: .4rem; padding: 2px; max-height: 32px; }
.app-sidebar .nav-header { font-size: .7rem; letter-spacing: .08em; opacity: .5; padding-top: 1rem; }
.sidebar-menu .nav-link { border-radius: .5rem; margin: 1px .5rem; width: auto; }
.sidebar-menu .nav-link.active,
.sidebar-menu .nav-link.active:hover {
    background: var(--brand) !important;
    color: var(--brand-ink) !important;
    font-weight: 600;
}
.sidebar-menu .nav-link.active .nav-icon { color: var(--brand-ink) !important; }

/* ---------- Cabeçalho ---------- */
.app-header .nav-link { color: var(--bs-body-color); }
[data-bs-theme="light"] .theme-icon-dark,
[data-bs-theme="dark"] .theme-icon-light { display: none; }
.app-content-header { padding-top: 1.25rem; padding-bottom: 1rem; }

/* ---------- Tabelas ---------- */
.table > :not(caption) > * > * { padding: .75rem 1rem; }
.table thead th {
    font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--bs-secondary-color); font-weight: 600;
    background: var(--bs-tertiary-bg);
}
.table-hover tbody tr { cursor: default; }

/* ---------- Telas de acesso ---------- */
.auth-page { background: var(--bs-tertiary-bg); min-height: 100vh; }
.auth-wrapper { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 992px) { .auth-wrapper { grid-template-columns: 1.1fr 1fr; } }
.auth-brand {
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .25), transparent 40%),
        linear-gradient(135deg, #ffd84d 0%, #ffcc00 45%, #f2a900 100%);
    color: var(--brand-ink);
    padding: 3rem 3.5rem;
    flex-direction: column;
    justify-content: space-between;
}
.auth-brand h1 { font-weight: 800; font-size: 2.2rem; max-width: 22ch; }
.auth-logo { max-width: 240px; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .15)); }
.auth-form { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 2rem 1.25rem; }
.auth-card {
    width: 100%; max-width: 420px;
    background: var(--bs-body-bg);
    padding: 2.25rem;
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .08);
    border: 1px solid var(--bs-border-color-translucent);
}
.auth-switch a { margin: 0 .6rem; color: var(--bs-secondary-color); }
.auth-switch a:hover { color: var(--bs-body-color); }
.portal-badge { font-weight: 600; }

.password-toggle {
    position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
    color: var(--bs-secondary-color); z-index: 5;
}
.password-meter { height: 4px; border-radius: 2px; background: var(--bs-secondary-bg); overflow: hidden; }
.password-meter > div { height: 100%; width: 0; transition: width .2s, background-color .2s; }

/* ---------- Página inicial ---------- */
.home-wrapper { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.home-logo { max-width: 220px; }
.portal-tile {
    display: flex; flex-direction: column; align-items: center; gap: .35rem;
    padding: 1.75rem 1rem; height: 100%;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color-translucent);
    border-radius: 1rem; color: inherit; text-align: center;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.portal-tile:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(16, 24, 40, .1); border-color: var(--brand); color: inherit; }
.portal-tile i { font-size: 2rem; color: var(--brand-strong); }
.portal-tile span { font-weight: 700; }
.portal-tile small { color: var(--bs-secondary-color); }

/* ---------- Botão carregando ---------- */
.btn.is-loading { position: relative; pointer-events: none; }
.btn.is-loading .btn-label { visibility: hidden; }
.btn.is-loading::after {
    content: ""; position: absolute; inset: 0; margin: auto;
    width: 1.1rem; height: 1.1rem; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Impressão ---------- */
@media print {
    .app-header, .app-sidebar, .app-footer, .no-print, .toast-container { display: none !important; }
    .app-main { margin: 0 !important; }
    body { background: #fff !important; }
}

/* O AdminLTE adiciona um ::after (clearfix) no cabeçalho do cartão, que atrapalha o flex */
.card-header.d-flex::after { display: none; }
.card-header .card-title { float: none; }
@media (max-width: 991.98px) {
    body:not(.sidebar-open) .app-sidebar { box-shadow: none !important; }
}

/* ---------- Formulários ---------- */
.form-label { font-weight: 500; font-size: .9rem; margin-bottom: .3rem; }
.sticky-actions {
    position: sticky; bottom: 0; z-index: 10;
    display: flex; justify-content: flex-end; gap: .5rem;
    padding: .75rem 1rem; margin: 0 -.25rem;
    background: color-mix(in srgb, var(--bs-tertiary-bg) 85%, transparent);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--bs-border-color-translucent);
    border-radius: var(--radius) var(--radius) 0 0;
}
.inline-edit input:focus { background: var(--bs-body-bg) !important; border: 1px solid var(--brand-strong) !important; }
.card-header form[role="search"] { margin: -.15rem 0; }
.step-badge {
    display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; margin-right: .5rem;
    border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: .75rem; font-weight: 700;
}

/* ---------- Notas ---------- */
.grade-table .grade-input { min-width: 3.6rem; padding: .25rem .3rem; }
.grade-table .abs-input { min-width: 3rem; background: var(--bs-tertiary-bg); }
.grade-table .grade-input.below { color: var(--bs-danger); font-weight: 600; }
.grade-table td, .grade-table th { padding: .35rem .4rem !important; }
.grade-table tbody tr:hover { background: var(--brand-subtle); }
.list-group-item.active-brand { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* ---------- Relatórios ---------- */
.report-editor { font-size: 1.05rem; line-height: 1.75; padding: 1.25rem 1.5rem; resize: vertical; min-height: 380px; font-family: Georgia, "Times New Roman", serif; }
.report-editor:focus { box-shadow: none !important; }
.report-editor[readonly] { background: var(--bs-tertiary-bg); }
.report-preview { max-height: 260px; overflow: auto; white-space: normal; }
.period-tabs .nav-link { color: var(--bs-body-color); border-radius: 2rem; padding: .35rem .9rem; }
.period-tabs .nav-link.active { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
a.class-card:hover { border-color: var(--brand); box-shadow: 0 6px 18px rgba(16, 24, 40, .08); }
.report-read { font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; line-height: 1.75; }
.report-read p { margin-bottom: .9rem; }
.release-row td { background: var(--bs-tertiary-bg) !important; }
.grade-table .grade-input[readonly] { background: var(--bs-secondary-bg); color: var(--bs-secondary-color); border-style: dashed; cursor: not-allowed; }

/* ---------- Mensagens ---------- */
.chat { display: flex; flex-direction: column; gap: .6rem; }
.chat-bubble { max-width: 85%; padding: .7rem .95rem; border-radius: 1rem; line-height: 1.45; }
.chat-bubble.from-family { align-self: flex-start; background: var(--bs-secondary-bg); border-bottom-left-radius: .3rem; }
.chat-bubble.from-school { align-self: flex-end; background: var(--brand-subtle); border-bottom-right-radius: .3rem; }
.chat-bubble.is-new { box-shadow: 0 0 0 2px var(--brand); }
.chat-time { font-size: .75rem; color: var(--bs-secondary-color); margin-top: .3rem; }
.sidebar-menu .nav-badge { position: absolute; right: .75rem; }
