﻿/**
 * Author:  SÃ©rgio Rosa SchÃ¼tz
 * Empresa: Pethos Tecnologia
 * Data e Hora: 14/02/2026 17:39
 * VersÃ£o: 2.3.1 (Build #3)
 * Finalidade: Componente de barra lateral unificada V17 Platinum.
 */

/* assets/css/sidebar.css - Premium Sidebar Styles */

:root {
    --sidebar-w: 320px;
    --sidebar-collapsed-width: 85px;

    /* Solid Blue Palette Original V17 */
    --sidebar-bg: #3b82f6;
    /* Azul primÃ¡rio */
    --sidebar-blur: none;
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);

    /* Eliminados gradientes em favor do flat Premium V17 Original */
    --pethos-grad: #3b82f6;
    --pethos-grad-hover: #2563eb;
    --accent-glow: rgba(255, 255, 255, 0.4);

    --transition-speed: 0.4s;
    --sidebar-font: 'Outfit', -apple-system, sans-serif;
}

[data-theme="dark"] {
    --sidebar-bg: #0f172a;
    --sidebar-border: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --sidebar-shadow: 10px 0 40px rgba(0, 0, 0, 0.2);
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: var(--sidebar-shadow);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
    height: 100vh;
    min-height: 100%;
    /* ForÃ§a preenchimento em telas quebradas */
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    /* Garante ancoragem total vertical */
    font-family: var(--sidebar-font);
    overflow: hidden;

    /* VariÃ¡veis escopadas (Texto Branco no Fundo Azul/Escuro) */
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.85);
    --primary: #ffffff;
}

/* Re-add blur via separate background element if needed, but for now prioritise fix */

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Header */
.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--sidebar-border);
    height: 80px;
    box-sizing: border-box;
}

.brand-logo {
    font-size: 2rem;
    color: #ffffff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Removidas cores "carnaval" nos Ã­cones para manter a sobriedade V17 Blue Solid.
   Agora herdam a cor branca/translÃºcida do texto */


.brand-name {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-main);
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.3s ease;
    letter-spacing: -0.8px;
    text-transform: tracking-tight;
}

.sidebar.collapsed .brand-name {
    opacity: 0;
    pointer-events: none;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    padding: 20px 12px;
}

/* Scrollbar Styling */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 20px;
}

/* Nav Item */
.nav-item {
    margin-bottom: 4px;
    border-radius: 12px;
    /* overflow: hidden; REMOVED for Flyout */
    position: relative;
    /* Anchor for positioning if needed, though we use fixed for submenus */
    transition: background 0.2s;
}

/* Estilos especÃ­ficos para pastas e mÃ³dulos do legado */
.nav-item.folder>.nav-link {
    font-weight: 600;
    color: var(--text-main);
}

.nav-item.module>.nav-link {
    font-weight: 400;
    font-size: 0.9rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 12px;
    position: relative;
    font-size: 13px;
    font-weight: 500;
    margin: 1px 0;
}

