/* ========================================
   MENU GLOBAL - CSS
   Importar em todas as paginas:
   <link rel="stylesheet" href="menu.css">
   ======================================== */

/* ========================================
   SEM MENU (usuario nao logado)
   ======================================== */
body.no-menu .main-content {
    margin-left: 0 !important;
    margin-top: 0 !important;
    padding-bottom: 0 !important;
}

/* ========================================
   LAYOUT ESQUERDA (sidebar estilo Instagram)
   ======================================== */
body.layout-esquerda .topbar {
    display: none !important;
}

body.layout-esquerda .sidebar {
    display: flex;
    width: 56px;
    transition: width 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

body.layout-esquerda .sidebar:hover {
    width: 244px;
}

body.layout-esquerda .sidebar .menu-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.3s ease 0.1s, width 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

body.layout-esquerda .sidebar:hover .menu-text {
    opacity: 1;
    width: auto;
    margin-left: 16px;
}

body.layout-esquerda .logo-section {
    position: relative;
    height: 56px;
    padding-left: 0;
    padding-right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.layout-esquerda .sidebar .logo-icon {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

body.layout-esquerda .menu-icon {
    min-width: 20px;
    width: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.layout-esquerda .menu-item:hover {
    background-color: var(--menu-hover-bg, rgba(0, 0, 0, 0.05));
}

body.layout-esquerda .menu-item.active {
    font-weight: 700;
    background-color: var(--menu-active-bg, rgba(0, 0, 0, 0.08));
}

body.layout-esquerda .submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    padding-left: 20px;
}

body.layout-esquerda .sidebar:hover .menu-group:hover .submenu {
    max-height: 300px;
    transition: max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

body.layout-esquerda .submenu-item {
    display: flex;
    align-items: center;
    padding: 8px 12px 8px 24px;
    color: var(--menu-text-muted, #6b7280);
    text-decoration: none;
    font-size: 14px;
    border-radius: 8px;
    transition: background-color 0.2s ease, color 0.2s ease, opacity 0.4s ease, transform 0.4s ease;
    white-space: nowrap;
    overflow: hidden;
    opacity: 0;
    transform: translateX(-8px);
}

body.layout-esquerda .sidebar:hover .menu-group:hover .submenu-item {
    opacity: 1;
    transform: translateX(0);
}

body.layout-esquerda .sidebar:hover .menu-group:hover .submenu-item:nth-child(1) { transition-delay: 0.05s; }
body.layout-esquerda .sidebar:hover .menu-group:hover .submenu-item:nth-child(2) { transition-delay: 0.1s; }
body.layout-esquerda .sidebar:hover .menu-group:hover .submenu-item:nth-child(3) { transition-delay: 0.15s; }
body.layout-esquerda .sidebar:hover .menu-group:hover .submenu-item:nth-child(4) { transition-delay: 0.2s; }
body.layout-esquerda .sidebar:hover .menu-group:hover .submenu-item:nth-child(5) { transition-delay: 0.25s; }
body.layout-esquerda .sidebar:hover .menu-group:hover .submenu-item:nth-child(6) { transition-delay: 0.3s; }

body.layout-esquerda .submenu-item:hover {
    background-color: var(--menu-hover-bg, rgba(0, 0, 0, 0.05));
    color: var(--menu-text, #111827);
}

body.layout-esquerda .sidebar:not(:hover) .submenu {
    max-height: 0 !important;
}

@media (min-width: 1024px) {
    body.layout-esquerda .main-content {
        margin-left: 56px;
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* ========================================
   LAYOUT TOPO (navbar horizontal)
   ======================================== */
body.layout-topo .sidebar {
    display: none !important;
}

body.layout-topo .topbar {
    display: flex;
}

body.layout-topo .main-content {
    margin-left: 0 !important;
    margin-top: 56px;
}

/* Topbar estilos */
.topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--menu-bg, #1e293b);
    color: var(--menu-text, white);
    z-index: 50;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-left img {
    height: 36px;
    width: 36px;
    border-radius: 8px;
}

.topbar-left .page-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.topbar-left .page-title {
    font-size: 15px;
    font-weight: 700;
}

.topbar-left .page-subtitle {
    font-size: 11px;
    color: var(--menu-text-muted, #94a3b8);
    font-weight: 400;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 2px;
}

.topbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--menu-text-muted, #cbd5e1);
    text-decoration: none;
    font-size: 10px;
    gap: 2px;
    transition: background-color 0.15s, color 0.15s;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

.topbar-item:hover {
    background-color: var(--menu-hover-bg, rgba(255,255,255,0.1));
    color: var(--menu-text, white);
}

.topbar-item.active {
    color: var(--menu-text, white);
    font-weight: 600;
}

.topbar-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: #3b82f6;
    border-radius: 2px;
}

.topbar-item i {
    font-size: 17px;
}

/* Dropdown do topbar */
.topbar-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    min-width: 200px;
    padding: 6px;
    display: none;
    z-index: 80;
}

.topbar-group:hover .topbar-dropdown {
    display: block;
}

.topbar-dropdown a {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    border-radius: 8px;
    transition: background-color 0.15s;
    gap: 10px;
}

.topbar-dropdown a:hover {
    background-color: #f3f4f6;
}

.topbar-dropdown a i {
    width: 18px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* ========================================
   MOBILE (ambos layouts viram barra no topo)
   ======================================== */
.menu-label-mobile {
    display: none;
}

.mobile-submenu-overlay {
    display: none;
}

@media (max-width: 1023px) {
    body.layout-esquerda .sidebar,
    body.layout-topo .sidebar {
        display: none !important;
    }

    body.layout-esquerda .topbar,
    body.layout-topo .topbar {
        display: none !important;
    }

    .mobile-nav {
        display: flex !important;
    }

    body .main-content {
        margin-left: 0 !important;
        margin-top: 60px !important;
        margin-bottom: 0 !important;
    }

    .mobile-submenu-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 60;
    }

    .mobile-submenu-overlay.active {
        display: block;
    }

    .mobile-submenu-panel {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: auto;
        background: white;
        border-radius: 0 0 16px 16px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        z-index: 70;
        padding: 8px 16px 16px;
        transform: translateY(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-submenu-overlay.active .mobile-submenu-panel {
        transform: translateY(0);
    }

    .mobile-submenu-panel .submenu-title {
        font-size: 14px;
        font-weight: 600;
        color: #374151;
        padding: 8px 8px 12px;
        border-bottom: 1px solid #e5e7eb;
        margin-bottom: 4px;
    }

    .mobile-submenu-panel a {
        display: flex;
        align-items: center;
        padding: 14px 12px;
        color: #374151;
        text-decoration: none;
        font-size: 15px;
        border-radius: 10px;
        transition: background-color 0.15s ease;
    }

    .mobile-submenu-panel a:hover,
    .mobile-submenu-panel a:active {
        background-color: #f3f4f6;
    }

    .mobile-submenu-panel a i {
        margin-right: 12px;
        width: 20px;
        text-align: center;
        color: #6b7280;
    }
}

/* Mobile nav bar */
.mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--menu-bg, white);
    border-bottom: 1px solid var(--menu-border, #e5e7eb);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    z-index: 50;
    align-items: center;
    justify-content: space-evenly;
    padding: 0;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    gap: 1px;
    text-decoration: none;
    color: var(--menu-text-muted, #6b7280);
    cursor: pointer;
    height: 56px;
}

.mobile-nav-item.active {
    color: #2563eb;
    font-weight: 700;
}

.mobile-nav-item i {
    font-size: 18px;
}

.mobile-nav-item span {
    font-size: 9px;
    line-height: 1.1;
    white-space: nowrap;
}

/* Esconder menus ate carregar preferencia */
body:not(.layout-esquerda):not(.layout-topo) .sidebar,
body:not(.layout-esquerda):not(.layout-topo) .topbar,
body:not(.layout-esquerda):not(.layout-topo) #page-header {
    visibility: hidden;
}

.menu-item {
    transition: background-color 0.2s ease;
}

.menu-group {
    position: relative;
}

/* ========================================
   CABECALHO DE PAGINA
   ======================================== */
.page-header {
    background: var(--menu-bg, #1e293b);
    border-bottom: 1px solid var(--menu-border, #e5e7eb);
    padding: 16px 24px;
    margin-bottom: 0;
}

.page-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.page-header-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--menu-text, #111827);
    line-height: 1.2;
    margin: 0;
}

.page-header-breadcrumb {
    font-size: 12px;
    color: var(--menu-text-muted, #6b7280);
    font-weight: 400;
}

@media (max-width: 640px) {
    .page-header {
        padding: 12px 16px;
    }
    .page-header-title {
        font-size: 17px;
    }
}

@media print {
    .page-header {
        display: none !important;
    }
}

/* ========================================
   OCULTAR VALORES MONETÁRIOS
   ======================================== */
.valor-monetario {
    display: inline-block;
    position: relative;
}

body.valores-ocultos .valor-monetario {
    color: transparent !important;
    user-select: none;
    position: relative;
    min-width: 4em;
}

body.valores-ocultos .valor-monetario::after {
    content: '••••••';
    color: #9ca3af;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    text-align: inherit;
    font-size: inherit;
    font-weight: inherit;
    letter-spacing: 2px;
}

/* Botão olhinho no topbar */
#btn-toggle-valores {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s, border-color 0.2s;
    color: #fff;
}
#btn-toggle-valores:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    color: #fff;
}

/* ========================================
   IMPRESSAO - Ocultar menu
   ======================================== */
@media print {
    #menu-container,
    .sidebar,
    .topbar,
    .mobile-nav,
    .mobile-submenu-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        margin-top: 0 !important;
        padding-bottom: 0 !important;
    }
}
