﻿/* Extraído de html/layouts/sidebar.html (antes era <style> inline no CORPO, depois da marcação: o navegador pintava a
   tela sem estes estilos por alguns instantes — "distorção" ao navegar). Agora vai no <head>. */

/* ================================================================
   SIDEBAR — Design minimalista profissional
   Referência: Linear, Vercel, Supabase, Notion
   ================================================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 1002;
    transition: width 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* ---- Header (60px = mesma altura da navbar) ---- */
.sidebar-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.875rem 0 1.125rem;
    border-bottom: 1px solid var(--border-color-light);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.brand-logo {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Marca: logotipo completo quando expandido, só o símbolo quando recolhido. A barra lateral é azul-escura nos dois
   temas, então a versão "reverse" (ERP em branco) vale sempre; a versão para fundo claro não é usada aqui. */
.brand-lockup { height: 30px; width: auto; display: block; flex-shrink: 0; }
.brand-mark   { height: 30px; width: auto; display: none;  flex-shrink: 0; }
.brand-lockup--light, .brand-mark--light { display: none; }
.brand-lockup--dark { display: block; }

.brand-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.18s, max-width 0.26s;
    max-width: 200px;
    white-space: nowrap;
}

.brand-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.brand-sub {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    letter-spacing: 0;
}

/* Botão de colapso */
.sidebar-toggle {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: 1px solid var(--border-color-light);
    background: transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 0.625rem;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    margin-left: 0.375rem;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--bg-surface-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.sidebar-toggle i {
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Nav (scrollável) ---- */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.625rem 0.625rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color-light) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-color-light);
    border-radius: 2px;
}

/* ---- Section Labels ---- */
.nav-section {
    padding: 1.25rem 0.375rem 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
}

.nav-section span {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-section::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color-light);
}

/* ---- Nav Item ---- */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 1px;
    position: relative;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 450;
}

