/* =============================================
   ULTRA PROFESSIONAL TABLET MENU
   Chart-systemX - Premium Design
   ============================================= */

/* =============================================
   TABLET BREAKPOINT: 768px - 1279px
   ============================================= */
@media screen and (min-width: 768px) and (max-width: 1279px) {
    
    /* Hide desktop navigation */
    nav.tablet-nav-fix {
        display: none !important;
    }
    
    .tablet-action-buttons {
        display: none !important;
    }
    
    /* Enhanced tablet menu button */
    #mobileMenuBtn {
        display: flex !important;
        width: 46px !important;
        height: 46px !important;
        background: linear-gradient(135deg, #1e40af, #3b82f6) !important;
        box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3) !important;
    }
    
    #mobileMenuBtn:hover {
        background: linear-gradient(135deg, #f97316, #fb923c) !important;
        box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3) !important;
    }
    
    /* =========================================
       PROFESSIONAL FULL-HEIGHT SLIDING MENU
       ========================================= */
    #mobileMenu {
        /* Full height from top - no gap */
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 340px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        background: #ffffff !important;
        box-shadow: -8px 0 32px rgba(0,0,0,0.12) !important;
        z-index: 9999 !important;
        overflow: hidden !important;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    #mobileMenu.hidden {
        transform: translateX(100%) !important;
    }
    
    #mobileMenu:not(.hidden) {
        transform: translateX(0) !important;
    }
    
    /* Professional Header Section */
    .tablet-menu-header {
        background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%) !important;
        padding: 0 !important;
        height: 100px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-shrink: 0 !important;
        box-shadow: 0 2px 12px rgba(30, 64, 175, 0.15) !important;
    }
    
    .tablet-menu-header > * {
        padding: 0 1.25rem !important;
    }
    
    /* Menu Content Section with Scrollbar */
    #mobileMenu .menu-content-wrapper {
        flex: 1 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 1rem 0 12rem 0 !important;
        min-height: 0 !important;
        max-height: calc(100vh - 120px) !important;
    }
    
    /* Professional Scrollbar Design */
    #mobileMenu .menu-content-wrapper::-webkit-scrollbar {
        width: 6px !important;
    }
    
    #mobileMenu .menu-content-wrapper::-webkit-scrollbar-track {
        background: #f1f5f9 !important;
        border-radius: 3px !important;
    }
    
    #mobileMenu .menu-content-wrapper::-webkit-scrollbar-thumb {
        background: #cbd5e1 !important;
        border-radius: 3px !important;
        transition: background 0.2s !important;
    }
    
    #mobileMenu .menu-content-wrapper::-webkit-scrollbar-thumb:hover {
        background: #94a3b8 !important;
    }
    
    /* Firefox Scrollbar */
    #mobileMenu .menu-content-wrapper {
        scrollbar-width: thin !important;
        scrollbar-color: #cbd5e1 #f1f5f9 !important;
    }
    
    /* Professional Menu Items - RTL Optimized */
    #mobileMenu a {
        display: flex !important;
        align-items: center !important;
        flex-direction: row-reverse !important; /* RTL layout */
        padding: 0.875rem 1.5rem !important;
        margin: 0 0.75rem 0.25rem 0.75rem !important;
        font-size: 0.938rem !important;
        font-weight: 500 !important;
        color: #334155 !important;
        border-radius: 0.5rem !important;
        transition: all 0.2s ease !important;
        text-decoration: none !important;
        position: relative !important;
        overflow: hidden !important;
        text-align: right !important;
    }
    
    #mobileMenu a:hover {
        background: #f8fafc !important;
        color: #1e40af !important;
        padding-right: 2rem !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    }
    
    #mobileMenu a:active {
        transform: scale(0.98) !important;
    }
    
    /* Icon spacing */
    #mobileMenu a svg {
        margin-left: 0.75rem !important;
        flex-shrink: 0 !important;
    }
    
    /* Active menu item */
    #mobileMenu a.active {
        background: linear-gradient(135deg, #eff6ff, #dbeafe) !important;
        color: #1e40af !important;
        font-weight: 600 !important;
        box-shadow: 0 2px 4px rgba(30, 64, 175, 0.1) !important;
    }
    
    /* Dropdown Sections - RTL Optimized */
    #mobileMenu .mobile-dropdown {
        margin: 0.25rem 0 !important;
    }
    
    #mobileMenu .mobile-dropdown button {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-direction: row-reverse !important; /* RTL: Arrow on left */
        width: calc(100% - 1.5rem) !important;
        margin: 0 0.75rem !important;
        padding: 0.875rem 1.5rem !important;
        background: transparent !important;
        border: none !important;
        font-size: 0.938rem !important;
        font-weight: 500 !important;
        color: #334155 !important;
        text-align: right !important;
        border-radius: 0.5rem !important;
        transition: all 0.2s !important;
        cursor: pointer !important;
    }
    
    /* Ensure arrow stays on the left in RTL */
    #mobileMenu .mobile-dropdown button > svg:first-child {
        margin-right: 0 !important;
        margin-left: auto !important;
    }
    
    #mobileMenu .mobile-dropdown button:hover {
        background: #f8fafc !important;
        color: #1e40af !important;
    }
    
    /* Dropdown arrow animation */
    #mobileMenu .mobile-dropdown button svg {
        transition: transform 0.3s ease !important;
    }
    
    #mobileMenu .mobile-dropdown button[aria-expanded="true"] svg,
    #mobileMenu .mobile-dropdown .rotate-180 {
        transform: rotate(180deg) !important;
    }
    
    /* Dropdown content */
    #mobileMenu .mobile-dropdown > div:not(.hidden) {
        background: #f8fafc !important;
        margin: 0.25rem 0.75rem !important;
        border-radius: 0.5rem !important;
        padding: 0.5rem 0 !important;
        animation: slideDown 0.3s ease-out !important;
    }
    
    #mobileMenu .mobile-dropdown a {
        padding-right: 2.5rem !important;
        margin: 0.125rem 0.75rem !important;
        font-size: 0.875rem !important;
        color: #64748b !important;
    }
    
    #mobileMenu .mobile-dropdown a:hover {
        background: white !important;
        color: #1e40af !important;
    }
    
    /* User Section Styling */
    #mobileMenu .user-section {
        border-top: 1px solid #e5e7eb !important;
        margin-top: 1rem !important;
        padding-top: 1rem !important;
    }
    
    #mobileMenu .user-card {
        background: linear-gradient(135deg, #f8fafc, #f1f5f9) !important;
        border-radius: 0.75rem !important;
        padding: 1rem !important;
        margin: 0.75rem !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    }
    
    /* Action Buttons in Menu */
    #mobileMenu .action-buttons {
        padding: 1rem 0.75rem !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    #mobileMenu .action-buttons a,
    #mobileMenu .action-buttons button {
        width: 100% !important;
        padding: 0.75rem !important;
        border-radius: 0.5rem !important;
        font-weight: 600 !important;
        text-align: center !important;
        transition: all 0.2s !important;
    }
    
    #mobileMenu .action-buttons .primary-btn {
        background: linear-gradient(135deg, #1e40af, #3b82f6) !important;
        color: white !important;
        box-shadow: 0 2px 4px rgba(30, 64, 175, 0.2) !important;
    }
    
    #mobileMenu .action-buttons .primary-btn:hover {
        background: linear-gradient(135deg, #1e3a8a, #2563eb) !important;
        box-shadow: 0 4px 8px rgba(30, 64, 175, 0.3) !important;
    }
    
    #mobileMenu .action-buttons .secondary-btn {
        background: white !important;
        color: #1e40af !important;
        border: 1px solid #cbd5e1 !important;
    }
    
    #mobileMenu .action-buttons .secondary-btn:hover {
        background: #f8fafc !important;
        border-color: #1e40af !important;
    }
    
    /* Animations */
    @keyframes slideDown {
        from {
            opacity: 0;
            max-height: 0;
        }
        to {
            opacity: 1;
            max-height: 500px;
        }
    }
}