.sidebar:not(.sidebar-esus-theme) .nav-link:hover,
.sidebar:not(.sidebar-esus-theme) .nav-link:focus {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

.sidebar:not(.sidebar-esus-theme) .nav-link:hover i {
    color: #ffffff !important;
}

.sidebar-esus-theme .nav-link:hover,
.sidebar-esus-theme .nav-link:focus,
.sidebar-esus-theme .nav-link:hover .nav-text {
    color: #2563eb !important;
}

.sidebar-esus-theme .nav-link:hover i {
    color: #2563eb !important;
}

.sidebar:not(.sidebar-esus-theme) .nav-link.active,
.sidebar:not(.sidebar-esus-theme) .nav-link.active:hover {
    background: #ffffff !important;
    color: #2563eb !important;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
}

.sidebar:not(.sidebar-esus-theme) .nav-link.active i,
.sidebar:not(.sidebar-esus-theme) .nav-link.active .nav-text,
.sidebar:not(.sidebar-esus-theme) .nav-link.active:hover i,
.sidebar:not(.sidebar-esus-theme) .nav-link.active:hover .nav-text {
    color: #2563eb !important;
}

.sidebar-esus-theme .nav-link.active,
.sidebar-esus-theme .nav-link.active:hover {
    background: #ebf5ff !important;
    color: #2563eb !important;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
}

.sidebar-esus-theme .nav-link.active i,
.sidebar-esus-theme .nav-link.active .nav-text,
.sidebar-esus-theme .nav-link.active:hover i,
.sidebar-esus-theme .nav-link.active:hover .nav-text {
    color: #2563eb !important;
}

/* --- TIPOGRAFIA DA ÃRVORE --- */
.nav-item.nav-type-module>.nav-link {
    font-weight: 800 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem !important;
    margin-top: 8px;
}

.nav-item.nav-type-module>.nav-link>i {
    color: #93c5fd !important;
    /* Azul claro fluorescente para MÃ³dulos */
}

.nav-item.nav-type-level>.nav-link {
    font-weight: 700 !important;
    font-size: 0.82rem !important;
}

.nav-item.nav-type-application>.nav-link {
    font-weight: 500;
    font-size: 0.8rem !important;
}

.nav-item.nav-type-application>.nav-link>i {
    color: #c4b5fd !important;
    /* Roxo suave para AplicaÃ§Ãµes */
}

.sidebar:not(.sidebar-esus-theme) .nav-link.active i {
    color: #ffffff !important;
}

.nav-link i {
    width: 28px;
    text-align: center;
    transition: all 0.3s;
    font-size: 1.2rem;
}

.nav-text {
    flex: 1;
    white-space: normal;
    /* Allow wrap if really needed, but width is bigger now */
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.sidebar.collapsed .sidebar-nav>.nav-item>.nav-link .nav-text,
.sidebar.collapsed .sidebar-nav>.nav-item>.nav-link .chevron {
    opacity: 0;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.1s;
}

/* Chevron Rotation */
.chevron {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

/* For flyout, we point right when closed, keep right/hidden logic */
.nav-item.open>.nav-link .chevron {
    transform: rotate(90deg);
}

/* DESTAQUE DE PASTA ABERTA */
.nav-item.open>.nav-link {
    background: rgba(0, 0, 0, 0.05); /* Fundo padrÃ£o leve caso nÃ£o tenha e-SUS theme */
}

/* Evita texto branco sumir no novo tema V17 esus-theme fundo claro */
.sidebar:not(.sidebar-esus-theme) .nav-item.open>.nav-link,
.sidebar:not(.sidebar-esus-theme) .nav-item.open>.nav-link i,
.sidebar:not(.sidebar-esus-theme) .nav-item.open>.nav-link .nav-text {
    color: #ffffff !important;
}

.sidebar-esus-theme .nav-item.open>.nav-link,
.sidebar-esus-theme .nav-item.open>.nav-link i,
.sidebar-esus-theme .nav-item.open>.nav-link .nav-text {
    color: #2563eb !important;
}

/* FLYOUT Submenu Styles */
.submenu {
    /* Hidden by default */
    display: none;
    opacity: 0;

    /* Fixed positioning relative to viewport, set by JS */
    position: fixed;
    z-index: 9999;

    background: #2563eb;
    /* Azul levemente mais escuro para destaque (Solid Blue) */
    color: #ffffff;

    min-width: 240px;
    max-width: 320px;
    border-radius: 12px;
    box-shadow: 8px 8px 30px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;

    /* Animation state */
    transition: opacity 0.2s ease, margin-left 0.2s ease;
    margin-left: 10px;
}

/* Accordion Specific - Cleaned up to allow transitions */
.sidebar-accordion .submenu {
    position: relative;
    display: none;
    min-width: 0;
    max-width: none;
    box-shadow: none;
    border: none;
    background: transparent;
    margin: 0;
    padding: 0;
    left: 0;
    top: 0;
    height: auto;
}

/* OcultaÃ§Ã£o do submenu removida para nÃ£o encravar na transiÃ§Ã£o */

.sidebar-accordion .nav-item.open>.submenu {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    height: auto !important;
}

/* Ensure nested levels also behave correctly */
.sidebar-accordion .submenu .nav-item.open>.submenu {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    height: auto !important;
}




.submenu.show {
    display: block;
    opacity: 1;
    margin-left: 0;
}

.submenu .nav-link {
    padding-left: 16px !important;
    color: var(--text-muted); /* Deixa sem important para permitir override */
    display: flex !important;
    align-items: center;
    gap: 12px;
}

.submenu .nav-text {
    display: block !important;
    color: inherit;
    /* Remove !important para permitir que o estado .active mude a cor para azul */
    opacity: 1 !important;
    white-space: nowrap;
}

.sidebar:not(.sidebar-esus-theme) .submenu .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #93c5fd !important;
}

.sidebar:not(.sidebar-esus-theme) .submenu .nav-link i {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Recursive Levels Indentation - NO LONGER NEEDED FOR FLYOUT
   since they are stacked cards */
/* However, we might want to keep visual hierarchy if inside submenu? 
   No, flyout usually means next level pops out again. */

/* Override old level classes for flat look inside card */
.nav-link.level-1,
.nav-link.level-2,
.nav-link.level-3,
.nav-link.level-4,
.nav-link.level-5,
.nav-link.level-6 {
    padding-left: 10px !important;
    border-left: none;
}

.submenu .nav-link::before {
    display: none;
}

/* Footer (Logout) */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0, 0, 0, 0.03);
    /* Leve escurecimento pro rodapÃ© */
}

.sidebar-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    text-align: left;
    padding: 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.logout-btn {
    color: #fca5a5;
    /* Vermelho mais suave pra contrastar no azul */
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ffffff;
}

/* GRADIENT SIDEBAR THEME (DESATIVADO - FORÃ‡ANDO COR SÃ“LIDA) */
.sidebar.gradient-sidebar {
    background: var(--sidebar-bg) !important;
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.85);
    --sidebar-border: rgba(255, 255, 255, 0.15);
    backdrop-filter: none;
}

