/**
 * استایل موبایل برای مگامنو - نمایش کامل در موبایل
 * 
 * @package LZ_Megamenu
 * @version 1.0.0
 */

/* ============================================
   مگامنو در موبایل - بهینه‌سازی کامل
   ============================================ */

@media (max-width: 768px) {
    
    /* اطمینان از نمایش navbar در موبایل */
    .navbar-primary {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: 50px;
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    /* اطمینان از نمایش دکمه منو */
    #menu-toggle,
    .menu-toggle-btn {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* پس‌زمینه تار - فول اسکرین */
    .mega-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        pointer-events: none;
    }
    
    .mega-menu-overlay.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    
    /* مگامنو - فول اسکرین در موبایل */
    .mega-menu-wrapper {
        position: fixed !important;
        top: 0 !important;
        right: -100% !important;
        bottom: 0 !important;
        left: auto !important;
        width: 85% !important;
        max-width: 320px !important;
        min-width: 280px !important;
        height: 100vh !important;
        background: #fff;
        z-index: 9999;
        display: none !important;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
        overflow: hidden;
        transform: translateX(100%);
        transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                    transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.3s ease,
                    visibility 0.3s ease;
        opacity: 0;
        visibility: hidden;
    }
    
    /* حالت باز */
    .mega-menu-wrapper.open {
        display: flex !important;
        right: 0 !important;
        transform: translateX(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* محتوای مگامنو */
    .mega-menu-content {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        background: #fff;
        overflow: hidden;
    }
    
    /* بدنه مگامنو */
    .mega-menu-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }
    
    /* sidebar - نوار کناری */
    .mega-sidebar {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        background: #f8f9fa;
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }
    
    /* هدر sidebar */
    .sidebar-header {
        padding: 16px;
        background: #003871;
        color: #fff;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        flex-shrink: 0;
    }
    
    /* آیکون بستن */
    .close-icon {
        width: 28px;
        height: 28px;
        cursor: pointer;
        padding: 4px;
        border-radius: 4px;
        transition: background 0.3s ease;
    }
    
    .close-icon:active {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .close-icon path {
        fill: #fff !important;
    }
    
    /* منوی کناری */
    .sidebar-menu {
        flex: 1;
        list-style: none;
        margin: 0;
        padding: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar-menu::-webkit-scrollbar {
        width: 4px;
    }
    
    .sidebar-menu::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 2px;
    }
    
    /* آیتم‌های منو */
    .sidebar-menu .menu-item {
        border-bottom: 1px solid #e9ecef;
    }
    
    .sidebar-menu .menu-item:last-child {
        border-bottom: none;
    }
    
    .sidebar-menu .menu-item > a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        color: #333;
        text-decoration: none;
        font-size: 15px;
        font-weight: 500;
        transition: all 0.3s ease;
        background: transparent;
    }
    
    .sidebar-menu .menu-item:active > a,
    .sidebar-menu .menu-item.active > a {
        background: #003871;
        color: #fff;
    }
    
    /* فلش منو */
    .menu-arrow {
        font-size: 24px;
        font-weight: bold;
        transition: transform 0.3s ease;
        color: #666;
    }
    
    .sidebar-menu .menu-item.active .menu-arrow {
        transform: rotate(90deg);
        color: #fff;
    }
    
    /* پنل‌های محتوا - فول اسکرین در موبایل */
    .mega-panel {
        position: fixed !important;
        top: 0 !important;
        right: -100% !important;
        bottom: 0 !important;
        left: auto !important;
        width: 85% !important;
        max-width: 320px !important;
        min-width: 280px !important;
        height: 100vh !important;
        background: #fff;
        padding: 0 !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 10000 !important;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
        display: none !important;
        opacity: 0;
        transform: translateX(100%);
        transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.3s ease;
    }
    
    .mega-panel.visible {
        display: block !important;
        right: 0 !important;
        transform: translateX(0) !important;
        opacity: 1 !important;
    }
    
    /* هدر پنل */
    .mega-panel-header {
        padding: 16px 20px;
        background: #003871;
        color: #fff;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-direction: column;
        gap: 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .mega-panel-header h2 {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
        color: #fff;
        width: 100%;
        text-align: right;
    }
    
    .mega-panel-link {
        color: #fff;
        text-decoration: none;
        font-size: 13px;
        padding: 8px 16px;
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 6px;
        transition: all 0.3s ease;
        width: 100%;
        text-align: center;
        display: block;
    }
    
    .mega-panel-link:active {
        background: rgba(255, 255, 255, 0.1);
    }
    
    /* گرید پنل - تک ستون در موبایل */
    .mega-panel-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0 !important;
        padding: 0 !important;
    }
    
    /* ستون‌های دسته‌بندی */
    .mega-column {
        background: #fff;
        border-radius: 0;
        padding: 20px;
        border: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .mega-column:last-child {
        border-bottom: none;
    }
    
    /* گروه دسته‌بندی */
    .category-group {
        margin-bottom: 24px;
        padding-bottom: 20px;
        border-bottom: 1px solid #e9ecef;
    }
    
    .category-group:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }
    
    .category-group h3 {
        margin: 0 0 12px 0;
        font-size: 16px;
        font-weight: 700;
        color: #1a365d;
    }
    
    .category-group h3 a {
        color: #1a365d;
        text-decoration: none;
    }
    
    .category-group h3 a:active {
        color: #003871;
    }
    
    /* زیردسته‌ها */
    .sub-categories {
        list-style: none;
        margin: 0;
        padding: 0;
    }
    
    .sub-categories li {
        margin-bottom: 4px;
    }
    
    .sub-categories a {
        color: #2d3748;
        text-decoration: none;
        font-size: 14px;
        font-weight: 400;
        display: block;
        padding: 8px 0;
        transition: all 0.3s ease;
    }
    
    .sub-categories a:active {
        color: #003871;
        padding-right: 8px;
        font-weight: 500;
    }
    
    /* دسته‌بندی ساده */
    .simple-category {
        margin-bottom: 12px;
    }
    
    .simple-category a {
        color: #2d3748;
        text-decoration: none;
        font-size: 15px;
        font-weight: 500;
        display: block;
        padding: 10px 0;
    }
    
    .simple-category a:active {
        color: #003871;
        padding-right: 8px;
        font-weight: 600;
    }
    
    /* فوتر sidebar */
    .sidebar-footer {
        padding: 16px 20px;
        border-top: 1px solid #e9ecef;
        display: flex;
        flex-direction: column;
        gap: 10px;
        flex-shrink: 0;
        background: #f8f9fa;
    }
    
    .help-link,
    .login-link {
        color: #666;
        text-decoration: none;
        font-size: 14px;
        padding: 10px 12px;
        border-radius: 6px;
        transition: all 0.3s ease;
        text-align: center;
        border: 1px solid #e9ecef;
        background: #fff;
    }
    
    .help-link:active,
    .login-link:active {
        background: #e9ecef;
        color: #003871;
    }
    
    /* جلوگیری از اسکرول صفحه وقتی منو باز است */
    body.mega-menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
    
    /* دکمه بازگشت در پنل (اگر نیاز باشد) */
    .panel-back-button {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 16px 20px;
        background: #f8f9fa;
        border-bottom: 1px solid #e9ecef;
        color: #003871;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.3s ease;
    }
    
    .panel-back-button:active {
        background: #e9ecef;
    }
    
    .panel-back-button::before {
        content: '‹';
        font-size: 28px;
        font-weight: bold;
    }
}

/* ============================================
   موبایل کوچک (< 480px)
   ============================================ */

@media (max-width: 480px) {
    
    .mega-menu-wrapper {
        width: 90% !important;
        max-width: 100% !important;
    }
    
    .mega-panel {
        width: 90% !important;
        max-width: 100% !important;
    }
    
    .sidebar-menu .menu-item > a {
        padding: 14px 16px;
        font-size: 14px;
    }
    
    .mega-panel-header h2 {
        font-size: 16px;
    }
    
    .category-group h3 {
        font-size: 15px;
    }
    
    .sub-categories a {
        font-size: 13px;
    }
}

/* ============================================
   حالت افقی (Landscape)
   ============================================ */

@media (max-width: 768px) and (orientation: landscape) {
    
    .mega-menu-wrapper,
    .mega-panel {
        width: 60% !important;
        max-width: 400px !important;
    }
    
    .sidebar-header,
    .mega-panel-header {
        padding: 12px 20px;
    }
    
    .sidebar-menu .menu-item > a {
        padding: 12px 20px;
    }
}

/* ============================================
   انیمیشن‌ها
   ============================================ */

@media (max-width: 768px) {
    
    @keyframes slideInFromRight {
        from {
            right: -100%;
            transform: translateX(100%);
            opacity: 0;
        }
        to {
            right: 0;
            transform: translateX(0);
            opacity: 1;
        }
    }
    
    @keyframes slideOutToRight {
        from {
            right: 0;
            transform: translateX(0);
            opacity: 1;
        }
        to {
            right: -100%;
            transform: translateX(100%);
            opacity: 0;
        }
    }
    
    .mega-menu-wrapper.open {
        animation: slideInFromRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .mega-panel.visible {
        animation: slideInFromRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

