@import url("mobile-optimizations.css");

/* Professional Mobile Menu Styles - RTL Support */

/* Mobile-scoped styles for hamburger button */
@media (max-width: 991px) {
    .hamburger-menu {
        display: flex !important;
        flex-direction: column;
        justify-content: space-around;
        width: 25px;
        height: 20px;
        cursor: pointer;
        z-index: var(--z-dropdown);
        position: relative;
        background: none;
        border: none;
        padding: 0;
        margin: 0;
        outline: none;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        transition: transform 0.2s ease;
    }

    .hamburger-menu:hover {
        transform: scale(1.05);
    }

    .hamburger-menu:active {
        transform: scale(0.95);
    }

    .hamburger-menu span {
        display: block;
        width: 100%;
        height: 1.8px;
        background-color: var(--text-main-light);
        border-radius: 5px;
        transition: all 0.3s ease-in-out;
    }

    /* X animation when expanded */
    .hamburger-menu[aria-expanded="true"] span:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }

    .hamburger-menu[aria-expanded="true"] span:nth-child(2) {
        opacity: 0;
    }

    .hamburger-menu[aria-expanded="true"] span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }

    /* Mobile overlay styles */
    #mobileOverlay {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, #161b22 0%, #0d1117 100%);
        z-index: var(--z-overlay);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.35s ease, visibility 0.35s ease;
    }

    #mobileOverlay.is-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Backdrop filter support */
    @supports (backdrop-filter: blur(6px)) {
        #mobileOverlay {
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
        }
    }

    /* Mobile nav panel styles */
    #mobileNav {
        position: fixed;
        top: 0;
        right: 0;
        height: 100dvh;
        width: 65%;
        background: linear-gradient(135deg, #161b22 0%, #0d1117 100%);
        border-left: 2px solid var(--primary-color);
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.8);
        padding-top: 40px;
        padding-bottom: 40px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 14px;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: var(--z-modal);
        transform: translateX(100%);
        transition: transform 0.35s ease;
    }

    #mobileNav.is-open {
        transform: translateX(0);
    }

    /* Mobile nav links styling */
    #mobileNav a {
        color: var(--text-main-light);
        text-decoration: none;
        font-size: 0.9rem;
        font-weight: 600;
        transition: all 0.3s ease;
        padding: 10px 16px;
        width: 90%;
        text-align: center;
        background-color: rgba(255, 255, 255, 0.04);
        border-radius: 10px;
        margin: 0;
        border: 1px solid rgba(255, 255, 255, 0.08);
        display: block;
    }

    #mobileNav a:hover {
        color: var(--text-main-light);
        background-color: rgba(0, 188, 212, 0.1);
        border-color: var(--primary-color);
        transform: translateY(-2px);
    }

    /* Mobile language dropdown in nav */
    #mobileNav .mobile-language-dropdown {
        display: block;
        width: 90%;
        margin: 12px auto;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        padding-top: 10px;
    }

    #mobileNav .mobile-language-dropdown .dropdown-toggle {
        background-color: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.08);
        color: var(--text-main-light);
        padding: 10px 16px;
        border-radius: 10px;
        cursor: pointer;
        font-weight: 600;
        font-size: 0.9rem;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        transition: all 0.3s ease;
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    #mobileNav .mobile-language-dropdown .dropdown-toggle:hover {
        background-color: rgba(0, 188, 212, 0.1);
        border-color: var(--primary-color);
        box-shadow: 0 0 8px rgba(0, 188, 212, 0.2);
        transform: translateY(-2px);
    }

    #mobileNav .mobile-language-dropdown .dropdown-toggle img {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        object-fit: cover;
    }

    #mobileNav .mobile-language-dropdown .dropdown-toggle .fa-chevron-down {
        font-size: 0.7rem;
        transition: transform 0.3s ease;
    }

    #mobileNav .mobile-language-dropdown.active .dropdown-toggle .fa-chevron-down {
        transform: rotate(180deg);
    }

    #mobileNav .mobile-language-dropdown .dropdown-menu {
        position: static;
        background-color: rgba(255, 255, 255, 0.02);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 8px;
        list-style: none;
        padding: 0;
        margin-top: 10px;
        width: 100%;
        box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
        opacity: 0;
        visibility: hidden;
        max-height: 0;
        overflow: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease, max-height 0.4s ease-out;
    }

    #mobileNav .mobile-language-dropdown.active .dropdown-menu {
        opacity: 1;
        visibility: visible;
        max-height: 200px;
    }

    #mobileNav .mobile-language-dropdown .dropdown-menu li button {
        background: none;
        border: none;
        color: var(--text-secondary-light);
        padding: 8px 12px;
        width: 100%;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        cursor: pointer;
        font-size: 0.85rem;
        font-weight: 600;
        transition: background-color 0.3s ease, color 0.3s ease;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    #mobileNav .mobile-language-dropdown .dropdown-menu li:last-child button {
        border-bottom: none;
    }

    #mobileNav .mobile-language-dropdown .dropdown-menu li button:hover {
        background-color: rgba(0, 188, 212, 0.1);
        color: var(--primary-color);
    }

    #mobileNav .mobile-language-dropdown .dropdown-menu li button.active-lang {
        background-color: rgba(0, 188, 212, 0.1);
        color: var(--primary-color);
    }

    /* Mobile auth buttons */
    #mobileNav .mobile-auth-buttons {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 90%;
        margin: 12px auto 0;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        padding-top: 14px;
    }

    #mobileNav .mobile-auth-buttons .btn {
        width: 100%;
    }

    /* Compact login button for mobile/tablet */
    .mobile-nav .mobile-auth-buttons .btn.login,
    #mobileNav .mobile-auth-buttons .btn.login {
        font-size: 0.85rem;
        padding: 8px 14px;
        border-width: 1.5px;
        border-radius: 35px;
        letter-spacing: 0.05px;
        text-align: center;
    }

    .mobile-nav .mobile-auth-buttons .btn.login i,
    #mobileNav .mobile-auth-buttons .btn.login i {
        font-size: 0.9rem;
    }

    /* Body scroll lock when menu is open */
    body.menu-open {
        overflow: hidden !important;
    }

    /* Hide desktop elements on mobile */
    .nav-links,
    .header-actions .btn:not(.hide-on-free-course-signup),
    .search-button,
    .language-dropdown {
        display: none !important;
    }
}

