/* Chanel-Style Navbar CSS */

/* Root Variables */
:root {
    --chanel-black: #1F1F1F;
    --chanel-white: #ffffff;
    --chanel-gray: #9D9387;
    --chanel-dark-gray: #9D9387;
    --chanel-light-gray: #ffffff;
    --chanel-border: 1px solid rgba(157, 147, 135, 0.3);
    --chanel-shadow: 0 2px 10px rgba(31, 31, 31, 0.1);
    --chanel-font-primary: 'Poppins', 'Tajawal', sans-serif;
}

/* Loading Screen */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--chanel-white);
    z-index: 10000; /* Higher than navbar */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    opacity: 1;
    visibility: visible;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: none !important;
}

.loading-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-logo img {
    width: 100%;
    max-width: 220px;
    height: auto;
}

/* Main Navbar - Clean Implementation */
.chanel-navbar {
    background: var(--chanel-white);
    border-bottom: var(--chanel-border);
    box-shadow: var(--chanel-shadow);
    padding: 0;
    
    /* Fixed positioning with high z-index */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1050; /* Bootstrap modal backdrop is 1040, dropdown is 1000 */
    
    /* Smooth transitions */
    transition: top 0.4s ease-in-out, transform 0.4s ease-in-out;
    overflow: visible;
}

/* Hidden state - slide up */
.chanel-navbar.navbar-hidden {
    top: -100px; /* Adjust based on your navbar height */
    transform: translateY(-100%);
}

/* Visible state - normal position */
.chanel-navbar.navbar-visible {
    top: 0;
    transform: translateY(0);
}

/* Ensure smooth transitions on all states */
.chanel-navbar.navbar-transitioning {
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Body padding to prevent content from hiding behind fixed navbar */
body {
    padding-top: 0 !important; /* Reset any conflicting padding */
    margin-top: 80px; /* Use margin instead of padding for better compatibility */
    transition: margin-top 0.3s ease;
}

/* Prevent layout shift when navbar height changes */
.chanel-navbar-spacer {
    height: 80px; /* Same as navbar height */
    flex-shrink: 0;
}

/* Performance optimizations */
.chanel-navbar * {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .chanel-navbar.navbar-hidden {
        top: -80px; /* Adjust for mobile navbar height */
    }
    
    body {
        margin-top: 70px !important; /* Smaller margin for mobile */
    }

    .chanel-brand-logo {
        height: 70px;
        max-width: 240px;
    }

    .chanel-brand-logo-mobile {
        height: 48px;
        max-width: 180px;
    }

    .chanel-brand-logo-sidebar {
        height: 58px;
    }

    .chanel-brand-logo-loading {
        height: 80px;
    }
}

@media (max-width: 575.98px) {
    body {
        margin-top: 60px !important; /* Even smaller for very small screens */
    }
    
    .chanel-navbar.navbar-hidden {
        top: -70px;
    }

    .chanel-brand-logo {
        height: 56px;
        max-width: 200px;
    }

    .chanel-brand-logo-mobile {
        height: 44px;
    }

    .chanel-brand-logo-loading {
        height: 70px;
    }
}

/* Desktop Navigation */
.chanel-nav-desktop {
    flex-direction: column;
    padding: 0;
    position: relative;
    z-index: 1040;
}

/* Remove focus outline from navbar links */
.chanel-nav-link:focus,
.chanel-nav-link:active,
.chanel-nav-link:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Remove outline from dropdown toggles */
.chanel-nav-item .dropdown-toggle:focus,
.chanel-nav-item .dropdown-toggle:active,
.chanel-nav-item .dropdown-toggle:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Remove outline from icon links */
.chanel-icon-link:focus,
.chanel-icon-link:active,
.chanel-icon-link:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Remove outline from mobile navbar elements */
.chanel-mobile-menu-btn:focus,
.chanel-mobile-menu-btn:active,
.chanel-mobile-menu-btn:focus-visible,
.chanel-sidebar-item:focus,
.chanel-sidebar-item:active,
.chanel-sidebar-item:focus-visible,
.chanel-brand:focus,
.chanel-brand:active,
.chanel-brand:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Remove outline from all navbar buttons and links */
.chanel-navbar button:focus,
.chanel-navbar button:active,
.chanel-navbar button:focus-visible,
.chanel-navbar a:focus,
.chanel-navbar a:active,
.chanel-navbar a:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Remove outline from dropdown items */
.chanel-dropdown-item:focus,
.chanel-dropdown-item:active,
.chanel-dropdown-item:focus-visible,
.dropdown-item:focus,
.dropdown-item:active,
.dropdown-item:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Remove default browser button styles */
.chanel-navbar button {
    border: none;
    background: none;
    padding: 0;
    margin: 0;
}

.chanel-navbar button::-moz-focus-inner {
    border: 0;
}

/* Top Row - Logo and Icons */
.chanel-nav-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.2rem 2rem;
    min-height: 60px;
    border-bottom: 1px solid rgba(157, 147, 135, 0.2);
    position: relative;
    z-index: 1050;
    background: var(--chanel-white);
}

