:root {
    --brand-primary: #6366f1;
    --brand-secondary: #4f46e5;
    --brand-glass-opacity: 0.7;
    --brand-gradient: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
}

/* Sovereign Navbar Global Styles */
.premium-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: rgba(255, 255, 255, var(--brand-glass-opacity));
    backdrop-filter: blur(15px);
    width: calc(100% - 32px);
    max-width: 1750px;
    margin: 0 auto 20px auto;
    border-radius: 0 0 24px 24px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 2000;
    border: 1px solid rgba(255, 255, 255, 0.4);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.premium-navbar.navbar-hidden {
    transform: translateY(-110%);
    opacity: 0;
    pointer-events: none;
    margin-bottom: -60px;
    /* Collapse space */
}

.navbar-toggle-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-size: 0.8rem;
    transition: all 0.2s;
    margin-left: 4px;
    flex-shrink: 0;
}

.navbar-toggle-btn:hover {
    background: #ef4444;
    color: white;
    transform: rotate(90deg);
}

.navbar-restore-btn {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 20px;
    border-radius: 0 0 15px 15px;
    background: var(--brand-primary);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 3000;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
    animation: slideInDown 0.4s ease;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@media print {
    .navbar-restore-btn,
    #navbar-restore-trigger,
    .navbar-toggle-btn,
    #focus-toggle {
        display: none !important;
        visibility: hidden !important;
    }
}

@keyframes slideInDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.brand-title {
    font-size: 1.5rem;
    font-weight: bold;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    white-space: nowrap;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 8px;
}

.toggle-menu-btn,
.toggle-help-btn {
    padding: 6px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    height: 36px;
    white-space: nowrap;
    flex-shrink: 0;
}

.toggle-menu-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.25);
}

.toggle-help-btn {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.nav-menu-container,
.help-menu-container {
    display: none;
    position: fixed;
    top: 82px;
    right: 18px;
    width: min(460px, calc(100vw - 32px));
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(100vh - 102px) !important;
    background: rgba(255, 255, 255, 0.99);
    backdrop-filter: blur(25px);
    border-radius: 16px;
    box-shadow: 0 18px 40px -16px rgba(15, 23, 42, 0.35);
    padding: 14px;
    z-index: 99999;
    min-width: 200px;
    /* Reduced to half size as requested */
    border: 1px solid rgba(255, 255, 255, 1);

    overflow-y: auto !important;
    padding-bottom: 18px !important;
    scrollbar-width: thin;
    scrollbar-color: #c47f0f #f1f5f9;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* The previous oversized anchor caused menus to appear detached from the bar. */
.nav-menu-container::before {
    display: none;
}

/* Premium Scrollbar Styling */
.nav-menu-container::-webkit-scrollbar,
.help-menu-container::-webkit-scrollbar {
    width: 8px;
}

.nav-menu-container::-webkit-scrollbar-track,
.help-menu-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.nav-menu-container::-webkit-scrollbar-thumb,
.help-menu-container::-webkit-scrollbar-thumb {
    background: #4338ca;
    border-radius: 10px;
}

.nav-menu-container::-webkit-scrollbar-thumb:hover,
.help-menu-container::-webkit-scrollbar-thumb:hover {
    background: #3730a3;
}


/* Removed redundant positioning override */

.help-menu-container {
    right: 18px;
}

.nav-menu-container .menu-grid,
.help-menu-container .menu-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.nav-menu-container .menu-section-header,
.help-menu-container .menu-section-header,
.nav-menu-container .full-width-tile,
.help-menu-container .full-width-tile {
    grid-column: 1 / -1;
}

.nav-menu-container .nav-menu-item,
.help-menu-container .nav-menu-item {
    min-height: 48px;
    padding: 8px 10px;
}

/* --- INDIVIDUAL MENU BUTTONS (The items you want to make taller) --- */
.nav-menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    /* Reduced vertical padding for a more compact list */
    margin: 4px 0;
    /* Reduced margin to bring buttons closer together */
    color: #1e293b;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 700;
    font-size: 0.95rem;
}

.nav-menu-item:hover {
    background: #f1f5f9;
    border-color: #6366f1;
    color: #4338ca;
    transform: scale(1.02) translateX(5px);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.12);
}

/* --- MENU SECTION HEADERS (Headers like "Main Navigation") --- */
.menu-section-header {
    font-size: 0.8rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #64748b;
    padding: 10px 4px 4px;
    margin-top: 4px;
    border-bottom: 2px solid #f1f5f9;
    margin-bottom: 8px;
    /* Reduced space below header */
}

.user-info-badge {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 6px 16px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    font-size: 0.8rem;
    color: #475569;
    font-weight: 600;
}

@media (max-width: 1024px) {
    .premium-navbar {
        padding: 18px 24px;
        border-radius: 0 0 24px 24px;
    }
    .premium-clock {
        display: none;
    }
}

@media (max-width: 768px) {
    .premium-navbar {
        padding: 15px 18px;
        flex-direction: row; /* Keep branding and controls on same line if possible */
        justify-content: space-between;
    }

    .brand-title {
        font-size: 1.2rem;
    }

    .nav-controls {
        gap: 8px;
    }

    .toggle-menu-btn, .toggle-help-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
        height: 38px;
    }

    .nav-menu-container,
    .help-menu-container {
        position: fixed;
        top: 75px !important;
        left: 12px !important;
        right: 12px !important;
        width: calc(100% - 24px) !important;
        max-height: 80vh !important;
        border-radius: 24px !important;
        padding: 15px !important;
    }
    
    .nav-menu-container::before {
        display: none; /* Hide anchor arrow on mobile for cleaner look */
    }
}

@media (max-width: 480px) {
    .premium-navbar {
        padding: 12px 15px;
        flex-direction: column;
        gap: 12px;
    }
    
    .nav-controls {
        width: 100%;
        justify-content: center;
    }
    
    .brand-title {
        width: 100%;
        text-align: center;
    }

    .business-tagline {
        font-size: 0.8rem !important;
    }
}

/* ============================================================
   MULTI-BUSINESS & BRANCH SWITCHER ENHANCEMENTS
   Swift, zero-latency administration across linked business units
   ============================================================ */
#branch-switcher-container {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
    flex-shrink: 1;
}

@media (max-width: 1450px) {
    #branch-switcher-container label {
        display: none !important;
    }
}

#branch-switcher-select {
    padding: 7px 12px;
    border: 2px solid #3b82f6;
    border-radius: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    max-width: 250px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: all 0.2s ease;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

#branch-switcher-select:hover {
    border-color: #2563eb;
    background: #dbeafe;
}

#branch-switcher-select:focus {
    border-color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

@media (max-width: 768px) {
    #branch-switcher-container {
        width: 100%;
        justify-content: center;
        margin: 4px 0;
    }
    #branch-switcher-select {
        max-width: 100%;
        width: 100%;
    }
}
