/**
 * Custom Navbar Styles for Ghost Gym
 * Slim top navigation bar following Sneat template patterns
 */

/* ============================================
   NAVBAR BASE STYLES
   ============================================ */

/* Base navbar - using attribute selector for higher specificity over Sneat */
.layout-navbar[class] {
    height: 60px;
    padding: 0.5rem 1.5rem;
    box-shadow: 0 2px 6px 0 rgba(67, 89, 113, 0.12);
    z-index: 1000;
    position: relative;
    background-color: var(--bs-body-bg);
    transition: background-color 0.2s ease;
    width: 100%;
    max-width: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Override navbar-detached class that adds margins */
.layout-navbar[class].navbar-detached {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
}

/* Remove container constraints for full width */
.layout-navbar[class] .container-xxl {
    max-width: none;
    width: 100%;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

/* ============================================
   LEFT SECTION: HAMBURGER + PAGE TITLE
   ============================================ */

.navbar-nav-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Hamburger Menu Toggle */
.layout-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    color: var(--bs-body-color);
}

.layout-menu-toggle:hover {
    background-color: rgba(67, 89, 113, 0.04);
    transform: scale(1.05);
}

.layout-menu-toggle:active {
    transform: scale(0.98);
}

.layout-menu-toggle i {
    font-size: 1.5rem;
    line-height: 1;
}

/* Page Title */
.navbar-nav-left h5 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--bs-heading-color);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-nav-left .bx {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* ============================================
   RIGHT SECTION: UTILITY ICONS
   ============================================ */

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.navbar-nav .nav-item {
    display: flex;
    align-items: center;
}

.navbar-nav .nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    color: var(--bs-body-color);
    text-decoration: none;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(67, 89, 113, 0.04);
    color: var(--bs-primary);
}

.navbar-nav .nav-link:active {
    transform: scale(0.95);
}

/* Theme Toggle Icon */
.style-switcher-toggle i {
    font-size: 1.375rem;
    transition: transform 0.3s ease;
}

.style-switcher-toggle:hover i {
    transform: rotate(20deg);
}

/* ============================================
   USER AVATAR & DROPDOWN
   ============================================ */

/* Avatar Base */
.avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.avatar i {
    font-size: 2rem;
    color: var(--bs-body-color);
}

/* Avatar Initial (for signed-in users) */
.avatar-initial {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1rem;
    font-weight: 600;
    color: var(--bs-primary);
    background-color: rgba(var(--bs-primary-rgb), 0.12);
    border-radius: 50%;
    text-transform: uppercase;
}

/* Override Bootstrap's bg-label-primary for avatar - Soft Clay palette */
.avatar-initial.bg-label-primary {
    background-color: rgba(var(--gs-primary-rgb), 0.12) !important;
    color: var(--gs-primary) !important;
}

[data-bs-theme="dark"] .avatar-initial.bg-label-primary {
    background-color: rgba(var(--gs-primary-rgb), 0.15) !important;
    color: var(--gs-primary-dark) !important;
}

/* Online Status Indicator */
.avatar-online::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border: 2px solid var(--bs-body-bg);
    border-radius: 50%;
    background-color: var(--gs-success);
}

/* User Dropdown Menu */
.dropdown-menu {
    min-width: 240px;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    border: 1px solid rgba(67, 89, 113, 0.12);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(67, 89, 113, 0.15);
}

