/* ═══════════════════════════════════════════════════════════════
   CMS INSTITUCIONAL — panel.css
   Estratégia: mobile-first. Base = celular, breakpoints ampliam.
   Breakpoints:
     sm:  576px  (celular paisagem)
     md:  768px  (tablet)
     lg:  992px  (desktop)
═══════════════════════════════════════════════════════════════ */

:root {
    --sidebar-w:      260px;
    --sidebar-bg:     #1A2B4A;
    --sidebar-text:   #B0C4DE;
    --sidebar-hover:  rgba(255,255,255,0.07);
    --sidebar-active: rgba(74,122,200,0.22);
    --accent:         #4A7AC8;
    --topbar-h:       56px;
    --radius:         10px;
    --shadow-sm:      0 1px 4px rgba(0,0,0,0.07);
    --shadow-md:      0 4px 16px rgba(0,0,0,0.10);
    --bg:             #F4F6FA;
    --border:         #E0E4EE;
}

*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    -webkit-tap-highlight-color: transparent;
}

/* ── Layout ────────────────────────────────────────────────────── */
.cms-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────────── */
.cms-sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 300;
    position: fixed;
    top: 0; left: 0;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
}

.sidebar-logo {
    width: 100%;
    max-width: 160px;
    height: auto;
    object-fit: contain;
}

.cms-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
}

@media (min-width: 992px) {
    .cms-sidebar {
        position: sticky;
        transform: none !important;
        flex-shrink: 0;
        box-shadow: none;
    }
}

/* Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 299;
    backdrop-filter: blur(2px);
}
.sidebar-backdrop.show { display: block; }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0px 40px;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

/* Nav items */
.sidebar-nav { list-style: none; margin: 6px 0; padding: 0; flex: 1; }

.sidebar-nav .nav-section {
    padding: 14px 18px 3px;
    font-size: .67rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: rgba(176,196,222,0.45);
    pointer-events: none;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 18px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    border-radius: 6px;
    margin: 1px 8px;
    transition: background .15s, color .15s;
    min-height: 44px;
}

.sidebar-nav li a:hover  { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav li a.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
    border-left: 3px solid var(--accent);
    padding-left: 15px;
}

/* Footer sidebar */
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; }

.user-info { display: flex; align-items: center; gap: 10px; color: var(--sidebar-text); min-width: 0; }
.user-info .user-name { font-size: .85rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Topbar mobile ─────────────────────────────────────────────── */
.cms-topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: var(--shadow-sm);
}

.btn-hamburger {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent; cursor: pointer;
    border-radius: 8px; color: #1A2B4A; flex-shrink: 0;
    transition: background .15s;
}
.btn-hamburger:hover { background: #F0F4FB; }

@media (min-width: 992px) { .cms-topbar { display: none !important; } }

/* ── Main ──────────────────────────────────────────────────────── */
.cms-main { flex: 1; min-height: 100vh; min-width: 0; display: flex; flex-direction: column; }

.cms-content { flex: 1; padding: 16px; }
@media (min-width: 576px) { .cms-content { padding: 20px; } }
@media (min-width: 992px) { .cms-content { padding: 28px 32px; } }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast-fixed { position: fixed; top: 16px; left: 16px; right: 16px; z-index: 9999; }
@media (min-width: 576px) { .toast-fixed { left: auto; right: 20px; min-width: 300px; max-width: 420px; } }

/* ── Dashboard cards ───────────────────────────────────────────── */
.card-module { cursor: pointer; border-radius: var(--radius); transition: transform .15s, box-shadow .15s; }
@media (hover: hover) {
    .card-module:hover { transform: translateY(-3px); box-shadow: var(--shadow-md) !important; }
}
.module-icon { width: 48px; height: 48px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ── Tabelas responsivas ───────────────────────────────────────── */
/* Mobile: cards empilhados */
.table-cms { width: 100%; border-collapse: collapse; }
.table-cms thead { display: none; }

.table-cms tbody tr {
    display: block;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
}

.table-cms tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 0;
    font-size: .9rem;
    border: none;
    text-align: right;
}

.table-cms tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: .75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: .05em;
    flex-shrink: 0;
    min-width: 90px;
    text-align: left;
}

.table-cms tbody td.td-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.table-cms tbody td.td-actions::before { display: none; }

/* Tablet+: tabela normal */
@media (min-width: 768px) {
    .table-cms thead { display: table-header-group; }
    .table-cms thead th {
        background: #1A2B4A;
        color: #fff;
        font-weight: 600;
        font-size: .85rem;
        padding: 12px 16px;
        border: none;
        text-align: left;
    }
    .table-cms tbody tr {
        display: table-row;
        background: #fff;
        border-radius: 0;
        box-shadow: none;
        margin-bottom: 0;
        padding: 0;
        border: none;
        border-bottom: 1px solid #F0F0F0;
        transition: background .12s;
    }
    .table-cms tbody tr:hover { background: #F5F8FF; }
    .table-cms tbody td { display: table-cell; padding: 12px 16px; vertical-align: middle; text-align: left; }
    .table-cms tbody td::before { display: none; }
    .table-cms tbody td.td-actions { border-top: none; margin-top: 0; padding-top: 12px; justify-content: flex-end; }
}

/* ── Formulários ───────────────────────────────────────────────── */
.form-control, .form-select { min-height: 44px; font-size: 1rem !important; }
textarea.form-control { min-height: unset; }
.btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.btn-sm { min-height: 34px; }

/* ── Grade curricular ──────────────────────────────────────────── */
.curriculum-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 576px) { .curriculum-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .curriculum-grid { grid-template-columns: repeat(3, 1fr); } }

/* ── Page header ───────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
@media (min-width: 768px) { .page-header { margin-bottom: 28px; } }

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: #aaa; }
.empty-state i { font-size: 3rem; opacity: .25; margin-bottom: 12px; }

/* ── Login ─────────────────────────────────────────────────────── */
.login-body { background: linear-gradient(135deg, #1A2B4A 0%, #2B4A8A 100%); min-height: 100vh; }
.login-wrapper { padding: 24px 16px; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 420px; border-radius: 16px; overflow: hidden; }
.login-header { background: linear-gradient(135deg, #1A2B4A, #2B4A8A); color: #fff; padding: 32px 24px 24px; text-align: center; }
.login-logo {
    width: 100%;
    max-width: 220px;
    height: auto;
    object-fit: contain;
}

/* ── Utilitários ───────────────────────────────────────────────── */
.cms-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; }
.cms-card-header { padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .9rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.cms-card-body { padding: 20px; }

.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { -webkit-overflow-scrolling: touch; }