.chanel-nav-top-left {
    flex: 1;
}

.chanel-nav-top-center {
    flex: 0 0 auto;
}

.chanel-nav-top-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

/* Bottom Row - Menu Items */
.chanel-nav-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2rem;
    height: 0;
    min-height: 0;
    position: relative;
    z-index: 1045;
    background: transparent;
    overflow: hidden;
    
    /* Hide by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* Show bottom navigation on navbar hover */
.chanel-navbar:hover .chanel-nav-bottom,
.chanel-nav-bottom:hover,
.chanel-nav-bottom.navbar-hovered {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    background: var(--chanel-white);
    height: auto;
    min-height: 50px;
    padding: 1rem 2rem;
    overflow: visible;
}

/* Keep bottom navigation visible when hovering over dropdowns */
.chanel-nav-bottom:hover,
.chanel-nav-bottom .dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    background: var(--chanel-white);
    height: auto;
    min-height: 50px;
    padding: 1rem 2rem;
    overflow: visible;
}

/* Extended hover area for better UX */
.chanel-navbar::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 10px;
    background: transparent;
    z-index: 1044;
    pointer-events: auto;
}

.chanel-nav-left,
.chanel-nav-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.chanel-nav-right {
    justify-content: flex-end;
}

.chanel-nav-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    /* Direction will be set by JavaScript based on language */
}

.navbar-tabs-list {
    transition: all 0.3s ease;
    /* Direction controlled by JavaScript based on language */
    /* Arabic = RTL (right to left), English = LTR (left to right) */
}

/* Explicit direction classes */
.navbar-tabs-list.navbar-rtl {
    direction: rtl !important;
    flex-direction: row !important;
}

.navbar-tabs-list.navbar-ltr {
    direction: ltr !important;
    flex-direction: row !important;
}

/* Fallback for dir attribute */
.navbar-tabs-list[dir="rtl"] {
    direction: rtl !important;
    flex-direction: row !important;
}

.navbar-tabs-list[dir="ltr"] {
    direction: ltr !important;
    flex-direction: row !important;
}

.chanel-nav-item {
    margin: 0 1.5rem;
    position: relative;
}

/* Ensure dropdown positioning */
.chanel-nav-item.dropdown {
    position: relative;
}

.chanel-nav-item .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1060;
    margin-top: 0;
}

.chanel-nav-link {
    font-family: var(--chanel-font-primary);
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--chanel-black);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.5rem 0;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
}

.chanel-nav-link:hover,
.chanel-nav-link.active {
    color: var(--chanel-dark-gray);
    text-decoration: none;
}

.chanel-nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--chanel-black);
    transition: width 0.3s ease;
}

.chanel-nav-link:hover::after,
.chanel-nav-link.active::after {
    width: 100%;
}

/* Center Logo */
.chanel-logo-center {
    flex: 0 0 auto;
    text-align: center;
}

.chanel-brand {
    text-decoration: none;
    color: var(--chanel-black);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
}

.chanel-brand:hover {
    color: var(--chanel-black);
    text-decoration: none;
    transform: translateY(-2px);
}

.chanel-brand-logo {
    display: block;
    height: 90px;
    width: auto;
    max-width: 300px;
    margin: 0 auto;
}

.chanel-brand-logo-mobile {
    height: 56px;
    max-width: 200px;
}

.chanel-brand-logo-sidebar {
    height: 64px;
    max-width: 220px;
}

.chanel-brand-logo-loading {
    height: 100px;
    max-width: 320px;
}

.chanel-brand-text {
    font-family: var(--chanel-font-primary);
    font-size: 1.8rem;
    font-weight: 300;
    letter-spacing: 6px;
    line-height: 1;
}

