/* ===================================================
   TOPO DO SISTEMA (HEADER.PHP)
   =================================================== */

/* Base: tema claro */
.sg-topbar {
    background: #ffffff;
    color: #111827;
    padding: .45rem 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.3s, color 0.3s;
}

.sg-topbar-inner {
    max-width: 1150px;
    margin: 0 auto;
    padding: 0 .75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

/* =========================
   BLOCO: ESQUERDA E DIREITA
   ========================= */
.sg-topbar-left,
.sg-topbar-right {
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* =========================
   LOGO DO SISTEMA
   ========================= */
.sg-logo-link {
    display: flex;
    align-items: center;
    gap: .4rem;
    text-decoration: none;
    color: inherit;
}

.sg-logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: .4rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    transition: background 0.3s, border-color 0.3s;
}

.sg-logo-text {
    font-weight: 600;
    font-size: .9rem;
}

/* =========================
   NAVEGAÇÃO CENTRAL
   ========================= */
.sg-topbar-nav {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.sg-nav-link {
    color: #111827;
    text-decoration: none;
    font-size: .85rem;
    padding: .35rem .75rem;
    border-radius: .5rem;
    border: 1px solid transparent;
    font-weight: 500;
    transition: background 0.2s, border 0.2s, color 0.2s;
}

.sg-nav-link:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
    text-decoration: none;
}

.sg-nav-logout {
    color: #b91c1c;
    border-color: #fca5a5;
}

.sg-nav-logout:hover {
    background: #dc2626;
    border-color: #b91c1c;
    color: #fff;
}

/* =========================
   BOTÕES DE USUÁRIO E TEMA
   ========================= */
.sg-user {
    font-size: .8rem;
    color: #6b7280;
}

.theme-toggle-btn {
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #111827;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s, color 0.2s, border 0.2s;
}

.theme-toggle-btn:hover {
    background: #e5e7eb;
}

/* =========================
   BOTÃO SAIR (TOP DESKTOP)
   ========================= */
.sg-btn-logout {
    display: inline-block;
    background: #dc2626;
    color: #fff;
    padding: .45rem .9rem;
    border-radius: .5rem;
    font-size: .85rem;
    text-decoration: none;
    transition: background 0.2s;
}

.sg-btn-logout:hover {
    background: #b91c1c;
}

/* ===================================================
   TEMA ESCURO (data-theme="dark")
   =================================================== */
[data-theme="dark"] .sg-topbar {
    background: #020617;
    color: #e5e7eb;
    border-bottom: 1px solid #1f2937;
}

[data-theme="dark"] .sg-logo-img {
    background: #111827;
    border-color: #1f2937;
}

[data-theme="dark"] .sg-nav-link {
    color: #e5e7eb;
}

[data-theme="dark"] .sg-nav-link:hover {
    background: #111827;
    border-color: #334155;
}

[data-theme="dark"] .sg-user {
    color: #cbd5f5;
}

[data-theme="dark"] .theme-toggle-btn {
    border-color: #4b5563;
    background: transparent;
    color: #e5e7eb;
}

[data-theme="dark"] .theme-toggle-btn:hover {
    background: #111827;
}

[data-theme="dark"] .sg-btn-logout {
    background: #b91c1c;
}

[data-theme="dark"] .sg-btn-logout:hover {
    background: #dc2626;
}

/* ===================================================
   MENU LATERAL (para telas pequenas)
   =================================================== */
.sg-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background: #1e293b;
    color: #fff;
    padding-top: 70px;
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 999;
    transform: translateX(-100%);
}

.sg-sidebar.active {
    transform: translateX(0);
}

.sg-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sg-sidebar li {
    border-bottom: 1px solid #334155;
}

.sg-sidebar a {
    display: block;
    padding: 0.9rem 1.2rem;
    color: #fff;
    text-decoration: none;
    font-size: 0.95rem;
}

.sg-sidebar a:hover {
    background: #2563eb;
}

.sg-sidebar-footer {
    position: sticky;
    bottom: 0;
    background: #0f172a;
    text-align: center;
    padding: 1rem 0;
    border-top: 1px solid #334155;
}

/* ===================================================
   RESPONSIVO
   =================================================== */
@media (max-width: 850px) {
    /* Mobile: menu vira lateral */
    .sg-topbar-nav {
        display: none;
    }

    .sg-btn-logout.desktop-only {
        display: none;
    }

    .sg-menu-btn {
        display: inline-block;
        font-size: 1.6rem;
        background: none;
        border: none;
        color: inherit;
        cursor: pointer;
    }

    .sg-topbar-inner {
        flex-wrap: wrap;
        justify-content: center;
    }

    .sg-topbar-left {
        width: 100%;
        justify-content: center;
        margin-bottom: .2rem;
    }

    .sg-topbar-right {
        width: 100%;
        justify-content: center;
        margin-top: .2rem;
    }

    body.menu-open {
        overflow: hidden;
    }
}

@media (min-width: 851px) {
    /* Desktop: menu horizontal no topo */
    .sg-sidebar {
        display: none;
    }
}
