/* ============================================
   Mobile Menu - Professional Design
   Ahwazna.ngo - FINAL VERSION
   ============================================ */

/* ============================================
   Desktop Styles (default - hide mobile elements)
   ============================================ */
.mobile-menu-header {
    display: none;
}

.mobile-menu-footer {
    display: none;
}

/* Force hide close button everywhere by default */
.mobile-menu-close,
.main-nav .mobile-menu-close,
.main-nav.open .mobile-menu-close,
button.mobile-menu-close,
#mobileMenuClose {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

.mobile-menu-btn {
    display: none;
}

/* ============================================
   Mobile Styles (max-width: 1024px)
   ============================================ */
@media (max-width: 1024px) {
    /* Show hamburger button */
    .mobile-menu-btn {
        display: flex !important;
        width: 44px;
        height: 44px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        background: none;
        border: none;
        cursor: pointer;
        z-index: 1002;
    }

    .mobile-menu-btn span {
        display: block;
        width: 24px;
        height: 2px;
        background: #333;
        transition: all 0.3s ease;
        border-radius: 2px;
    }

    /* Main Navigation Panel */
    .main-nav {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        left: auto;
        width: 300px;
        max-width: 85vw;
        height: 100vh;
        height: 100dvh;
        background: #fff;
        flex-direction: column;
        z-index: 1001;
        overflow-y: auto;
        overflow-x: hidden;
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.25);
        padding: 0;
        margin: 0;
        gap: 0;
        border: none;
        border-radius: 0;
    }

    [dir="ltr"] .main-nav {
        right: auto;
        left: 0;
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.25);
    }

    /* Show when open */
    .main-nav.open {
        display: flex !important;
    }

    /* Dark Overlay */
    .main-nav::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
        pointer-events: auto;
    }

    /* Mobile Menu Header */
    .main-nav.open .mobile-menu-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        background: linear-gradient(135deg, #C8102E 0%, #8B0000 100%);
        color: white;
        flex-shrink: 0;
        margin: 0;
        border: none;
        border-radius: 0;
        box-shadow: none;
        width: 100%;
        box-sizing: border-box;
        position: relative;
        overflow: hidden;
    }

    .mobile-menu-header .menu-title {
        font-size: 17px;
        font-weight: 700;
        color: white;
        margin: 0;
        padding: 0;
    }

    /* Close Button - ONLY show inside open menu header */
    .main-nav.open .mobile-menu-header .mobile-menu-close,
    .main-nav.open .mobile-menu-header button.mobile-menu-close,
    .main-nav.open .mobile-menu-header #mobileMenuClose {
        display: flex !important;
        visibility: visible !important;
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        overflow: visible !important;
        position: static !important;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.2);
        border: none;
        border-radius: 8px;
        color: white;
        cursor: pointer;
        padding: 0;
        margin: 0;
        flex-shrink: 0;
    }

    .main-nav.open .mobile-menu-header .mobile-menu-close:hover {
        background: rgba(255, 255, 255, 0.3);
    }

    /* Navigation Links */
    .main-nav.open .nav-link {
        display: flex !important;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 14px;
        padding: 16px 20px;
        margin: 0;
        font-size: 15px;
        font-weight: 500;
        color: #333;
        background: #fff;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        border-radius: 0;
        box-shadow: none;
        text-decoration: none;
        width: 100%;
        box-sizing: border-box;
        white-space: nowrap;
        transition: background 0.2s, color 0.2s;
        flex-shrink: 0;
    }

    /* RTL (Arabic/Persian) - Icon on RIGHT */
    .main-nav.open .nav-link .nav-icon {
        order: 1;
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 22px;
        height: 22px;
        min-width: 22px;
        opacity: 1 !important;
        color: #C8102E;
        flex-shrink: 0;
    }

    .main-nav.open .nav-link span {
        order: 2;
        flex: 1;
        text-align: right;
    }

    /* LTR (English) - Icon on LEFT */
    [dir="ltr"] .main-nav.open .nav-link .nav-icon {
        order: 1;
    }

    [dir="ltr"] .main-nav.open .nav-link span {
        order: 2;
        text-align: left;
    }

    /* Hover */
    .main-nav.open .nav-link:hover {
        background: #fef5f5;
        color: #C8102E;
    }

    /* Active */
    .main-nav.open .nav-link.active {
        background: #fef5f5;
        color: #C8102E;
        border-right: 4px solid #C8102E;
        border-bottom: 1px solid #f0f0f0;
    }

    [dir="ltr"] .main-nav.open .nav-link.active {
        border-right: none;
        border-left: 4px solid #C8102E;
    }

    /* Mobile Menu Footer - directly after nav links, NO gap */
    .main-nav.open .mobile-menu-footer {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 20px;
        background: #f5f5f5;
        border-top: 1px solid #e0e0e0;
        border-radius: 0;
        box-shadow: none;
        width: 100%;
        box-sizing: border-box;
        flex-shrink: 0;
        margin-top: 0;
    }

    .mobile-menu-footer .social-links {
        display: flex;
        justify-content: center;
        gap: 12px;
        margin: 0;
        padding: 0;
    }

    .mobile-menu-footer .social-links a {
        width: 42px;
        height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: white;
        border: 1px solid #ddd;
        border-radius: 10px;
        color: #666;
        transition: all 0.2s;
        padding: 0;
        margin: 0;
    }

    .mobile-menu-footer .social-links a:hover {
        background: #C8102E;
        border-color: #C8102E;
        color: white;
    }

    /* Hamburger Animation */
    .mobile-menu-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }

    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }

    /* Hide hamburger button when menu is open */
    body.menu-open .mobile-menu-btn {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .mobile-menu-btn.active {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* Also hide with ID selector for maximum specificity */
    body.menu-open #mobileMenuBtn,
    #mobileMenuBtn.active {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }

    /* Body lock */
    body.menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .main-nav {
        width: 100% !important;
        max-width: 100% !important;
    }

    .main-nav.open .mobile-menu-header {
        padding: 14px 16px;
    }

    .main-nav.open .nav-link {
        padding: 14px 16px;
        font-size: 14px;
        gap: 12px;
    }

    .main-nav.open .nav-link .nav-icon {
        width: 20px;
        height: 20px;
        min-width: 20px;
    }

    .main-nav.open .mobile-menu-footer {
        padding: 16px;
    }

    .mobile-menu-footer .social-links a {
        width: 38px;
        height: 38px;
    }
}