.dropdown-item {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    color: var(--bs-body-color);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.dropdown-item:hover {
    background-color: rgba(67, 89, 113, 0.04);
    color: var(--bs-primary);
}

.dropdown-item i {
    font-size: 1.125rem;
    vertical-align: middle;
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-top: 1px solid rgba(67, 89, 113, 0.12);
}

/* User Info in Dropdown Header */
.dropdown-item .avatar {
    width: 38px;
    height: 38px;
}

.dropdown-item .avatar-initial {
    font-size: 0.9375rem;
}

.dropdown-item .fw-medium {
    font-size: 0.9375rem;
    color: var(--bs-heading-color);
}

.dropdown-item .text-muted {
    font-size: 0.8125rem;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Tablet and below */
@media (max-width: 991.98px) {
    .layout-navbar {
        height: 56px;
        padding: 0.5rem 1rem;
    }
    
    .navbar-nav .nav-link {
        min-width: 36px;
        height: 36px;
        padding: 0.375rem;
    }
    
    .layout-menu-toggle {
        width: 36px;
        height: 36px;
    }
}

/* Mobile */
@media (max-width: 767.98px) {
    .layout-navbar[class] {
        padding: 0.5rem 1rem;
        height: 56px;
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
    }

    .layout-navbar[class].navbar-detached {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
    }

    .layout-navbar[class] .container-xxl {
        padding: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .navbar-nav-left h5 {
        font-size: 0.95rem;
        max-width: 180px;
    }
    
    .navbar-nav-left .bx {
        font-size: 1.125rem;
    }
    
    .navbar-nav {
        gap: 0.125rem;
    }
    
    .navbar-nav .nav-link {
        min-width: 32px;
        height: 32px;
        padding: 0.25rem;
    }
    
    .layout-menu-toggle {
        width: 32px;
        height: 32px;
    }
    
    .layout-menu-toggle i {
        font-size: 1.375rem;
    }
    
    .avatar {
        width: 32px;
        height: 32px;
    }
    
    .avatar i {
        font-size: 1.75rem;
    }
    
    .avatar-online::before {
        width: 10px;
        height: 10px;
    }
}

/* Small mobile */
@media (max-width: 575.98px) {
    .layout-navbar .navbar-nav .me-2,
    .layout-navbar .navbar-nav .me-xl-3 {
        margin-right: 0.25rem;
    }
    
    .navbar-nav-left h5 {
        font-size: 0.875rem;
        max-width: 140px;
    }
    
    .navbar-nav-left .bx {
        font-size: 1rem;
    }
}

/* ============================================
   DARK MODE ADJUSTMENTS
   ============================================ */

[data-bs-theme="dark"] .layout-navbar {
    box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .layout-menu-toggle:hover,
[data-bs-theme="dark"] .navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .dropdown-menu {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .dropdown-divider {
    border-top-color: rgba(255, 255, 255, 0.12);
}

/* ============================================
   LAYOUT INTEGRATION
   ============================================ */

/* Ensure menu appears above navbar when open */
.layout-menu {
    z-index: 1100 !important;
}

/* Ensure navbar sits above content but below menu */
.layout-page {
    position: relative;
    width: 100%;
}

/* Adjust content wrapper to account for navbar */
.layout-navbar + .content-wrapper {
    padding-top: 0;
}

/* Ensure layout container doesn't constrain navbar */
.layout-container {
    width: 100%;
}

/* Smooth transitions when menu toggles */
.layout-navbar,
.layout-menu-toggle {
    transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Focus states for keyboard navigation */
.layout-menu-toggle:focus-visible,
.navbar-nav .nav-link:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .layout-navbar,
    .layout-menu-toggle,
    .navbar-nav .nav-link,
    .style-switcher-toggle i {
        transition: none;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Hide arrow on dropdown toggle */
.hide-arrow::after {
    display: none !important;
}

/* Ensure proper spacing */
.navbar-nav-left .d-flex {
    gap: 0.75rem;
}

/* Text truncation for long titles on larger screens */
@media (min-width: 992px) {
    .navbar-nav-left h5 {
        max-width: 400px;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .navbar-nav-left h5 {
        max-width: 250px;
    }
}

/* ============================================
   NAVBAR SEARCH CONTAINER
   ============================================ */

.navbar-search-container {
    display: flex;
    align-items: center;
    margin: 0 1rem;
    flex: 0 1 auto;
}

/* ============================================
   DESKTOP SEARCH (Always Visible)
   ============================================ */

.navbar-search-desktop {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 350px;
    max-width: 350px;
}

.navbar-search-desktop .search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 0.375rem 0.75rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.navbar-search-desktop .search-input-wrapper:focus-within {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

.navbar-search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px; /* Prevent zoom on iOS */
    line-height: 1.5;
    padding: 0;
    padding-right: 40px; /* Space for close button */
    outline: none;
    color: var(--bs-body-color);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.navbar-search-input::placeholder {
    color: var(--bs-secondary);
    opacity: 0.5;
}

.navbar-search-input:focus {
    outline: none;
}

.search-icon {
    font-size: 1.375rem;
    color: var(--bs-body-color);
    flex-shrink: 0;
    opacity: 0.7;
}

.search-clear {
    opacity: 0.6;
    transition: opacity 0.2s ease;
    padding: 0.25rem;
}

.search-clear:hover {
    opacity: 1;
}

.search-results-count {
    font-size: 13px;
    color: var(--bs-secondary);
    text-align: center;
    min-height: 1rem;
    padding: 0;
    opacity: 0.8;
}

/* ============================================
   MOBILE SEARCH TOGGLE (Icon Button)
   ============================================ */

.navbar-search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    color: var(--bs-body-color);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.navbar-search-toggle:hover {
    background: rgba(67, 89, 113, 0.04);
}

.navbar-search-toggle:active {
    transform: scale(0.95);
    background: rgba(67, 89, 113, 0.08);
}

.navbar-search-toggle i {
    font-size: 1.5rem;
}

/* ============================================
   MOBILE SEARCH (Expanded State)
   ============================================ */

.navbar-search-mobile {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
    padding: 16px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-search-mobile.active {
    transform: translateY(0);
}

.navbar-search-mobile .search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    padding: 12px 14px;
    flex: 1;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    position: relative;
}

.navbar-search-mobile .search-input-wrapper:focus-within {
    border-color: var(--bs-border-color);
    background: rgba(var(--bs-body-color-rgb), 0.02);
}

.navbar-search-close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: var(--bs-secondary);
    cursor: pointer;
    transition: opacity 0.2s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    opacity: 0.6;
}

.navbar-search-close:hover {
    opacity: 1;
    background: rgba(67, 89, 113, 0.06);
}

.navbar-search-close:active {
    transform: translateY(-50%) scale(0.95);
    background: rgba(67, 89, 113, 0.1);
}

.navbar-search-close i {
    font-size: 1.25rem;
}

/* Backdrop overlay - hidden by default, can be enabled if needed */
.navbar-search-backdrop {
    display: none;
}

/* Don't prevent body scroll - allow seeing results */
body.mobile-search-active {
    /* overflow: hidden; - removed to allow scrolling */
}

/* ============================================
   RESPONSIVE BREAKPOINTS FOR SEARCH
   ============================================ */

/* Tablet */
@media (min-width: 768px) and (max-width: 1199px) {
    .navbar-search-desktop {
        width: 250px;
        max-width: 250px;
    }
}

/* Small tablet */
@media (min-width: 768px) and (max-width: 991px) {
    .navbar-search-desktop {
        width: 200px;
        max-width: 200px;
    }
}

/* Mobile adjustments */
@media (max-width: 767.98px) {
    .navbar-search-container {
        margin: 0 0.5rem;
    }
    
    .navbar-search-mobile {
        /* Compact size - just the search bar */
        padding: 12px;
    }
}

/* Small mobile devices */
@media (max-width: 375px) {
    .navbar-search-mobile {
        padding: 10px 12px;
    }
    
    .navbar-search-mobile .search-input-wrapper {
        padding: 10px 12px;
    }
}

/* ============================================
   DARK MODE FOR SEARCH
   ============================================ */

[data-bs-theme="dark"] .navbar-search-mobile {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

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

[data-bs-theme="dark"] .navbar-search-close:hover {
    background: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] .navbar-search-backdrop {
    background: rgba(0, 0, 0, 0.6);
}

/* ============================================
   ACCESSIBILITY FOR SEARCH
   ============================================ */

.navbar-search-toggle:focus-visible,
.navbar-search-close:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .navbar-search-desktop .search-input-wrapper,
    .navbar-search-toggle,
    .navbar-search-close,
    .search-clear {
        transition: none;
    }
}