/* ============================================
   HEADER STYLES - BAFAI LMS
   Modern, Clean, and Vibrant Design
   ============================================ */

/* Import Google Fonts */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* CSS Variables */
:root {
    --header-bg: #ffffff;
    --header-text: #1e293b;
    --header-primary: #503a98;
    --header-secondary: #21a37a;
    --header-border: #e2e8f0;
    --header-hover-bg: #f1f5f9;
    --header-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
    --header-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --gradient-primary: linear-gradient(135deg, #503a98 0%, #21a37a 100%);
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 2rem;
    --dark: #0f172a;
    --dark-soft: #1e293b;
    --gray: #64748b;
    --gray-light: #f1f5f9;
    --font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        "Inter",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        sans-serif;
    background: var(--gray-light);
    color: var(--dark);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    font-size: 15px;
}

.container {
    max-width: 1280px;
    width: 100%;
    padding-left: 2rem;
    padding-right: 2rem;
    margin: 0 auto;
}

/* Typography refinements */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Accent Bar at the Top */
.header-accent-bar {
    height: 4px;
    width: 100%;
    background: var(--gradient-primary);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1031;
}

/* Header Container */
.header-one {
    background: var(--header-bg);
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 1030;
    box-shadow: var(--header-shadow);
    transition: box-shadow 0.3s ease;
    border-bottom: 1px solid var(--header-border);
}

/* Navigation Wrapper */
.header-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    gap: 1.5rem;
    position: relative;
}

/* Logo */
.navbar-logo {
    flex-shrink: 0;
}

.navbar-logo .logo {
    height: 38px;
    width: auto;
    transition: var(--header-transition);
}

/* Desktop Navigation */
.main-nav {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0 auto 0 2rem;
    padding: 0;
    gap: 0.25rem;
}

.main-nav > li {
    position: relative;
}

.has-dropdown { position: relative; }

/* Bridge for hover (optional, but harmless) */
.main-nav > li.has-dropdown::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 16px;
    background: transparent;
    z-index: 999;
    pointer-events: none;
}

.main-nav > li > a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    color: var(--header-text);
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--header-transition);
    font-size: 0.95rem;
    white-space: nowrap;
    cursor: pointer;
}

.main-nav > li > a i {
    font-size: 0.7rem;
    transition: transform 0.25s ease;
    color: #64748b;
}

.main-nav > li:hover > a,
.main-nav > li.active > a,
.main-nav > li > a.nav-link-active {
    background: rgba(79, 70, 229, 0.06);
    color: var(--header-primary);
}

/* ========== DROPDOWN MENU - HOVER + CLICK SUPPORT ========== */
/* Default hidden state */
.main-nav .dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    display: none;
    left: 0;
    min-width: 230px;
    background: var(--header-bg);
    border-radius: var(--radius-md);
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.12);
    padding: 0.5rem;
    list-style: none;
    z-index: 1000;
    border: 1px solid var(--header-border);
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-12px);
    transition: all 0.25s ease;
    pointer-events: none;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.has-dropdown.open .dropdown-menu { display: block; }

/* Show on hover (mouse users) */
.main-nav > li.has-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Show on click (via .open class) */
.main-nav > li.has-dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Rotate arrow on hover OR open */
.main-nav > li.has-dropdown:hover > a i.fa-chevron-down,
.main-nav > li.has-dropdown.open > a i.fa-chevron-down {
    transform: rotate(180deg);
}

/* Dropdown items styling */
.main-nav .dropdown-menu li {
    display: block;
}

.main-nav .dropdown-menu li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    color: var(--header-text);
    text-decoration: none;
    transition: var(--header-transition);
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.main-nav .dropdown-menu li a i {
    width: 20px;
    color: #64748b;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.main-nav .dropdown-menu li a:hover {
    background: #f1f5f9;
    color: var(--header-primary);
    transform: translateX(3px);
}

.main-nav .dropdown-menu li a:hover i {
    color: var(--header-primary);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Cart Icon */
.cart-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.cart-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--header-hover-bg);
    color: var(--header-text);
    font-size: 1.15rem;
    text-decoration: none;
    transition: var(--header-transition);
    position: relative;
}

.cart-icon:hover {
    background: var(--header-primary);
    color: white;
    transform: scale(1.05);
}

