/* =========================================================
   ESTRUTURA ADMINISTRATIVA — ESTOQUE ESCOLAR
   Carregar após Bootstrap e public/css/style.css.
   ========================================================= */

.app-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    width: 100%;
    min-height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 25px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    background: var(--surface, #fff);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .035);
}

.header-left,
.header-right,
.header-brand,
.header-user {
    display: flex;
    align-items: center;
}

.header-left { gap: 15px; min-width: 0; }
.header-right { gap: 17px; }

.header-brand {
    gap: 10px;
    color: var(--text, #1e293b);
    text-decoration: none;
}

.header-brand:hover { color: var(--text, #1e293b); }

.header-brand-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 17px;
}

.header-brand-text { display: grid; gap: 2px; line-height: 1.15; }
.header-brand-text strong { font-size: 13px; font-weight: 700; letter-spacing: -.02em; }
.header-brand-text small { color: var(--text-muted, #94a3b8); font-size: 10px; }

.sidebar-toggle {
    width: 34px;
    height: 34px;
    display: none;
    place-items: center;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 7px;
    background: #fff;
    color: #475569;
    cursor: pointer;
}

.sidebar-toggle:hover { background: #f8fafc; color: #1e293b; }

.header-user { gap: 10px; min-width: 0; }

.user-avatar {
    width: 37px;
    height: 37px;
    flex: 0 0 37px;
    display: grid;
    place-items: center;
    border: 1px solid #cfe0fb;
    border-radius: 50%;
    background: linear-gradient(145deg, #eff6ff, #dbeafe);
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
}

.user-meta { min-width: 0; display: grid; gap: 3px; }
.user-name {
    max-width: 230px;
    overflow: hidden;
    color: #334155;
    font-size: 11px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-role { color: #94a3b8; font-size: 10px; }

.header-divider { width: 1px; height: 29px; background: var(--border, #e2e8f0); }
.logout-form { margin: 0; }

.logout-button {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 11px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    color: #64748b;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.logout-button:hover { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }

/* Área de trabalho */
.app-wrapper {
    min-height: calc(100vh - 66px);
    display: flex;
    align-items: stretch;
    background: var(--app-bg, #f5f7fb);
}

.app-sidebar {
    position: sticky;
    top: 66px;
    width: 238px;
    height: calc(100vh - 66px);
    flex: 0 0 238px;
    display: flex;
    flex-direction: column;
    padding: 24px 14px 16px;
    border-right: 1px solid var(--border, #e2e8f0);
    background: #fff;
    overflow-y: auto;
}

.sidebar-section-label {
    margin: 0 10px 12px;
    color: #a0aaba;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .12em;
}

.sidebar-nav { display: grid; gap: 4px; }

.sidebar-link {
    position: relative;
    min-height: 39px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 11px;
    border-radius: 7px;
    color: #64748b;
    font-size: 11px;
    font-weight: 550;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.sidebar-link > i {
    width: 17px;
    flex: 0 0 17px;
    color: #94a3b8;
    text-align: center;
    font-size: 13px;
}

.sidebar-link:hover { background: #f8fafc; color: #334155; }
.sidebar-link:hover > i { color: #64748b; }

.sidebar-link.active {
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 650;
}
.sidebar-link.active > i { color: #2563eb; }

.sidebar-active-indicator {
    width: 3px;
    height: 19px;
    position: absolute;
    top: 50%;
    right: 0;
    border-radius: 3px 0 0 3px;
    background: #2563eb;
    transform: translateY(-50%);
}

.sidebar-bottom {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding: 14px 9px 2px;
    border-top: 1px solid #f1f5f9;
}
.sidebar-help-icon {
    width: 31px;
    height: 31px;
    flex: 0 0 31px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 13px;
}
.sidebar-bottom div:last-child { display: grid; gap: 3px; }
.sidebar-bottom strong { color: #475569; font-size: 10px; font-weight: 650; }
.sidebar-bottom span { color: #94a3b8; font-size: 9px; }

.app-content-wrapper {
    min-width: 0;
    min-height: calc(100vh - 66px);
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.app-main {
    width: 100%;
    min-width: 0;
    flex: 1 0 auto;
    padding: 26px 28px;
}

.app-footer {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 10px 28px;
    border-top: 1px solid var(--border, #e2e8f0);
    background: #fff;
    color: #94a3b8;
    font-size: 10px;
}
.app-footer strong { color: #64748b; font-weight: 650; }
.footer-separator { padding: 0 4px; color: #cbd5e1; }
.footer-right { white-space: nowrap; }

.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .sidebar-toggle { display: grid; }
    .app-sidebar {
        position: fixed;
        z-index: 1045;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(280px, 84vw);
        height: 100dvh;
        padding-top: 25px;
        box-shadow: 12px 0 35px rgba(15, 23, 42, .12);
        transform: translateX(-105%);
        transition: transform .22s ease;
    }
    .app-sidebar.is-open { transform: translateX(0); }
    .sidebar-backdrop {
        position: fixed;
        z-index: 1040;
        inset: 0;
        display: block;
        background: rgba(15, 23, 42, .34);
        opacity: 0;
        visibility: hidden;
        transition: opacity .2s ease, visibility .2s ease;
    }
    .sidebar-backdrop.is-visible { opacity: 1; visibility: visible; }
    body.sidebar-open { overflow: hidden; }
    .app-main { padding: 22px; }
}

@media (max-width: 575.98px) {
    .app-header { min-height: 60px; padding: 0 13px; gap: 8px; }
    .header-left { gap: 9px; }
    .header-right { gap: 9px; }
    .header-brand-icon { width: 32px; height: 32px; font-size: 15px; }
    .header-brand-text strong { font-size: 11px; }
    .header-brand-text small { font-size: 9px; }
    .user-avatar { width: 33px; height: 33px; flex-basis: 33px; font-size: 11px; }
    .user-meta { display: none; }
    .header-divider { height: 25px; }
    .logout-button { width: 33px; min-height: 33px; justify-content: center; padding: 0; }
    .logout-button span { display: none; }
    .app-wrapper, .app-content-wrapper { min-height: calc(100vh - 60px); }
    .app-main { padding: 16px 13px; }
    .app-footer { align-items: flex-start; flex-direction: column; gap: 4px; padding: 11px 14px; }
    .footer-right { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar, .sidebar-backdrop, .sidebar-link, .logout-button { transition: none !important; }
}