.sidebar.gradient-sidebar .nav-link.active,
.sidebar.gradient-sidebar .nav-link.active:hover {
    background: #ffffff !important;
    color: #2563eb !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.sidebar.gradient-sidebar .nav-link.active i,
.sidebar.gradient-sidebar .nav-link.active .nav-text {
    color: #2563eb !important;
}

.sidebar.gradient-sidebar .submenu {
    background: transparent;
    /* Melhora a hierarquia no Accordion */
}

.sidebar.gradient-sidebar .submenu .nav-link:hover,
.sidebar.gradient-sidebar .submenu .nav-link:focus {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

.sidebar.gradient-sidebar .nav-item.open>.nav-link {
    background: rgba(255, 255, 255, 0.2) !important;
    /* Destaque azul claro (PÃ­lula) para pasta aberta */
    color: #ffffff !important;
}

/* FIX PARA SUBMENUS ESCONDIDOS (APENAS SE NÃƒO FOR ACCORDION) */
.sidebar.is-admin-sidebar:not(.sidebar-accordion) {
    overflow: visible !important;
}

.sidebar.is-admin-sidebar:not(.sidebar-accordion) .sidebar-nav {
    overflow: visible !important;
}

.sidebar.is-admin-sidebar:not(.sidebar-accordion) .submenu {
    z-index: 10005 !important;
    visibility: visible !important;
}

/* Ajuste de IndentaÃ§Ã£o para Accordion (NÃ­veis) - REMOVIDO para look flat */
.sidebar.sidebar-accordion .submenu .nav-link {
    padding-left: 10px !important;
    font-size: 0.9rem;
    opacity: 0.9;
}