.cart-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    transition: transform 0.2s ease;
}

/* Auth Buttons */
.auth-buttons {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-signin {
    background: transparent;
    border: 2px solid var(--header-primary);
    padding: 0.45rem 1.4rem;
    border-radius: var(--radius-lg);
    color: var(--header-primary);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: var(--header-transition);
}

.btn-signin:hover {
    background: var(--header-primary);
    color: white;
}

.btn-signup {
    background: var(--gradient-primary);
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: var(--radius-lg);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: var(--header-transition);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-signup:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.35);
    color: white;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--header-text);
    font-size: 1.6rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: var(--header-transition);
}

.mobile-menu-btn:hover {
    background: var(--header-hover-bg);
}

/* Mobile Sidebar */
.mobile-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: #ffffff;
    z-index: 1050;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch; /* smooth scroll on iOS */
}

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

.mobile-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--header-border);
}

.mobile-sidebar-header img {
    height: 32px;
}

.close-sidebar {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #64748b;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--header-transition);
}

.close-sidebar:hover {
    background: #f1f5f9;
    color: var(--header-text);
}

/* Mobile Nav Links */
.mobile-nav {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    flex: 1;
}

.mobile-nav > li {
    border-bottom: 1px solid #f1f5f9;
}

.mobile-nav > li > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    color: var(--header-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--header-transition);
}

.mobile-nav > li > a i {
    font-size: 0.75rem;
    color: #94a3b8;
    transition: transform 0.25s ease;
}

.mobile-nav > li > a:hover {
    background: #f8fafc;
    color: var(--header-primary);
}

/* Mobile Dropdown */
.mobile-dropdown-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #f8fafc;
    display: none;
    border-bottom: 1px solid #e2e8f0;
}

.mobile-dropdown-menu.show {
    display: block;
}

.mobile-dropdown-menu li a {
    display: block;
    padding: 0.8rem 1.5rem 0.8rem 2.5rem;
    color: #475569;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--header-transition);
    border-left: 3px solid transparent;
}

.mobile-dropdown-menu li a:hover {
    color: var(--header-primary);
    background: rgba(79, 70, 229, 0.04);
    border-left-color: var(--header-primary);
}

