/* ============================================
   DARK THEME VARIABLES
   ============================================ */
:root {
    --dark-base: #0c0f14;
    --dark-elevated: #131820;
    --dark-card: #1c222b;
    --dark-border: rgba(255, 255, 255, 0.08);
    --text-primary: rgba(255, 255, 255, 0.9);
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --accent-green: #32e768; /* Fallback - será sobrescrito por --accent-primary do load_settings.php */
    --accent-primary: var(--accent-green); /* Fallback padrão - será sobrescrito dinamicamente */
    --accent-primary-hover: #28d15e; /* Fallback padrão - será sobrescrito dinamicamente */
}

/* Estilos para complementar o TailwindCSS e customizar o Payment Brick do Mercado Pago.
*/
body {
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Dark Theme Background Classes */
.bg-dark-base {
    background-color: var(--dark-base);
}

.bg-dark-elevated {
    background-color: var(--dark-elevated);
}

.bg-dark-card {
    background-color: var(--dark-card);
}

/* Customização do botão principal do Mercado Pago */
.mercadopago-button {
    background-color: var(--accent-color, #00A3FF) !important; /* Usa a cor de destaque definida no PHP */
    transition: filter 0.2s ease !important;
    font-size: 1.125rem !important;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

.mercadopago-button:hover {
    filter: brightness(1.1);
}


/* Novo Estilo para o Resumo Final */
.checkout-summary-box {
    background-color: #f9fafb; /* Cinza claro */
    border: 1px solid #e5e7eb; /* Borda sutil */
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
}

/* Estilo para a linha tracejada */
.checkout-summary-box hr {
    border-top-style: dashed;
}

/* ============================================
   GLASSMORPHISM SIDEBAR - MODERN DESIGN
   ============================================ */

/* Base para responsividade do menu lateral */
/* Sidebar oculta por padrão em telas pequenas */
#sidebar, #admin-sidebar {
    position: fixed;
    top: 0; /* Full height - cobre o header */
    bottom: 0;
    left: 0;
    z-index: 50; /* Acima do header (z-50) */
    width: 100%;
    max-width: 280px; /* Largura máxima para mobile */
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Sidebar Header (Logo Area) */
.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--dark-border);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}

.sidebar-header img {
    max-height: 40px;
    width: auto;
}

/* Sidebar Footer (User Controls) */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--dark-border);
    margin-top: auto;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    transition: background 0.2s ease;
}

.sidebar-user-info:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-primary);
}

.sidebar-user-name {
    flex: 1;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
}

.sidebar-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.sidebar-control-btn {
    padding: 0.5rem;
    border-radius: 0.5rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-control-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

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

/* Animação Shimmer para Barra de Progresso */
@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.animate-shimmer {
    animation: shimmer 2s infinite;
}

/* Glassmorphism Effect - Modern Glass */
.sidebar-glass {
    background: rgba(15, 20, 28, 0.75) !important;
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Sidebar Items - Base Styles */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    position: relative;
    text-decoration: none;
}

/* Estado Inativo */
.sidebar-item-inactive {
    color: rgba(255, 255, 255, 0.7);
}

.sidebar-item-inactive:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.9);
}

.sidebar-item-inactive i {
    color: rgba(255, 255, 255, 0.6);
    transition: color 0.2s ease;
}

.sidebar-item-inactive:hover i {
    color: rgba(255, 255, 255, 0.9);
}

/* Estado Ativo - Clean Design */
/* As cores são definidas dinamicamente via load_settings.php */
.sidebar-item-active {
    font-weight: 600;
}

/* Sidebar visível quando a classe 'open' é aplicada */
#sidebar.open, #admin-sidebar.open {
    transform: translateX(0);
}

/* Overlay para fechar o menu ao clicar fora (mobile) */
#sidebar-overlay, #admin-sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 30;
    display: none; /* Oculto por padrão */
    transition: opacity 0.3s ease-in-out;
    opacity: 0;
}

/* Overlay visível quando a classe 'open' é aplicada */
#sidebar-overlay.open, #admin-sidebar-overlay.open {
    display: block;
    opacity: 1;
}

/*
   Ajuste do conteúdo principal
   As regras de `margin-left`, `flex-grow`, `padding` e `overflow-y`
   agora são controladas diretamente pelas classes do Tailwind CSS
   aplicadas no HTML dos arquivos `index.php` e `admin.php`.
   Remover regras genéricas aqui evita conflitos com o layout de `checkout.php`.
*/
/* main {
    margin-left: 0;
    flex-grow: 1;
    overflow-y: auto;
} */ /* REMOVIDO: Regras específicas para 'main' agora são definidas no HTML com Tailwind */