/* =============================================
   OVERLAY FOR TABLET MENU
   ============================================= */
@media screen and (min-width: 768px) and (max-width: 1279px) {
    .menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 9998;
        opacity: 0;
        transition: opacity 0.35s ease;
    }
    
    .menu-overlay.active {
        display: block;
        opacity: 1;
    }
}

/* =============================================
   MOBILE UNCHANGED (< 768px)
   ============================================= */
@media screen and (max-width: 767px) {
    /* Original mobile behavior */
    #mobileMenuBtn {
        display: flex !important;
    }
    
    nav.tablet-nav-fix {
        display: none !important;
    }
    
    .tablet-action-buttons {
        display: none !important;
    }
    
    /* Mobile menu uses original styling */
    #mobileMenu {
        top: 90px !important;
        height: calc(100vh - 90px) !important;
        max-height: none !important;
        overflow-y: auto !important;
    }
    
    /* Mobile menu content wrapper padding */
    #mobileMenu .menu-content-wrapper {
        padding: 1rem 0 12rem 0 !important;
        overflow-y: auto !important;
    }
    
    .tablet-menu-header {
        display: none !important;
    }
}

/* =============================================
   DESKTOP UNCHANGED (≥ 1280px)
   ============================================= */
@media screen and (min-width: 1280px) {
    nav.tablet-nav-fix {
        display: flex !important;
    }
    
    .tablet-action-buttons {
        display: flex !important;
    }
    
    #mobileMenuBtn {
        display: none !important;
    }
    
    #mobileMenu {
        display: none !important;
    }
    
    .tablet-menu-header {
        display: none !important;
    }
}
