/**
 * Header & Navigation Styles
 * Premium Islamic-themed navigation with dropdowns
 */

/* ==========================================
   TOPBAR
   ========================================== */
.topbar {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-blue) 100%);
    color: white;
    padding: 10px 0;
    font-size: 0.9rem;
}

.topbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.topbar-left, .topbar-right {
    display: flex;
    gap: 25px;
    align-items: center;
    flex-wrap: wrap;
}

.topbar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
}

.topbar-item i {
    color: var(--light-gold);
}

.topbar-item:hover {
    color: white;
}

/* ==========================================
   MAIN NAVIGATION
   ========================================== */
.navbar {
    background: white;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 900;
    transition: var(--transition-smooth);
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1001;
    /* Reserve space for the logo clickable area */
    width: 100px;
    height: 50px;
}

.navbar-brand img {
    height: 100px;
    width: 100px;
    object-fit: contain;
    transition: var(--transition-smooth);
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 1001;
}

.navbar-brand:hover img {
    transform: translateY(-50%) scale(1.05);
}

/* Navigation Menu */
.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 5px;
    align-items: center;
}

/* Hide menu by default on mobile - will be shown when .active is added */
@media (max-width: 992px) {
    .nav-menu {
        display: none !important;
    }
    
    .nav-menu.active {
        display: flex !important;
    }
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 20px;
    color: var(--primary-blue);
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition-fast);
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 20px;
    right: 20px;
    height: 2px;
    background: var(--primary-gold);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.nav-link:hover {
    color: var(--primary-gold);
    background: rgba(184, 115, 51, 0.05);
}

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

.nav-item.active > .nav-link {
    color: var(--primary-gold);
    background: rgba(184, 115, 51, 0.1);
}

/* Dropdown Icon */
.dropdown-icon {
    font-size: 0.75rem;
    margin-left: 3px;
    transition: transform 0.3s ease;
}

.nav-item.dropdown:hover .dropdown-icon {
    transform: rotate(180deg);
}

/* ==========================================
   DROPDOWN MENUS
   ========================================== */
.dropdown {
    position: relative;
}

.dropdown-menu {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 250px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(18, 46, 91, 0.15);
    padding: 10px 0;
    margin-top: 5px;
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    border: 2px solid rgba(184, 115, 51, 0.1);
}

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

.dropdown-menu .nav-item {
    display: block;
    width: 100%;
}