/* Very small screens - full width panel */
@media (max-width: 767px) {
    #mobileNav {
        width: 100%;
        border-left: none;
        border-right: 2px solid var(--primary-color);
    }

    #mobileNav a {
        font-size: 0.85rem;
        padding: 8px 14px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .hamburger-menu {
        width: 22px;
        height: 18px;
    }

    .hamburger-menu span {
        height: 1.5px;
    }

    #mobileNav {
        padding-top: 40px;
        gap: 15px;
    }

    #mobileNav a {
        font-size: 0.8rem;
        padding: 7px 12px;
    }

    /* Mobile-specific compact login button styles */
    #mobileNav .mobile-auth-buttons .btn.login {
        font-size: 0.8rem;
        padding: 6px 14px;
        border-width: 1.5px;
        border-radius: 35px;
    }

    #mobileNav .mobile-auth-buttons .btn.login i {
        font-size: 0.9rem;
    }
}

/* Unified mobile menu overrides (ensure consistency across pages) */
.mobile-nav-overlay {
    background: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: var(--z-modal) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    display: flex !important;
    align-items: stretch !important;
    justify-content: flex-end !important;
}

.mobile-nav-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.mobile-nav-overlay .mobile-nav {
    width: min(320px, 88vw) !important;
    max-width: 380px !important;
    padding: 20px 18px !important;
    background: rgba(15, 23, 42, 0.85) !important;
    border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
    transform: translateX(110%) !important;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1) !important;
    overflow-y: auto !important;
}

.mobile-nav-overlay.active .mobile-nav {
    transform: translateX(0) !important;
}

html[dir="rtl"] .mobile-nav-overlay {
    justify-content: flex-start !important;
}

html[dir="rtl"] .mobile-nav-overlay .mobile-nav {
    right: auto !important;
    left: 0 !important;
    border-left: none !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
    transform: translateX(-110%) !important;
}

html[dir="rtl"] .mobile-nav-overlay.active .mobile-nav {
    transform: translateX(0) !important;
}

.mobile-nav-overlay .mobile-nav > a,
.mobile-nav-overlay .mobile-nav .mobile-links a {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 12px 14px !important;
    border-radius: 12px !important;
    font-size: 0.98rem !important;
    line-height: 1.3 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.mobile-nav-overlay .mobile-nav > a i,
.mobile-nav-overlay .mobile-nav .mobile-links a i {
    width: 24px !important;
    text-align: center !important;
    font-size: 1.05rem !important;
}

.mobile-nav-overlay .mobile-nav .mobile-nav-footer {
    margin-top: 18px !important;
    padding-top: 16px !important;
    gap: 14px !important;
}

.mobile-nav-overlay .mobile-nav .mobile-auth-buttons .btn {
    min-height: 44px !important;
    font-size: 0.95rem !important;
    border-radius: 12px !important;
}

@media (max-width: 480px) {
    .mobile-nav-overlay .mobile-nav {
        width: 100% !important;
        padding: 18px 16px !important;
        border-radius: 0 !important;
    }

    .mobile-nav-overlay .mobile-nav > a,
    .mobile-nav-overlay .mobile-nav .mobile-links a {
        font-size: 0.92rem !important;
        padding: 10px 12px !important;
    }
}