.nav-item:hover {
    background: var(--bg-surface-secondary);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-item.active {
    background: color-mix(in srgb, var(--primary-color, #667eea) 9%, transparent);
    color: var(--primary-color, #667eea);
    font-weight: 550;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 18%;
    height: 64%;
    width: 2.5px;
    background: var(--primary-color, #667eea);
    border-radius: 0 2px 2px 0;
}

/* ---- Nav Icon (sem caixa — apenas o ícone) ---- */
.nav-icon {
    font-size: 0.9375rem;
    width: 18px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
    transition: color 0.12s;
    /* sem background, sem border-radius, sem box-shadow */
}

.nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.18s, max-width 0.26s;
    max-width: 200px;
}

/* ---- Arrow ---- */
.nav-arrow {
    font-size: 0.625rem;
    color: var(--text-tertiary);
    flex-shrink: 0;
    margin-left: auto;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.18s;
    opacity: 0.7;
}

.nav-item:hover .nav-arrow { opacity: 1; }

.nav-item.has-sub:not(.collapsed) .nav-arrow,
.nav-item.has-sub[aria-expanded="true"] .nav-arrow {
    transform: rotate(90deg);
}

/* ---- Sub-menu (2º nível) ---- */
.nav-group { margin-bottom: 1px; }

.nav-sub {
    margin: 0.125rem 0 0.25rem 1.0625rem;
    padding: 0.125rem 0;
    border-left: 1px solid var(--border-color-light);
    overflow: hidden;
}

.nav-sub-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0 6px 6px 0;
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 0.8125rem;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
    position: relative;
}

.nav-sub-item:hover {
    background: var(--bg-surface-secondary);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-sub-item.active {
    color: var(--primary-color, #667eea);
    font-weight: 550;
    background: color-mix(in srgb, var(--primary-color, #667eea) 7%, transparent);
}

.sub-dot {
    width: 4px;
    min-width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--border-color);
    flex-shrink: 0;
    transition: background 0.12s, transform 0.12s;
}

.nav-sub-item:hover .sub-dot  { background: var(--text-secondary); }
.nav-sub-item.active .sub-dot { background: var(--primary-color, #667eea); transform: scale(1.4); }

/* ---- Sub-submenu (3º nível) ---- */
.nav-sub-group { margin-bottom: 0; }

.sub-arrow {
    font-size: 0.625rem;
    color: var(--text-tertiary);
    margin-left: auto;
    flex-shrink: 0;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
}

.nav-sub-item.has-sub:not(.collapsed) .sub-arrow,
.nav-sub-item.has-sub[aria-expanded="true"] .sub-arrow {
    transform: rotate(90deg);
}

.nav-nested {
    margin-left: 1rem;
    padding: 0.1rem 0;
    border-left: 1px solid var(--border-color-light);
}

.nav-nested-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    border-radius: 0 5px 5px 0;
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 0.8rem;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}

.nav-nested-item::before {
    content: '';
    width: 3px;
    min-width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--border-color);
    flex-shrink: 0;
    transition: background 0.12s;
}

.nav-nested-item:hover { background: var(--bg-surface-secondary); color: var(--text-primary); text-decoration: none; }
.nav-nested-item:hover::before { background: var(--text-tertiary); }
.nav-nested-item.active { color: var(--primary-color, #667eea); font-weight: 550; background: color-mix(in srgb, var(--primary-color, #667eea) 7%, transparent); }
.nav-nested-item.active::before { background: var(--primary-color, #667eea); }

/* ---- Footer ---- */
.sidebar-footer {
    padding: 0.75rem 0.625rem;
    border-top: 1px solid var(--border-color-light);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border-radius: 8px;
    overflow: hidden;
    transition: background 0.15s;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    cursor: pointer;
}

.user-card:hover { background: var(--bg-surface-secondary); text-decoration: none; }

.user-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.user-avatar-wrap img,
.user-avatar-img {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: block;
    object-fit: cover;
}

.user-avatar-letters {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.user-online {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    border: 1.5px solid var(--sidebar-bg);
}

.user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.18s, max-width 0.26s;
    max-width: 200px;
    white-space: nowrap;
}

.user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-mail {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-logout {
    width: 28px;
    min-width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.user-logout:hover { background: rgba(239,68,68,0.1); color: #ef4444; }

/* ================================================================
   COLLAPSED (mini mode — 60px)
   ================================================================ */

.sidebar.collapsed { width: 60px; }

/* Ocultar textos na transição */
.sidebar.collapsed .brand-info,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-arrow,
.sidebar.collapsed .nav-sub,
.sidebar.collapsed .user-info,
.sidebar.collapsed .user-logout {
    opacity: 0;
    max-width: 0;
    pointer-events: none;
    overflow: hidden;
}

.sidebar.collapsed .nav-section span { opacity: 0; max-width: 0; overflow: hidden; }
.sidebar.collapsed .nav-section::after { display: none; }
.sidebar.collapsed .nav-section {
    padding: 0.875rem 0.375rem 0.25rem;
    justify-content: center;
}

/* Linha fina como divisor de seção no modo collapsed */
.sidebar.collapsed .nav-section::before {
    content: '';
    width: 24px;
    height: 1px;
    background: var(--border-color-light);
    display: block;
}

/* Centralizar */
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 0 0.75rem; }
.sidebar.collapsed .sidebar-brand  { flex: 0 0 auto; gap: 0; margin-right: 4px; }
.sidebar.collapsed .brand-lockup { display: none !important; }
.sidebar.collapsed .brand-mark { height: 18px; }
.sidebar.collapsed .brand-mark--dark { display: block; }
.sidebar.collapsed .sidebar-toggle { margin-left: 0; }
.sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.5rem;
    gap: 0;
}

.sidebar.collapsed .nav-icon {
    width: 20px;
    min-width: 20px;
    font-size: 1rem;
}

.sidebar.collapsed .user-card {
    justify-content: center;
    padding: 0.5rem;
    gap: 0;
    flex: 0;
    min-width: 0;
}

.sidebar.collapsed .sidebar-footer { justify-content: center; }
.sidebar.collapsed .user-logout { display: none; }

/* Dica dos ícones com o menu recolhido (criada por sidebar-modern.js, fica no <body>) */
.sidebar-tip {
    position: fixed;
    z-index: 1060;
    max-width: 260px;
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    font-size: 0.8125rem;
    line-height: 1.25;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}
.sidebar-tip[hidden] { display: none; }
.sidebar-tip.show { opacity: 1; transform: none; }
.sidebar-tip__secao {
    display: block;
    margin-bottom: 1px;
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}
.sidebar-tip__titulo { font-weight: 600; }

/* ================================================================
   CONTENT — ajuste de margem
   ================================================================ */

.content-with-sidebar {
    margin-left: 260px;
    margin-top: 60px;
    transition: margin-left 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-collapsed .content-with-sidebar { margin-left: 60px; }

/* ================================================================
   MOBILE
   ================================================================ */

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px !important;
        z-index: 1050;
    }

    .sidebar.show { transform: translateX(0); }

    .content-with-sidebar {
        margin-left: 0 !important;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 1049;
        backdrop-filter: blur(3px);
    }

    .sidebar-overlay.show { display: block; }
    body.sidebar-open { overflow: hidden; }

    /* Touch targets maiores em mobile */
    .nav-item { min-height: 44px; }
    .nav-sub-item, .nav-nested-item { min-height: 40px; }
    .sidebar-toggle { width: 36px; height: 36px; }
}

@media (min-width: 992px) {
    .sidebar { transform: none !important; }
    .sidebar-overlay { display: none !important; }
}

/* Cartão do usuário no rodapé da barra: no tema claro o cartão herdava fundo claro com texto claro (ilegível).
   A barra é escura nos dois temas, então o cartão é translúcido e o texto claro, como no tema escuro. */
.sidebar .user-card { background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.10); }
.sidebar .user-card:hover { background: rgba(255, 255, 255, 0.10); border-color: rgba(130, 140, 248, 0.5); }
.sidebar .user-card .user-name { color: #f0f6ff; }
.sidebar .user-card .user-email { color: #8ab5de; }