.dropdown-menu .nav-link {
    padding: 12px 20px;
    color: var(--primary-blue);
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dropdown-menu .nav-link::after {
    display: none;
}

.dropdown-menu .nav-link:hover {
    background: linear-gradient(90deg, rgba(184, 115, 51, 0.08), rgba(212, 175, 55, 0.05));
    color: var(--primary-gold);
    padding-left: 25px;
}

.dropdown-menu .nav-link i {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Nested Dropdowns (Sub-menus) */
.dropdown-menu .dropdown {
    position: relative;
}

.dropdown-menu .dropdown > .nav-link::before {
    content: '\f054';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.7rem;
    margin-left: auto;
    color: var(--primary-gold);
}

.dropdown-menu .dropdown-menu {
    left: 100%;
    top: 0;
    margin-top: 0;
    margin-left: 5px;
}

.dropdown-menu .dropdown:hover > .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Depth Styling */
.dropdown-menu.depth-1 {
    background: #f8f9fa;
}

.dropdown-menu.depth-2 {
    background: #f0f1f3;
}

/* ==========================================
   MOBILE NAVIGATION
   ========================================== */
.mobile-menu-toggle {
    display: none;
    background: linear-gradient(135deg, var(--primary-gold), var(--light-gold));
    border: none;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
    padding: 12px 16px;
    border-radius: 8px;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.mobile-menu-toggle:hover {
    background: linear-gradient(135deg, var(--primary-blue), var(--dark-blue));
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

@media (max-width: 992px) {
    .mobile-menu-toggle {
        display: block;
        z-index: 950;
        order: 3; /* Place hamburger menu last */
        margin-left: auto; /* Push to the right */
    }
    
    .navbar-brand {
        order: 1; /* Place logo first */
    }
    
    .nav-menu {
        order: 2; /* Place nav-menu between (but it's hidden anyway) */
    }
    
    .navbar-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 15px 0;
    }
    
    .nav-menu {
        position: fixed;
        top: 80px;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        flex-direction: column;
        align-items: stretch;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
        padding: 20px 0;
        gap: 0;
        overflow-y: auto;
        max-height: calc(100vh - 80px);
        z-index: 900;
    }
    
    .nav-menu.active {
        animation: slideDown 0.3s ease-out;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .nav-item {
        width: 100%;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }
    
    .nav-link {
        width: 100%;
        border-radius: 0;
        padding: 16px 30px;
        font-size: 1.05rem;
    }
    
    .nav-link::after {
        display: none;
    }
    
    .nav-link:hover {
        background: linear-gradient(90deg, rgba(184, 115, 51, 0.1), transparent);
        padding-left: 35px;
    }
    
    /* Mobile Dropdowns - Override desktop hover behavior */
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        border-radius: 0;
        background: linear-gradient(135deg, rgba(18, 46, 91, 0.02), rgba(184, 115, 51, 0.02));
        margin-top: 0;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-out;
    }
    
    .dropdown.active > .dropdown-menu {
        max-height: 500px;
    }
    
    /* Override desktop hover on mobile */
    .dropdown:hover > .dropdown-menu {
        max-height: 0;
    }
    
    .dropdown.active:hover > .dropdown-menu {
        max-height: 500px;
    }
    
    .dropdown-menu .nav-link {
        padding-left: 50px;
        font-size: 0.95rem;
        color: var(--primary-blue);
    }
    
    .dropdown-menu .dropdown-menu .nav-link {
        padding-left: 70px;
        font-size: 0.9rem;
    }
    
    .dropdown > .nav-link {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .dropdown-icon {
        transform: none;
        transition: transform 0.3s ease;
        font-size: 0.8rem;
    }
    
    .dropdown.active > .nav-link .dropdown-icon {
        transform: rotate(180deg);
        color: var(--primary-gold);
    }
    
    /* Active state styling */
    .nav-item.active > .nav-link {
        background: linear-gradient(90deg, rgba(184, 115, 51, 0.15), transparent);
        border-left: 4px solid var(--primary-gold);
    }
}

/* ==========================================
   SEARCH BAR (Optional)
   ========================================== */
.nav-search {
    display: flex;
    align-items: center;
    margin-left: 20px;
}

.nav-search input {
    padding: 8px 15px;
    border: 2px solid #e8e8e8;
    border-radius: 20px;
    outline: none;
    transition: var(--transition-fast);
    width: 200px;
}

.nav-search input:focus {
    border-color: var(--primary-gold);
    width: 250px;
}

.nav-search button {
    background: var(--primary-gold);
    border: none;
    padding: 8px 15px;
    margin-left: -35px;
    border-radius: 20px;
    color: white;
    cursor: pointer;
}

/* ==========================================
   RESPONSIVE TOPBAR
   ========================================== */
@media (max-width: 768px) {
    .topbar {
        padding: 8px 0;
    }
    
    .topbar-content {
        justify-content: center;
        gap: 10px;
    }
    
    .topbar-left, .topbar-right {
        gap: 12px;
        font-size: 0.8rem;
    }
    
    .topbar-item span {
        display: none;
    }
    
    .topbar-item {
        font-size: 0.85rem;
    }
    
    .navbar {
        padding: 10px 0;
    }
    
    .navbar-content {
        padding: 10px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    
    .navbar-brand {
        flex: 0 0 auto;
        width: 80px;
        height: 40px;
    }
    
    .mobile-menu-toggle {
        flex: 0 0 auto;
        margin-left: auto;
    }
    
    .navbar-brand img {
        height: 80px;
        width: 80px;
    }
}

@media (max-width: 480px) {
    .topbar {
        font-size: 0.75rem;
    }
    
    .navbar-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        position: relative;
    }
    
    .navbar-brand {
        position: absolute;
        left: 0;
        width: 70px;
        height: 35px;
    }
    
    .mobile-menu-toggle {
        position: absolute;
        right: 0;
    }
    
    .topbar-left, .topbar-right {
        gap: 8px;
    }
    
    .navbar-brand img {
        height: 70px;
        width: 70px;
    }
    
    .mobile-menu-toggle {
        font-size: 1.3rem;
        padding: 10px 14px;
    }
}

/* Prevent horizontal scroll */
@media (max-width: 992px) {
    body {
        overflow-x: hidden !important;
    }
}