.chanel-brand-subtitle {
    font-family: var(--chanel-font-primary);
    font-size: 0.7rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-top: 2px;
    opacity: 0.7;
}

/* Icon Links */
.chanel-icon-link {
    font-size: 1rem;
    padding: 0.5rem;
}

.chanel-icon-link::after {
    display: none;
}

.chanel-cart-link {
    position: relative;
}

.chanel-cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--chanel-black);
    color: var(--chanel-white);
    border-radius: 50%;
    font-size: 0.7rem;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

/* Dropdown Menus */
.chanel-dropdown-menu {
    border: var(--chanel-border);
    box-shadow: var(--chanel-shadow);
    border-radius: 0;
    padding: 0.5rem 0;
    min-width: 200px;
    position: absolute;
    z-index: 1060;
    background: var(--chanel-white);
    top: 100%;
    left: 0;
    margin-top: 0;
}

.chanel-dropdown-item {
    font-family: var(--chanel-font-primary);
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--chanel-black);
    padding: 0.75rem 1.5rem;
    transition: all 0.3s ease;
    text-transform: capitalize;
}

.chanel-dropdown-item:hover {
    background: var(--chanel-gray);
    color: var(--chanel-black);
}

/* Mobile Navigation */
.chanel-nav-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 1rem;
}

.chanel-mobile-menu-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chanel-hamburger-line {
    width: 20px;
    height: 1px;
    background: var(--chanel-black);
    margin: 2px 0;
    transition: all 0.3s ease;
}

.chanel-mobile-menu-btn:hover .chanel-hamburger-line {
    background: var(--chanel-dark-gray);
}

.chanel-mobile-logo {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chanel-mobile-icons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chanel-mobile-icon {
    color: var(--chanel-black);
    text-decoration: none;
    position: relative;
    padding: 0.5rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.chanel-mobile-icon:hover {
    color: var(--chanel-dark-gray);
    text-decoration: none;
}

.chanel-mobile-cart-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--chanel-black);
    color: var(--chanel-white);
    border-radius: 50%;
    font-size: 0.6rem;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

/* Mobile Sidebar */
.chanel-mobile-sidebar {
    width: 100%;
    max-width: 320px;
}

.chanel-sidebar-header {
    background: #1F1F1F;
    color: var(--chanel-white);
    padding: 1.5rem;
    border-bottom: none;
}

.chanel-sidebar-logo {
    display: flex;
    justify-content: center;
    align-items: center;
}

.chanel-sidebar-logo .chanel-brand-logo-sidebar {
    max-width: 200px;
}

.chanel-close-btn {
    background: none;
    border: none;
    color: var(--chanel-white);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chanel-close-btn:hover {
    color: #9D9387;
}

.chanel-sidebar-body {
    background: var(--chanel-white);
    padding: 0;
}

.chanel-sidebar-nav {
    padding: 1rem 0;
}

.chanel-sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    color: var(--chanel-black);
    text-decoration: none;
    font-family: var(--chanel-font-primary);
    font-size: 0.95rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(157, 147, 135, 0.2);
}

.chanel-sidebar-item:hover {
    background: var(--chanel-gray);
    color: var(--chanel-black);
    text-decoration: none;
    transform: translateX(5px);
}

.chanel-sidebar-item.active {
    background: #1F1F1F;
    color: var(--chanel-white);
    font-weight: 500;
}

.chanel-sidebar-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.chanel-dropdown-toggle[aria-expanded="true"] .chanel-sidebar-arrow {
    transform: rotate(180deg);
}

.chanel-sidebar-submenu {
    background: var(--chanel-gray);
    border-left: 3px solid var(--chanel-black);
}

.chanel-sidebar-submenu-item {
    display: block;
    padding: 0.75rem 2.5rem;
    color: var(--chanel-dark-gray);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 400;
    text-transform: capitalize;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(157, 147, 135, 0.1);
}

.chanel-sidebar-submenu-item:hover {
    background: rgba(157, 147, 135, 0.2);
    color: var(--chanel-black);
    text-decoration: none;
    transform: translateX(3px);
}

.chanel-sidebar-divider {
    margin: 1rem 0;
    border-color: rgba(157, 147, 135, 0.3);
}

.chanel-sidebar-user-info {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--chanel-gray);
    color: var(--chanel-black);
    font-weight: 500;
    border-bottom: 1px solid rgba(157, 147, 135, 0.3);
}