/* Oculta o botão de toggle em telas maiores que md */
#sidebar-toggle, #admin-sidebar-toggle {
    display: flex; /* Visível por padrão em mobile */
}

/* Media query para telas maiores (desktop) */
@media (min-width: 768px) { /* md breakpoint (768px) */
    #sidebar, #admin-sidebar {
        transform: translateX(0); /* Sempre visível em desktop */
        width: 256px; /* md:w-64 */
    }

    #sidebar-toggle, #admin-sidebar-toggle {
        display: none; /* Oculta em desktop */
    }

    #sidebar-overlay, #admin-sidebar-overlay {
        display: none !important; /* Nunca visível em desktop */
        opacity: 0 !important;
    }
}

/* Dark Theme Card Styles */
.dark-card {
    background-color: var(--dark-card);
    border: 1px solid var(--dark-border);
    border-radius: 0.75rem;
    color: var(--text-primary);
}

.dark-card-header {
    border-bottom: 1px solid var(--dark-border);
    padding: 1rem 1.5rem;
}

.dark-card-body {
    padding: 1.5rem;
}

.dark-input {
    background-color: var(--dark-elevated);
    border: 1px solid var(--dark-border);
    color: var(--text-primary);
}

.dark-input:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb, 50, 231, 104), 0.1);
}

.dark-input::placeholder {
    color: var(--text-muted);
}

/* ============================================
   LIGHT THEME OVERRIDES
   ============================================ */
[data-theme="light"] {
    --dark-base: #f1f5f9;
    --dark-elevated: #ffffff;
    --dark-card: #ffffff;
    --dark-border: rgba(0, 0, 0, 0.1);
    --text-primary: rgba(15, 23, 42, 0.9);
    --text-secondary: rgba(51, 65, 85, 0.8);
    --text-muted: rgba(100, 116, 139, 0.7);
}

/* Light theme: override Tailwind literal dark colors for contrast */
[data-theme="light"] .text-white {
    color: #0f172a !important;
}

[data-theme="light"] .text-gray-200 {
    color: #1e293b !important;
}

[data-theme="light"] .text-gray-300 {
    color: #334155 !important;
}

[data-theme="light"] .text-gray-400 {
    color: #64748b !important;
}

[data-theme="light"] .text-gray-500 {
    color: #94a3b8 !important;
}

/* Light theme: colored text adjustments for readability */
[data-theme="light"] .text-blue-300 {
    color: #2563eb !important;
}

[data-theme="light"] .text-blue-200 {
    color: #1d4ed8 !important;
}

[data-theme="light"] .text-blue-400 {
    color: #3b82f6 !important;
}

[data-theme="light"] .text-green-300 {
    color: #16a34a !important;
}

[data-theme="light"] .text-green-200 {
    color: #15803d !important;
}

[data-theme="light"] .text-green-400 {
    color: #22c55e !important;
}

[data-theme="light"] .text-red-300 {
    color: #dc2626 !important;
}

[data-theme="light"] .text-red-400 {
    color: #ef4444 !important;
}

[data-theme="light"] .text-yellow-300 {
    color: #ca8a04 !important;
}

[data-theme="light"] .text-yellow-200 {
    color: #a16207 !important;
}

[data-theme="light"] .text-purple-400 {
    color: #9333ea !important;
}

/* Light theme: section labels in sidebar */
[data-theme="light"] .sidebar-section-label {
    color: #94a3b8 !important;
}

/* Light theme: dropdown menus */
[data-theme="light"] .bg-dark-card {
    border-color: #e2e8f0 !important;
}

/* Light theme: notification popup */
[data-theme="light"] .notification-popup {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
}

/* Light theme: badges and tags */
[data-theme="light"] .bg-green-900\/30 {
    background-color: rgba(34, 197, 94, 0.1) !important;
}

[data-theme="light"] .bg-gray-700 {
    background-color: #e2e8f0 !important;
}

/* Light theme: hover states */
[data-theme="light"] .hover\:bg-dark-elevated:hover {
    background-color: #f1f5f9 !important;
}

[data-theme="light"] .hover\:bg-dark-card:hover {
    background-color: #f8fafc !important;
}

/* Light theme: logo swap support */
[data-theme="light"] .logo-dark {
    display: none !important;
}

[data-theme="light"] .logo-light {
    display: block !important;
}

