/* ══════════════════════════════════════
   Navbar Component
   ══════════════════════════════════════ */

.navbar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    /* Transparent so children (dropdowns) are not clipped by backdrop-filter */
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--navbar-shadow);
    height: var(--navbar-height);
    transition: all var(--transition-base);
    overflow: visible;
}

/* Backdrop on a pseudo-element so it doesn't clip notification/user dropdowns */
.navbar::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: var(--navbar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.navbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: var(--container-xl);
    margin-inline: auto;
    padding-inline: var(--space-4);
    gap: var(--space-4);
}

/* ── Logo ── */
.navbar__logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    flex-shrink: 0;
}

.navbar__logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: var(--text-xl);
    font-weight: 800;
    box-shadow: var(--shadow-glow);
}

.navbar__logo-text {
    font-size: var(--text-xl);
    font-weight: 800;
    color: var(--primary-700);
    letter-spacing: -0.5px;
}

[data-theme="dark"] .navbar__logo-text {
    color: var(--primary-300);
}

/* ── Search ── */
.navbar__search {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.navbar__search-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-full);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-fast);
}

[dir="rtl"] .navbar__search-input {
    padding-right: var(--space-12);
}

[dir="ltr"] .navbar__search-input {
    padding-left: var(--space-12);
}

.navbar__search-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

[dir="rtl"] .navbar__search-icon { right: var(--space-4); }
[dir="ltr"] .navbar__search-icon { left: var(--space-4); }

.navbar__search-input:focus {
    background: var(--bg-card);
    border-color: var(--primary-300);
    box-shadow: 0 0 0 4px var(--input-focus-ring);
}

/* ── Actions ── */
.navbar__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
    overflow: visible;
    position: relative;
    z-index: calc(var(--z-sticky) + 5);
}

.navbar__action-btn {
    position: relative;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.navbar__action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary-500);
}

.navbar__action-btn svg {
    width: 22px;
    height: 22px;
}

/* ── Badge (Cart count / Notifications) ── */
.navbar__badge {
    position: absolute;
    top: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--badge-bg);
    color: var(--badge-text);
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    animation: scaleIn 0.3s var(--transition-spring);
}

[dir="rtl"] .navbar__badge { left: 2px; }
[dir="ltr"] .navbar__badge { right: 2px; }

/* ── Language Switcher ── */
.lang-switcher {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    padding: 3px;
    gap: 2px;
}

.lang-switcher__btn {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.lang-switcher__btn:hover {
    color: var(--text-primary);
}

.lang-switcher__btn.active {
    background: var(--primary-500);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

/* ── User Menu ── */
.navbar__user-menu {
    position: relative;
    z-index: calc(var(--z-sticky) + 10);
}

.navbar__user-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

.navbar__user-btn:hover {
    background: var(--primary-50);
}

.navbar__user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: var(--text-sm);
    font-weight: 700;
}

/* ── Dropdown Menu ── */
.dropdown-menu {
    position: absolute;
    top: calc(100% + var(--space-2));
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: var(--space-2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
    /* Above sticky navbar siblings (secondary categories) and page content */
    z-index: calc(var(--z-sticky) + 10);
}

[dir="rtl"] .dropdown-menu { left: 0; }
[dir="ltr"] .dropdown-menu { right: 0; }

.dropdown-menu.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu__item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    font-family: inherit;
}

.dropdown-menu__item:hover {
    background: var(--bg-tertiary);
    color: var(--primary-600);
}

.dropdown-menu__item svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.dropdown-menu__divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--space-2) 0;
}

.dropdown-menu__item--danger {
    color: var(--error);
}

.dropdown-menu__item--danger svg {
    color: var(--error);
}

.notif-item {
    background: var(--bg-card);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.notif-item:hover {
    background: var(--bg-card-hover);
}

[data-theme="dark"] .notif-item {
    background: hsl(0, 0%, 11%) !important;
    color: hsl(0, 0%, 95%) !important;
    border-bottom-color: hsl(0, 0%, 22%) !important;
}

[data-theme="dark"] .notif-item:hover {
    background: hsl(0, 0%, 15%) !important;
}

[data-theme="dark"] .notif-item > div:first-child {
    background: hsl(25, 80%, 28%) !important;
}

/* ── Mobile Menu ── */
.navbar__mobile-toggle {
    display: none;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    cursor: pointer;
}

@media (max-width: 768px) {
    .navbar__inner {
        gap: var(--space-2);
        padding-inline: var(--space-3);
        flex-wrap: nowrap;
        /* Keep visible so notification/user dropdowns are not clipped behind the hero */
        overflow: visible;
    }

    .navbar__search {
        display: none;
    }

    .navbar__mobile-toggle {
        display: flex;
    }

    .lang-switcher {
        display: none;
    }

    .hide-on-mobile {
        display: none !important;
    }

    /* Hide theme toggle on mobile - accessible from mobile menu */
    #theme-toggle-btn {
        display: none;
    }

    /* Prevent logo text from taking too much space */
    .navbar__logo-text {
        font-size: 11px; /* Forced small size */
        display: block;
        white-space: nowrap;
    }

    .navbar__logo-icon {
        width: 34px;
        height: 34px;
        font-size: var(--text-base);
    }

    .navbar__action-btn {
        width: 36px;
        height: 36px;
    }

    .navbar__action-btn svg {
        width: 20px;
        height: 20px;
    }

    /* Fix dropdown menu overflowing on mobile */
    .navbar .dropdown-menu {
        position: fixed !important;
        top: calc(var(--navbar-height, 72px) + var(--space-2, 8px)) !important;
        left: var(--space-4, 16px) !important;
        right: var(--space-4, 16px) !important;
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
    }

    /* Prevent navbar from overflowing horizontally */
    .navbar__user-btn span {
        display: none;
    }
    .navbar__user-btn {
        padding: var(--space-1);
    }
}

/* ── Secondary Navbar (Categories) ── */
.navbar__secondary {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    padding: 0 var(--space-4);
}

.navbar__categories {
    display: flex;
    gap: var(--space-6);
    align-items: center;
    max-width: var(--container-xl);
    margin: 0 auto;
    height: 48px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.navbar__categories::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.navbar__category-link {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: var(--text-sm);
    text-decoration: none;
    padding: var(--space-2) 0;
    position: relative;
    transition: color var(--transition-fast);
}

.navbar__category-link:hover {
    color: var(--primary-500);
}

/* Add a bottom border on hover */
.navbar__category-link::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary-500);
    transform: scaleX(0);
    transition: transform var(--transition-fast);
}

.navbar__category-link:hover::after {
    transform: scaleX(1);
}

.navbar__category-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
}