.chanel-sidebar-user-info i {
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

.chanel-logout {
    color: #dc3545 !important;
}

.chanel-logout:hover {
    background: #f8d7da !important;
    color: #721c24 !important;
}

/* Menu Items in Bottom Row */
.chanel-nav-menu {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3rem;
    width: 100%;
}

.chanel-nav-menu .chanel-nav-list {
    gap: 3rem;
}

/* Smooth transitions for menu items */
.chanel-nav-bottom .chanel-nav-item {
    transition: all 0.3s ease;
    transform: translateY(0);
}

/* Staggered animation for menu items */
.chanel-navbar:hover .chanel-nav-bottom .chanel-nav-item:nth-child(1) {
    transition-delay: 0.1s;
}

.chanel-navbar:hover .chanel-nav-bottom .chanel-nav-item:nth-child(2) {
    transition-delay: 0.15s;
}

.chanel-navbar:hover .chanel-nav-bottom .chanel-nav-item:nth-child(3) {
    transition-delay: 0.2s;
}

.chanel-navbar:hover .chanel-nav-bottom .chanel-nav-item:nth-child(4) {
    transition-delay: 0.25s;
}

.chanel-navbar:hover .chanel-nav-bottom .chanel-nav-item:nth-child(5) {
    transition-delay: 0.3s;
}

/* Search functionality */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(238, 234, 225, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1055; /* Above navbar but below loading */
    display: none;
    align-items: center;
    justify-content: center;
}

.search-container {
    max-width: 600px;
    width: 90%;
    text-align: center;
}

.search-input {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.5rem;
    border: none;
    border-bottom: 2px solid var(--chanel-black);
    background: transparent;
    text-align: center;
    outline: none;
    font-family: var(--chanel-font-primary);
    letter-spacing: 2px;
}

.search-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    font-size: 2rem;
    color: var(--chanel-black);
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-close:hover {
    transform: rotate(90deg);
}

/* Responsive Adjustments */
@media (max-width: 991.98px) {
    .chanel-navbar {
        min-height: 60px;
    }
    
    .chanel-nav-desktop {
        display: none !important;
    }
}

@media (max-width: 575.98px) {
    .chanel-nav-mobile {
        padding: 0 0.75rem;
    }
    
    .chanel-mobile-logo .chanel-brand-text {
        font-size: 1.2rem;
        letter-spacing: 3px;
    }
}

/* Animation for loading */
@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

.loading-overlay.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

/* Smooth scrolling compensation for fixed navbar */
html {
    scroll-padding-top: 60px; /* Only top row visible by default */
    transition: scroll-padding-top 0.4s ease;
}

/* Adjust scroll padding when navbar is hovered (expanded) */
.chanel-navbar:hover ~ * {
    scroll-margin-top: 110px;
}

@media (max-width: 991.98px) {
    html {
        scroll-padding-top: 60px;
    }
}


/* Additional Chanel-style refinements */
.chanel-nav-link.dropdown-toggle::after {
    display: none;
}

/* No padding needed since navbar will expand on hover */

/* Override Bootstrap dropdown positioning issues */
.chanel-nav-item .dropdown-menu.show {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1060;
    opacity: 1;
    visibility: visible;
}

/* Ensure dropdowns don't get cut off */
.chanel-nav-desktop {
    overflow: visible;
}

.chanel-navbar {
    overflow: visible;
}

/* Fix for mobile to prevent issues */
@media (max-width: 991.98px) {
    .chanel-nav-bottom {
        display: none !important;
    }
    
    /* No body padding needed on mobile */
}

.chanel-nav-item .dropdown-toggle::after {
    border: none;
    content: '';
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 3px solid currentColor;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Hover effects for better UX */
.chanel-mobile-menu-btn:hover {
    transform: scale(1.05);
}

.chanel-brand:hover .chanel-brand-text {
    letter-spacing: 8px;
}

.chanel-brand:hover .chanel-brand-subtitle {
    opacity: 1;
}

/* Focus states for accessibility */
.chanel-nav-link:focus,
.chanel-mobile-icon:focus,
.chanel-sidebar-item:focus {
    outline: 2px solid var(--chanel-black);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .chanel-navbar,
    .chanel-mobile-sidebar {
        display: none !important;
    }
}