[data-theme="dark"] .logo-light,
:root .logo-light {
    display: none !important;
}

[data-theme="dark"] .logo-dark,
:root .logo-dark {
    display: block !important;
}

/* Light theme: body/page backgrounds */
[data-theme="light"] body {
    background-color: var(--dark-base) !important;
}

/* Light theme: header */
[data-theme="light"] header.fixed {
    background: rgba(241, 245, 249, 0.9) !important;
    border-bottom: 1px solid var(--dark-border);
}

/* Light theme: sidebar */
[data-theme="light"] .sidebar-glass {
    background: rgba(255, 255, 255, 0.85) !important;
    border-right: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.06) !important;
}

[data-theme="light"] .sidebar-item-inactive {
    color: #334155;
}

[data-theme="light"] .sidebar-item-inactive:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #0f172a;
}

[data-theme="light"] .sidebar-item-inactive i {
    color: #64748b;
}

[data-theme="light"] .sidebar-item-inactive:hover i {
    color: #0f172a;
}

[data-theme="light"] .sidebar-user-info:hover {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .sidebar-control-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #0f172a;
}

[data-theme="light"] .sidebar-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .sidebar-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* Light theme: cards with shadows instead of dark bg */
[data-theme="light"] .bg-dark-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .bg-dark-elevated {
    background-color: #f8fafc !important;
}

/* Light theme: borders */
[data-theme="light"] .border-dark-border {
    border-color: #e2e8f0 !important;
}

/* Light theme: form inputs */
[data-theme="light"] .form-input,
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="email"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="number"],
[data-theme="light"] input[type="url"],
[data-theme="light"] input[type="search"],
[data-theme="light"] input[type="tel"],
[data-theme="light"] textarea,
[data-theme="light"] select {
    background-color: #ffffff !important;
    border-color: #d1d5db !important;
    color: #1e293b !important;
}

[data-theme="light"] .form-input::placeholder,
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder {
    color: #94a3b8 !important;
}

/* Light theme: dark-card class used directly */
[data-theme="light"] .dark-card {
    background-color: #ffffff;
    border-color: #e2e8f0;
    color: #0f172a;
}

[data-theme="light"] .dark-input {
    background-color: #ffffff;
    border-color: #d1d5db;
    color: #1e293b;
}

/* Light theme: info/alert boxes */
[data-theme="light"] .bg-blue-900\/20 {
    background-color: rgba(59, 130, 246, 0.08) !important;
}

[data-theme="light"] .bg-green-900\/20 {
    background-color: rgba(34, 197, 94, 0.08) !important;
}

[data-theme="light"] .bg-red-900\/20 {
    background-color: rgba(239, 68, 68, 0.08) !important;
}

[data-theme="light"] .bg-yellow-900\/20 {
    background-color: rgba(234, 179, 8, 0.08) !important;
}

/* Light theme: toggle button */
.theme-toggle-btn {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

[data-theme="dark"] .theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Light theme: overlay */
[data-theme="light"] #sidebar-overlay.open,
[data-theme="light"] #admin-sidebar-overlay.open {
    background-color: rgba(0, 0, 0, 0.2);
}

/* Light theme: mobile toggle button */
[data-theme="light"] #sidebar-toggle,
[data-theme="light"] #admin-sidebar-toggle {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #334155 !important;
}

/* Light theme: dropdown/notification panel */
[data-theme="light"] .bg-dark-base\/80 {
    background-color: rgba(241, 245, 249, 0.9) !important;
}

/* Invisible Header Styles */
header.fixed {
    background: rgba(7, 9, 13, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* ============================================
   MODERNIZATION: UI/UX IMPROVEMENTS
   ============================================ */

/* Sidebar Active State - Pill Indicator */
.sidebar-item-active {
    position: relative;
}
.sidebar-item-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background-color: var(--accent-primary);
}

/* Section Labels with Decorative Line */
.sidebar-section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
}
[data-theme="light"] .sidebar-section-label::after {
    background: rgba(0, 0, 0, 0.06);
}

/* Cards - Improved Shadow & Hover */
.dark-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.dark-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
[data-theme="light"] .dark-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .dark-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* KPI Cards - Accent Bar on Hover */
.kpi-card {
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), transparent);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.kpi-card:hover::before {
    opacity: 1;
}

/* Dark Table - Improved */
.dark-table th {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--dark-border);
}
.dark-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.dark-table tbody tr {
    transition: background-color 0.15s ease;
}
.dark-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}
[data-theme="light"] .dark-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}
[data-theme="light"] .dark-table td {
    border-bottom-color: rgba(0, 0, 0, 0.04);
}

