/**
 * Menu Gem Styles
 * Purpose: Main navigation and mobile sidebar styles
 *
 * Architecture:
 * - CSS Variables for theming
 * - BEM-like naming convention
 * - Mobile-first responsive design
 * - RTL-compatible (Bootstrap 4.6 RTL)
 * - Accessibility compliant
 *
 * WHY extracted from Blade: Better performance (browser caching), maintainability, reusability
 */

/* ========================================
   CSS VARIABLES (Theming)
   ======================================== */

:root {
    --menu-sidebar-width: 290px;
    --menu-sidebar-bg: #ffffff;
    --menu-overlay-bg: rgba(0, 0, 0, 0.6);
    --menu-primary-color: #1f7373;
    --menu-transition-speed: 0.3s;
    --menu-transition-ease: cubic-bezier(0.25, 0.8, 0.25, 1);
    --menu-z-overlay: 99990;
    --menu-z-sidebar: 99999;
    --menu-border-color: #eee;
    --menu-hover-bg: #f9f9f9;
    --menu-text-color: #444;
}

/* ========================================
   SIDEBAR OVERLAY
   WHY: Blocks interaction with page when sidebar is open
   ======================================== */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--menu-overlay-bg);
    z-index: var(--menu-z-overlay);
    opacity: 0;
    visibility: hidden;
    transition: all var(--menu-transition-speed) ease;
    backdrop-filter: blur(2px);
    /* WHY backdrop-filter: Modern visual effect, indicates modal state */
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   MOBILE SIDEBAR (Common Base)
   WHY: Shared styles for all three sidebars (main, category, user)
   ======================================== */

.mobile-sidebar {
    position: fixed;
    top: 0;
    right: calc(var(--menu-sidebar-width) * -1);
    /* Hidden off-screen to the right */
    width: var(--menu-sidebar-width);
    height: 100vh;
    background: var(--menu-sidebar-bg);
    z-index: var(--menu-z-sidebar);
    overflow-y: auto;
    transition: right 0.4s var(--menu-transition-ease);
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    /* WHY flex column: Allows sticky footer for CTA buttons */
}

.mobile-sidebar.open {
    right: 0;
}

/* ========================================
   SIDEBAR HEADER
   ======================================== */

.sidebar-header {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--menu-border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    color: #333;
    flex-shrink: 0;
    /* WHY flex-shrink 0: Header always visible, doesn't compress */
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #dc3545;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: transform 0.2s ease;
}

.close-btn:hover {
    transform: scale(1.1);
}

.close-btn:focus {
    outline: 2px solid var(--menu-primary-color);
    outline-offset: 2px;
}

/* ========================================
   SIDEBAR CONTENT
   ======================================== */

.sidebar-content {
    padding: 10px 0;
    flex-grow: 1;
    overflow-y: auto;
    /* WHY overflow auto: Allows scrolling if content exceeds viewport */
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    border-bottom: 1px solid #f1f1f1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--menu-text-color);
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s ease, color 0.2s ease;
    /*justify-content: space-between;*/
}

.sidebar-nav li a:hover {
    background: var(--menu-hover-bg);
    color: var(--menu-primary-color);
}

.sidebar-nav li a:focus {
    outline: 2px solid var(--menu-primary-color);
    outline-offset: -2px;
}

.sidebar-nav li a i {
    margin-left: 10px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* ========================================
   SUBMENU (Accordion)
   WHY: Allows nested navigation without leaving sidebar
   ======================================== */

.sidebar-submenu {
    display: none;
    /* Hidden by default */
    background: #fcfcfc;
    list-style: none;
    padding: 0;
    margin: 0;
    border-top: 1px solid var(--menu-border-color);
}

.sidebar-submenu li a {
    padding-right: 40px;
    /* Indentation for hierarchy */
    font-size: 13px;
    color: #000000;
}

.sidebar-submenu li a:hover {
    background: #f5f5f5;
}

/* Accordion Arrow */
/* WHY touch-action: manipulation: Removes 300ms tap delay on mobile so dropdown opens immediately */
.has-submenu>a {
    position: relative;
    touch-action: manipulation;
}

.has-submenu>a::after {
    content: '\f107';
    /* FontAwesome Down Arrow */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    margin-right: auto;
    transition: transform var(--menu-transition-speed);
    /* WHY: Visual indicator for expandable items */
}

.has-submenu.active>a::after {
    transform: rotate(180deg);
}

.has-submenu.active>.sidebar-submenu {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }

    to {
        opacity: 1;
        max-height: 500px;
    }
}

/* ========================================
   SIDEBAR FOOTER
   WHY: Sticky CTA button (e.g., "Register Free Business")
   ======================================== */

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--menu-border-color);
    text-align: center;
    flex-shrink: 0;
    background: #fff;
    /* WHY background: Ensures contrast over scrolled content */
}

/* ========================================
   HEADER HIDING ON SCROLL
   WHY: Scroll down = header fully hidden; scroll up = header visible.
   Uses transform so full height is hidden on all devices (no fixed px).
   ======================================== */

#header {
    transition: transform var(--menu-transition-speed) var(--menu-transition-ease);
    /* WHY transform: Hides entire header regardless of height; no layout shift */
}

#header.hide-header {
    transform: translateY(-100%);
    /* WHY -100%: Entire header moves off-screen on all viewports */
}

/* ========================================
   MOBILE: FIXED HEADER HEIGHT ON SCROLL
   WHY: User requirement - header height must not change when scrolling on mobile
   ======================================== */

@media (max-width: 991px) {
    #header .header-body,
    #header .header-container {
        min-height: 72px;
        /* WHY: Keeps bar height constant; logo row + padding */
    }

    #header .header-row {
        min-height: 72px;
    }
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

/* Hide desktop-only elements on mobile */
@media (max-width: 991px) {
    .desktop-only {
        display: none !important;
    }
}

/* Hide mobile triggers on desktop */
@media (min-width: 992px) {
    .mobile-trigger {
        display: none !important;
    }

    /* Desktop dropdown minimum width */
    #header .header-nav-main nav>ul>li.dropdown .dropdown-menu {
        min-width: 150px;
    }
}

/* ========================================
   MISC FIXES
   ======================================== */

/* Fix angle-down icon display */
.fa-angle-down::before {
    content: "\f107";
}

/* Header column alignment */
#header .header-column {
    display: block;
    align-self: center;
}

/* Badge indicator for logged-in user */
.dot-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS
   ======================================== */

/* Skip to content link (for screen readers) */
.skip-to-content {
    position: absolute;
    left: -9999px;
    z-index: 999999;
    padding: 1em;
    background: #000;
    color: #fff;
    text-decoration: none;
}

.skip-to-content:focus {
    left: 50%;
    transform: translateX(-50%);
    top: 0;
}

/* Focus visible for keyboard navigation */
@supports selector(:focus-visible) {
    .sidebar-nav a:focus {
        outline: none;
    }

    .sidebar-nav a:focus-visible {
        outline: 2px solid var(--menu-primary-color);
        outline-offset: -2px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    .mobile-sidebar {
        border: 2px solid currentColor;
    }

    .sidebar-nav li {
        border-bottom-width: 2px;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {

    .mobile-sidebar,
    .sidebar-overlay,
    #header,
    .close-btn,
    .sidebar-nav li a,
    .has-submenu>a::after,
    .sidebar-submenu {
        transition: none;
        animation: none;
    }
}

/* ========================================
   PRINT STYLES
   WHY: Don't print navigation elements
   ======================================== */

@media print {
    .mobile-sidebar,
    .sidebar-overlay,
    .mobile-trigger {
        display: none !important;
    }
}