/* Mobile Auth Buttons */
.mobile-auth {
    padding: 1.5rem;
    border-top: 1px solid var(--header-border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: auto;
}

.mobile-auth .btn-signin,
.mobile-auth .btn-signup {
    text-align: center;
    width: 100%;
    padding: 0.7rem 0;
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1040;
    display: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
}

/* Scroll shadow for sticky header */
.header-one.scrolled {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

/* Cart animation */
@keyframes pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

.cart-count-updated {
    animation: pop 0.3s ease;
}

/* ============================================
           RESPONSIVE DESIGN
           ============================================ */
@media (max-width: 1024px) {
    .main-nav > li > a {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 991px) {
    .main-nav {
        display: none;
    }
    .mobile-menu-btn {
        display: block;
    }
    .header-actions {
        gap: 0.5rem;
    }
    .auth-buttons {
        display: none;
    }
    .navbar-logo {
        margin-right: auto;
    }
}

@media (max-width: 576px) {
    .header-nav {
        padding: 0.5rem 0;
    }
    .navbar-logo .logo {
        height: 32px;
    }
    .cart-icon {
        width: 38px;
        height: 38px;
    }
}


/* User dropdown in header */
.user-dropdown {
    position: relative;
    display: inline-block;
}
.btn-user {
    background: transparent;
    border: none;
    color: var(--primary);
    font-weight: 600;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.3s;
}
.btn-user:hover {
    color: var(--primary-dark);
}
.user-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 1000;
}
.user-dropdown:hover .dropdown-menu,
.user-dropdown .dropdown-menu.show {
    opacity: 1;
    visibility: visible;
}
.dropdown-item {
    display: block;
    padding: 0.6rem 1rem;
    color: var(--dark);
    text-decoration: none;
    transition: background 0.2s;
}
.dropdown-item:hover {
    background: var(--gray-light);
    color: var(--primary);
}
.logout-btn {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

/* Visible when parent has .open class */
.user-dropdown.open .dropdown-menu {
    display: block;
}

@media (max-width: 768px) {
    .user-dropdown .dropdown-menu {
        right: auto;
        left: 0;
        width: 100%;
    }
}

/* Mobile auth styles */
.mobile-auth {
    padding: 1rem 0;
    border-top: 1px solid rgba(0,0,0,0.1);
    margin-top: 1rem;
}
.mobile-auth .btn-signin,
.mobile-auth .btn-signup {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.7rem;
    margin-bottom: 0.8rem;
    border-radius: 2rem;
    text-decoration: none;
    font-weight: 600;
}
.mobile-auth .btn-signin {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}
.mobile-auth .btn-signup {
    background: var(--primary);
    color: white;
}
.mobile-user-info {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}
.mobile-user-name {
    font-weight: 600;
    color: var(--dark);
    text-align: center;
    padding: 0.5rem;
    background: var(--gray-light);
    border-radius: 2rem;
}
.mobile-logout-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.7rem;
    border-radius: 2rem;
    font-weight: 600;
    width: 100%;
    cursor: pointer;
    transition: background 0.3s;
}
.mobile-logout-btn:hover {
    background: #c82333;
}

/* ============================================
   FIXES FOR MOBILE SIDEBAR - PREVENT CUTOFF
   ============================================ */

/* Ensure the mobile sidebar takes full height and scrolls if needed */
.mobile-sidebar {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 100vh;
}

/* Extra bottom padding for the mobile auth section to avoid cut-off */
.mobile-auth {
    margin-bottom: 20px;
    padding-bottom: 20px;
}

/* On very short screens, allow scrolling and add extra safety */
@media (max-height: 600px) {
    .mobile-sidebar {
        padding-bottom: 30px;
    }
    .mobile-auth {
        margin-top: 20px;
        padding-top: 12px;
        padding-bottom: 25px;
    }
}

/* Ensure the close button is not overlapped and the header stays on top */
.mobile-sidebar-header {
    flex-shrink: 0;
    background: #fff;
    z-index: 1;
}

/* Make sure the mobile nav doesn't push auth off screen */
.mobile-nav {
    flex: 1 1 auto;
    overflow-y: auto;
}

/* Improve touch targets for auth buttons on mobile */
.mobile-auth .btn-signin,
.mobile-auth .btn-signup,
.mobile-logout-btn {
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
}

/* Prevent the entire sidebar from overflowing on very narrow devices */
@media (max-width: 380px) {
    .mobile-sidebar {
        width: 90%;
        max-width: 280px;
    }
    .mobile-nav > li > a {
        padding: 0.8rem 1rem;
        font-size: 0.85rem;
    }
    .mobile-auth {
        padding: 1rem;
    }
}

/* Make mobile sidebar scrollable */
.mobile-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;  /* use viewport height */
    background: #ffffff;
    z-index: 1050;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    /* Ensure content can scroll */
    -webkit-overflow-scrolling: touch; /* smooth scroll on iOS */
}

/* Ensure the header area is sticky at top */
.mobile-sidebar-header {
    position: sticky;
    top: 0;
    background: white;
    z-index: 2;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--header-border);
    flex-shrink: 0;
}

/* Make the nav area take remaining space and scroll if needed */
.mobile-nav {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 1rem;
}

/* Auth section at bottom, not sticky but will be scrolled to if needed */
.mobile-auth {
    margin-top: auto;
    padding: 1.5rem;
    border-top: 1px solid var(--header-border);
    background: white;
    flex-shrink: 0;
}

/* ============================================
   OVERLAP FIX: DROPDOWN ON TOP OF EVERYTHING
   ============================================ */

/* Force dropdowns to be above all page content */
.main-nav .dropdown-menu,
.user-dropdown .dropdown-menu {
    z-index: 99999 !important;
    position: absolute;
}

/* Ensure no parent container clips or hides the dropdown */
.header-one,
.header-nav,
.main-nav,
.main-nav > li {
    overflow: visible !important;
    z-index: 1030;
}

/* Lower the z-index of potential overlapping elements (like banners, sliders) */
.banner-section,
.partners-section,
.swiper-container,
.slider-section,
.hero-section,
.courses-grid-section,
.carousel,
.swiper-wrapper,
.media-card,
.feature-item,
.course-card {
    position: relative;
    z-index: 1 !important;
}

/* If the dropdown is still behind, force a higher stacking context on the header */
.header-one {
    z-index: 9999 !important;
    isolation: isolate;
}