/* Loading Skeleton Animation */
@keyframes skeleton-pulse {
    0% { opacity: 0.6; }
    50% { opacity: 0.3; }
    100% { opacity: 0.6; }
}
.skeleton {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}
[data-theme="light"] .skeleton {
    background: rgba(0, 0, 0, 0.06);
}

/* Button Hierarchy */
.btn-primary {
    background-color: var(--accent-primary);
    color: #fff;
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover {
    background-color: var(--accent-primary-hover);
}
.btn-primary:active {
    transform: scale(0.98);
}
.btn-secondary {
    background-color: var(--dark-elevated);
    color: var(--text-primary);
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    border: 1px solid var(--dark-border);
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.btn-secondary:hover {
    background-color: var(--dark-card);
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}
[data-theme="light"] .btn-ghost:hover {
    background: rgba(0, 0, 0, 0.04);
}
.btn-danger {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.25);
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    top: 80px;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    background: var(--dark-card);
    border: 1px solid var(--dark-border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 280px;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toast-slide-in 0.3s ease-out;
}
.toast-success { border-left: 3px solid #22c55e; }
.toast-error { border-left: 3px solid #ef4444; }
.toast-warning { border-left: 3px solid #eab308; }
.toast-info { border-left: 3px solid #3b82f6; }

@keyframes toast-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

[data-theme="light"] .toast {
    background: #fff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Breadcrumb Component */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}
.breadcrumb a:hover {
    color: var(--accent-primary);
}
.breadcrumb .separator {
    color: var(--text-muted);
    font-size: 0.75rem;
}
.breadcrumb .current {
    color: var(--text-primary);
    font-weight: 500;
}

/* Global Smooth Transitions */
a, button, input, select, textarea {
    transition-property: background-color, border-color, color, box-shadow, opacity;
    transition-duration: 0.15s;
    transition-timing-function: ease;
}

/* Sidebar Menu Badge */
.menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    background-color: var(--accent-primary);
    color: #fff;
    margin-left: auto;
}

/* ============================================
   SIDEBAR COLLAPSE - Desktop Only
   ============================================ */

/* Collapse Toggle Button - always visible on desktop */
.sidebar-collapse-btn {
    display: none; /* hidden on mobile */
}

@media (min-width: 768px) {
    .sidebar-collapse-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        padding: 0;
        border-radius: 50%;
        color: var(--text-muted);
        cursor: pointer;
        border: 1px solid var(--dark-border);
        background: var(--dark-elevated);
        position: fixed;
        top: 28px;
        left: 244px; /* 256px sidebar - 12px offset */
        z-index: 60;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease, left 0.3s ease;
    }
    body.sidebar-collapsed .sidebar-collapse-btn {
        left: 56px; /* 68px sidebar - 12px offset */
    }
    .sidebar-collapse-btn:hover {
        background: var(--dark-card);
        color: var(--text-primary);
        transform: scale(1.1);
    }
    [data-theme="light"] .sidebar-collapse-btn {
        background: #fff;
        border-color: #e2e8f0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    [data-theme="light"] .sidebar-collapse-btn:hover {
        background: #f8fafc;
    }

    /* Sidebar needs position:relative for the button */
    #sidebar, #admin-sidebar {
        position: fixed; /* already set, just ensuring */
    }

    /* === COLLAPSED STATE === */
    #sidebar.collapsed, #admin-sidebar.collapsed {
        width: 68px !important;
        overflow: visible; /* allow tooltip overflow */
    }

    /* Hide all text, labels, widgets, plan cards, dropdowns */
    #sidebar.collapsed .sidebar-item span,
    #sidebar.collapsed .sidebar-item .menu-badge,
    #sidebar.collapsed .sidebar-section-label,
    #sidebar.collapsed .sidebar-user-name,
    #sidebar.collapsed .sidebar-dropdown-menu,
    #sidebar.collapsed .sidebar-dropdown-toggle .dropdown-arrow,
    #sidebar.collapsed .sidebar-header img,
    #sidebar.collapsed .sidebar-user-info span,
    #sidebar.collapsed > .px-2.mb-4,
    #sidebar.collapsed > .mt-auto,
    #admin-sidebar.collapsed .sidebar-item span,
    #admin-sidebar.collapsed .sidebar-item .menu-badge,
    #admin-sidebar.collapsed .sidebar-section-label,
    #admin-sidebar.collapsed .sidebar-user-name,
    #admin-sidebar.collapsed .sidebar-dropdown-menu,
    #admin-sidebar.collapsed .sidebar-dropdown-toggle .dropdown-arrow,
    #admin-sidebar.collapsed .sidebar-header img,
    #admin-sidebar.collapsed .sidebar-user-info span,
    #admin-sidebar.collapsed > .px-2,
    #admin-sidebar.collapsed > .mt-auto {
        display: none !important;
    }

    /* Center icons in collapsed items */
    #sidebar.collapsed .sidebar-item,
    #admin-sidebar.collapsed .sidebar-item {
        justify-content: center;
        padding: 0.65rem;
        margin: 2px 6px;
        gap: 0;
    }
    #sidebar.collapsed .sidebar-item i,
    #admin-sidebar.collapsed .sidebar-item i {
        margin: 0;
        width: 22px;
        height: 22px;
    }

    /* Pill indicator adjustment for collapsed */
    #sidebar.collapsed .sidebar-item-active::before,
    #admin-sidebar.collapsed .sidebar-item-active::before {
        top: 15%;
        bottom: 15%;
    }

    /* Header: show small icon/initial instead of logo */
    #sidebar.collapsed .sidebar-header,
    #admin-sidebar.collapsed .sidebar-header {
        padding: 1rem 0.25rem;
        justify-content: center;
        min-height: 60px;
    }

    /* Footer: only show avatar, hide controls text */
    #sidebar.collapsed .sidebar-footer,
    #admin-sidebar.collapsed .sidebar-footer {
        padding: 0.5rem 0.25rem;
    }
    #sidebar.collapsed .sidebar-user-info,
    #admin-sidebar.collapsed .sidebar-user-info {
        justify-content: center;
        padding: 0.4rem;
        gap: 0;
    }
    #sidebar.collapsed .sidebar-user-avatar,
    #admin-sidebar.collapsed .sidebar-user-avatar {
        width: 32px;
        height: 32px;
    }
    #sidebar.collapsed .sidebar-controls,
    #admin-sidebar.collapsed .sidebar-controls {
        justify-content: center;
        flex-wrap: wrap;
        gap: 2px;
    }
    #sidebar.collapsed .sidebar-control-btn,
    #admin-sidebar.collapsed .sidebar-control-btn {
        padding: 0.35rem;
    }

    /* Nav padding in collapsed */
    #sidebar.collapsed nav,
    #admin-sidebar.collapsed nav {
        padding: 0 2px;
    }

    /* Dropdown toggle acts as regular item when collapsed */
    #sidebar.collapsed .sidebar-dropdown-toggle,
    #admin-sidebar.collapsed .sidebar-dropdown-toggle {
        pointer-events: none; /* disable dropdown in collapsed mode */
    }
    #sidebar.collapsed .sidebar-dropdown-toggle .flex,
    #admin-sidebar.collapsed .sidebar-dropdown-toggle .flex {
        justify-content: center;
        gap: 0;
    }

    /* Tooltip for collapsed items - appears on hover to the right */
    #sidebar.collapsed .sidebar-item[data-tooltip],
    #admin-sidebar.collapsed .sidebar-item[data-tooltip] {
        position: relative;
    }
    #sidebar.collapsed .sidebar-item[data-tooltip]::after,
    #admin-sidebar.collapsed .sidebar-item[data-tooltip]::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%);
        background: var(--dark-card);
        color: var(--text-primary);
        border: 1px solid var(--dark-border);
        padding: 6px 12px;
        border-radius: 6px;
        font-size: 0.8rem;
        font-weight: 500;
        white-space: nowrap;
        z-index: 200;
        pointer-events: none;
        opacity: 0;
        visibility: hidden;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        transition: opacity 0.15s ease, visibility 0.15s ease;
    }
    #sidebar.collapsed .sidebar-item[data-tooltip]:hover::after,
    #admin-sidebar.collapsed .sidebar-item[data-tooltip]:hover::after {
        opacity: 1;
        visibility: visible;
    }
    [data-theme="light"] #sidebar.collapsed .sidebar-item[data-tooltip]::after,
    [data-theme="light"] #admin-sidebar.collapsed .sidebar-item[data-tooltip]::after {
        background: #fff;
        border-color: #e2e8f0;
        color: #1e293b;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    /* Main content adapts to collapsed sidebar */
    body.sidebar-collapsed main {
        margin-left: 68px !important;
    }

}