/**
 * Unified Layout System
 * Auto SEO Pilot - SaaS Platinum Edition v20.4
 * 
 * نظام تخطيط موحد وجذري - يحل جميع المشاكل بشكل نهائي
 * Single Source of Truth for all layout and positioning
 * 
 * IMPORTANT: This file must load LAST to override all other CSS rules
 * يتم تحميل هذا الملف آخراً لتجاوز جميع قواعد CSS الأخرى
 * 
 * CRITICAL RULES:
 * - Sidebar is overlay on desktop (>= 992px) - can be toggled
 * - Main content is full width by default
 * - When sidebar is open (body.sidebar-open), content moves to make space
 * - All calculations use CSS variables to prevent shifts
 * - Rules use !important to ensure they override conflicting styles
 * - This file is the ONLY source of truth for .main-content and .main-content-section positioning
 * 
 * CONFLICT RESOLUTION:
 * - Other CSS files (layout.css, smart-responsive.css, responsive.css) should NOT define
 *   base .main-content or .main-content-section rules to avoid conflicts
 * - This file overrides all conflicting rules with !important
 * 
 * FILE STRUCTURE:
 * 1. CSS Variables
 * 2. Base Layout System
 * 3. Sidebar System (Base + Desktop + Mobile/Tablet)
 * 4. Main Content System (Base + Desktop + Mobile/Tablet)
 * 5. Language Switcher
 * 6. Utility Classes
 * 7. Responsive Fixes
 */

/* ============================================
   CSS VARIABLES - CENTRAL CONTROL
   ============================================ */

:root {
    /* Sidebar Dimensions - CRITICAL: Single source of truth */
    --sidebar-width: 280px;
    --sidebar-width-tablet: 260px;
    --sidebar-width-mobile: 75vw;
    --sidebar-width-mobile-max: 300px;
    --sidebar-width-mobile-min: 250px;

    /* Gap between sidebar and main content */
    --sidebar-content-gap: 20px;

    /* Transitions */
    --transition-sidebar: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-content: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-Index Layers - Strict Hierarchy */
    --z-sidebar: 1050;
    /* Highest priority */
    --z-menu-btn: 1055;
    /* Button above sidebar */
    --z-overlay: 1040;
    /* Behind sidebar, above content */
    --z-content: 10;
    --z-section: 90;
    --z-section-active: 95;

    /* Content Spacing - Responsive padding */
    --content-padding-desktop: 30px;
    --content-padding-tablet: 20px;
    --content-padding-mobile: 15px;

    /* Dynamic Padding for responsive screens */
    --content-padding-xl: 40px;
    --content-padding-lg: 30px;
}

/* ============================================
   BASE LAYOUT SYSTEM
   ============================================ */

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

/* ============================================
   SIDEBAR - BASE SYSTEM
   ============================================ */

.modern-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
    max-width: var(--sidebar-width) !important;
    background: var(--bg-glass-sidebar);
    backdrop-filter: blur(var(--bg-glass-blur));
    z-index: 99999 !important;
    /* Extremely high to stay above dashboard content */
    display: flex !important;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;

    /* Unified Transitions */
    transition:
        transform var(--transition-sidebar),
        box-shadow var(--transition-sidebar),
        opacity var(--transition-sidebar),
        visibility var(--transition-sidebar) !important;
}

/* ========================================
   SMART AUTO POSITIONING (Logic Properties)
   This automatically handles RTL (Right) and LTR (Left)
   ======================================== */

.modern-sidebar {
    /* Auto-anchor to the start of the text flow (Right in RTL, Left in LTR) */
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;

    /* Auto-border on the inner side */
    border-inline-end: 1px solid var(--border-glass) !important;
    border-inline-start: none !important;

    /* Base State: Start hidden */
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* RTL Hidden State (Slide to right) */
[dir="rtl"] .modern-sidebar:not(.sidebar-visible):not(.mobile-active):not(.sidebar-open),
[dir="rtl"] .modern-sidebar.sidebar-hidden {
    transform: translateX(100%) !important;
    right: 0 !important;
    left: auto !important;
}

/* LTR Hidden State (Slide to left) */
[dir="ltr"] .modern-sidebar:not(.sidebar-visible):not(.mobile-active):not(.sidebar-open),
[dir="ltr"] .modern-sidebar.sidebar-hidden {
    transform: translateX(-100%) !important;
    left: 0 !important;
    right: auto !important;
}

/* Fallback for no [dir] (Assume RTL) */
:not([dir]) .modern-sidebar:not(.sidebar-visible):not(.mobile-active):not(.sidebar-open) {
    transform: translateX(100%) !important;
    right: 0 !important;
}

/* SMART VISIBLE STATE - Unified for all modes */
.modern-sidebar.sidebar-visible,
.modern-sidebar.mobile-active,
body.sidebar-open .modern-sidebar {
    transform: translateX(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    display: flex !important;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5) !important;
    z-index: 100000 !important;
    /* Topmost */
    /* Ensure anchored to start when visible */
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
}

/* ========================================
   SIDEBAR TOGGLE BUTTON - MOBILE FIX
   ======================================== */
@media (max-width: 991.98px) {
    :root {
        --sidebar-width: var(--sidebar-width-mobile);
    }

    /* Ensure sidebar respects new width and min/max constraints */
    .modern-sidebar {
        width: var(--sidebar-width) !important;
        min-width: var(--sidebar-width-mobile-min) !important;
        max-width: var(--sidebar-width-mobile-max) !important;
    }

    .sidebar-toggle-btn,
    #sidebarToggle,
    .mobile-menu-toggle,
    #mobileMenuToggle,
    button[onclick*="toggleSidebar"] {
        display: flex !important;
        position: fixed !important;
        top: 15px !important;
        left: 10px !important;
        /* Fixed position */
        z-index: 10010 !important;
        /* Above sidebar (10001) */
        visibility: visible !important;
        opacity: 1 !important;
        /* Premium Glass Button Dimensions */
        width: 44px !important;
        height: 44px !important;
        border-radius: 12px !important;

        /* Premium Glass Design */
        background: rgba(15, 23, 42, 0.6) !important;
        /* Darker glass for better contrast */
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2) !important;

        align-items: center !important;
        justify-content: center !important;
        flex-direction: column !important;
        gap: 5px !important;
        padding: 0 !important;
        cursor: pointer !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* Hover State */
    .sidebar-toggle-btn:hover,
    #sidebarToggle:hover,
    .mobile-menu-toggle:hover,
    #mobileMenuToggle:hover {
        background: rgba(15, 23, 42, 0.8) !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25) !important;
        border-color: rgba(99, 102, 241, 0.4) !important;
        /* Indigo tint on hover */
    }

    /* Style the hamburger lines (spans) */
    .mobile-menu-toggle span,
    #mobileMenuToggle span {
        display: block !important;
        width: 24px !important;
        height: 2.5px !important;
        background-color: var(--text-main, #ffffff) !important;
        border-radius: 2px;
        transition: all 0.3s ease;
        opacity: 1 !important;
    }

    /* Ensure white color in dark mode */
    @media (prefers-color-scheme: dark) {

        .mobile-menu-toggle span,
        #mobileMenuToggle span {
            background-color: #ffffff !important;
        }
    }

    /* Active state (X shape) if class is added (optional enhancement) */
    /* Active state (X shape) using aria-expanded */
    .mobile-menu-toggle[aria-expanded="true"] span:nth-child(1),
    #mobileMenuToggle[aria-expanded="true"] span:nth-child(1) {
        transform: translateY(7.5px) rotate(45deg) !important;
    }

    .mobile-menu-toggle[aria-expanded="true"] span:nth-child(2),
    #mobileMenuToggle[aria-expanded="true"] span:nth-child(2) {
        opacity: 0 !important;
    }

    .mobile-menu-toggle[aria-expanded="true"] span:nth-child(3),
    #mobileMenuToggle[aria-expanded="true"] span:nth-child(3) {
        transform: translateY(-7.5px) rotate(-45deg) !important;
    }



    /* Adjust position based on direction */
    html[dir="rtl"] .sidebar-toggle-btn,
    html[dir="rtl"] #sidebarToggle,
    html[dir="rtl"] .mobile-menu-toggle,
    html[dir="rtl"] #mobileMenuToggle {
        left: 10px !important;
        right: auto !important;
    }

    html[dir="ltr"] .sidebar-toggle-btn,
    html[dir="ltr"] #sidebarToggle,
    html[dir="ltr"] .mobile-menu-toggle,
    html[dir="ltr"] #mobileMenuToggle {
        left: 10px !important;
        right: auto !important;
    }
}

/* ============================================
   SIDEBAR CLOSE BUTTON
   ============================================ */

.sidebar-close-btn {
    position: absolute;
    top: 1rem;
    z-index: 10;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    color: #6366f1;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

/* RTL: Close button on left */
[dir="rtl"] .sidebar-close-btn,
html[dir="rtl"] .sidebar-close-btn {
    left: 1rem;
    right: auto;
}

/* LTR: Close button on right */
[dir="ltr"] .sidebar-close-btn,
html[dir="ltr"] .sidebar-close-btn {
    right: 1rem;
    left: auto;
}

/* Fallback (RTL default) */
:root:not([dir]) .sidebar-close-btn,
html:not([dir]) .sidebar-close-btn {
    left: 1rem;
    right: auto;
}

.sidebar-close-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.5);
    color: #4f46e5;
    transform: scale(1.05);
}

.sidebar-close-btn:active {
    transform: scale(0.95);
}

.sidebar-close-btn i {
    line-height: 1;
}

/* ============================================
   DESKTOP SIDEBAR (>= 992px) - OVERLAY MODE
   ============================================ */

@media (min-width: 992px) {
    /* ========================================
       MOBILE MENU TOGGLE BUTTON
       ======================================== */

    .mobile-menu-toggle,
    #mobileMenuToggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        position: fixed !important;
        top: 20px !important;
        z-index: var(--z-menu-btn) !important;
        align-items: center !important;
        justify-content: center !important;
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
        padding: 0 !important;
        margin: 0 !important;
        background: var(--bg-card, #ffffff) !important;
        border: 1px solid var(--border, rgba(0, 0, 0, 0.1)) !important;
        border-radius: 12px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08) !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        overflow: hidden !important;
        text-align: center !important;
        line-height: 1 !important;
        flex-direction: row !important;
        /* CRITICAL: Hide any stray text inside button */
        font-size: 0 !important;
        color: transparent !important;
        text-indent: -9999px !important;
    }

    /* RTL: Button on right */
    [dir="rtl"] .mobile-menu-toggle,
    [dir="rtl"] #mobileMenuToggle {
        right: 20px !important;
        left: auto !important;
    }

    /* LTR: Button on left */
    [dir="ltr"] .mobile-menu-toggle,
    [dir="ltr"] #mobileMenuToggle {
        left: 20px !important;
        right: auto !important;
    }

    /* Icon inside button */
    .mobile-menu-toggle i,
    #mobileMenuToggle i,
    .mobile-menu-toggle #menuIcon,
    #mobileMenuToggle #menuIcon {
        font-size: 20px !important;
        line-height: 1 !important;
        width: 20px !important;
        height: 20px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: var(--text-main, #374151) !important;
        transition: color 0.2s ease !important;
        margin: 0 !important;
        padding: 0 !important;
        font-family: "Font Awesome 6 Free" !important;
        font-weight: 900 !important;
        font-style: normal !important;
        text-rendering: auto !important;
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
        opacity: 1 !important;
        visibility: visible !important;
        /* Reset parent's text hiding */
        text-indent: 0 !important;
    }

    /* Support for span-based hamburger lines in Desktop button */
    .mobile-menu-toggle span,
    #mobileMenuToggle span {
        display: block !important;
        width: 20px !important;
        height: 2px !important;
        background-color: var(--text-main, #374151) !important;
        border-radius: 2px;
        transition: all 0.3s ease;
        opacity: 1 !important;
        margin: 0 !important;
        /* Ensure spans are visible by overriding font-size: 0 on parent */
        visibility: visible !important;
    }

    .mobile-menu-toggle,
    #mobileMenuToggle {
        /* Re-center spans horizontally */
        flex-direction: column !important;
        gap: 4px !important;
    }

    /* Hover state */
    .mobile-menu-toggle:hover,
    #mobileMenuToggle:hover {
        background: var(--bg-secondary, #f9fafb) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1) !important;
        transform: translateY(-1px) !important;
    }

    .mobile-menu-toggle:hover i,
    #mobileMenuToggle:hover i,
    .mobile-menu-toggle:hover #menuIcon,
    #mobileMenuToggle:hover #menuIcon,
    .mobile-menu-toggle:hover span,
    #mobileMenuToggle:hover span {
        color: var(--accent, #6366f1) !important;
        background-color: var(--accent, #6366f1) !important;
    }

    /* Active state (when sidebar is open) */
    .mobile-menu-toggle[aria-expanded="true"],
    #mobileMenuToggle[aria-expanded="true"] {
        background: var(--accent, #6366f1) !important;
        border-color: var(--accent, #6366f1) !important;
    }

    .mobile-menu-toggle[aria-expanded="true"] i,
    #mobileMenuToggle[aria-expanded="true"] i,
    .mobile-menu-toggle[aria-expanded="true"] #menuIcon,
    #mobileMenuToggle[aria-expanded="true"] #menuIcon {
        color: #ffffff !important;
    }

    /* ========================================
       SIDEBAR - OVERLAY MODE (Desktop)
       ======================================== */

    /* Base sidebar properties - NO position defaults here */
    .modern-sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        height: 100vh !important;
        width: var(--sidebar-width) !important;
        min-width: var(--sidebar-width) !important;
        max-width: var(--sidebar-width) !important;
        z-index: var(--z-sidebar) !important;
        display: flex !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.3s ease,
            visibility 0.3s ease !important;
    }

    /* ========================================
       RTL DESKTOP (Arabic - Sidebar on RIGHT)
       ======================================== */

    /* RTL: Position sidebar on RIGHT side */
    html[dir="rtl"] .modern-sidebar {
        right: 0 !important;
        left: auto !important;
        border-left: 1px solid var(--border-glass) !important;
        border-right: none !important;
    }

    /* RTL: Hidden state - slide OUT to right */
    html[dir="rtl"] .modern-sidebar:not(.sidebar-visible):not(.mobile-active) {
        transform: translateX(100%) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    /* RTL: Visible state - slide IN from right */
    html[dir="rtl"] .modern-sidebar.sidebar-visible,
    html[dir="rtl"] .modern-sidebar.mobile-active {
        transform: translateX(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        right: 0 !important;
        left: auto !important;
    }

    /* ========================================
       LTR DESKTOP (English - Sidebar on LEFT)
       ======================================== */

    /* LTR: Position sidebar on LEFT side */
    html[dir="ltr"] .modern-sidebar {
        left: 0 !important;
        right: auto !important;
        border-right: 1px solid var(--border-glass) !important;
        border-left: none !important;
    }

    /* LTR: Hidden state - slide OUT to left */
    html[dir="ltr"] .modern-sidebar:not(.sidebar-visible):not(.mobile-active) {
        transform: translateX(-100%) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    /* LTR: Visible state - slide IN from left */
    html[dir="ltr"] .modern-sidebar.sidebar-visible,
    html[dir="ltr"] .modern-sidebar.mobile-active {
        transform: translateX(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        left: 0 !important;
        right: auto !important;
    }

    /* ========================================
       GLOBAL VISIBLE STATE (Fallback)
       ======================================== */

    .modern-sidebar.sidebar-visible,
    .modern-sidebar.mobile-active {
        transform: translateX(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        display: flex !important;
        z-index: 10001 !important;
    }

    /* Sidebar overlay - shows when sidebar is visible */
    .sidebar-overlay,
    #sidebarOverlay {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0, 0, 0, 0.4) !important;
        z-index: var(--z-overlay) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transition: opacity 0.3s ease, visibility 0.3s ease !important;
    }

    .sidebar-overlay.active,
    #sidebarOverlay.active {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    /* ========================================
       CONTENT WRAPPER - DESKTOP
       ======================================== */

    /* Content Wrapper - Full width by default */
    .content-wrapper {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
            margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1),
            width 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* ========================================
       CONTENT PUSH LOGIC (Desktop >= 992px)
       Dynamic margin that moves with sidebar
       ======================================== */

    /* ----------------------------------------
       RTL (Arabic): Content moves LEFT when sidebar opens
       ---------------------------------------- */
    html[dir="rtl"] body.sidebar-open .content-wrapper,
    [dir="rtl"] body.sidebar-open .content-wrapper,
    :root[dir="rtl"] body.sidebar-open .content-wrapper {
        margin-right: var(--sidebar-width) !important;
        margin-left: 0 !important;
        width: calc(100% - var(--sidebar-width)) !important;
    }

    /* RTL: When sidebar closes, reset margin */
    html[dir="rtl"] body:not(.sidebar-open) .content-wrapper,
    [dir="rtl"] body:not(.sidebar-open) .content-wrapper,
    :root[dir="rtl"] body:not(.sidebar-open) .content-wrapper {
        margin-right: 0 !important;
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* ----------------------------------------
       LTR (English): Content moves RIGHT when sidebar opens
       ---------------------------------------- */
    html[dir="ltr"] body.sidebar-open .content-wrapper,
    [dir="ltr"] body.sidebar-open .content-wrapper,
    :root[dir="ltr"] body.sidebar-open .content-wrapper {
        margin-left: var(--sidebar-width) !important;
        margin-right: 0 !important;
        width: calc(100% - var(--sidebar-width)) !important;
    }

    /* LTR: When sidebar closes, reset margin */
    html[dir="ltr"] body:not(.sidebar-open) .content-wrapper,
    [dir="ltr"] body:not(.sidebar-open) .content-wrapper,
    :root[dir="ltr"] body:not(.sidebar-open) .content-wrapper {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }

    /* Fallback: Default to RTL if no dir attribute */
    :root:not([dir]) body.sidebar-open .content-wrapper,
    html:not([dir]) body.sidebar-open .content-wrapper {
        margin-right: var(--sidebar-width) !important;
        margin-left: 0 !important;
        width: calc(100% - var(--sidebar-width)) !important;
    }

    :root:not([dir]) body:not(.sidebar-open) .content-wrapper,
    html:not([dir]) body:not(.sidebar-open) .content-wrapper {
        margin-right: 0 !important;
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Ensure scrolling is allowed when sidebar is open */
    body.sidebar-active,
    body.sidebar-open,
    body.sidebar-active.sidebar-open {
        overflow: auto !important;
        overflow-y: auto !important;
        position: relative !important;
        width: auto !important;
    }

    html body.sidebar-active,
    html body.sidebar-open {
        overflow: auto !important;
        overflow-y: auto !important;
    }

    /* Main content inside wrapper - moves dynamically with sidebar */
    .content-wrapper .main-content {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
        padding-left: var(--content-padding-desktop);
        padding-right: var(--content-padding-desktop);
    }

    /* Sections inside wrapper - move dynamically with sidebar */
    .content-wrapper .main-content-section {
        position: relative;
        left: auto;
        right: auto;
        top: auto;
        bottom: auto;
        width: 100%;
        max-width: 100%;
        max-height: none;
        box-sizing: border-box;
        overflow-x: hidden;
        padding-left: var(--content-padding-desktop);
        padding-right: var(--content-padding-desktop);
    }

    /* Prevent content shifting - ensure padding consistency */
    .main-content>*:first-child {
        margin-top: 0 !important;
    }
}

/* ============================================
   CONTENT WRAPPER - UNIFIED CONTAINER
   ============================================ */

.content-wrapper {
    position: relative;
    width: 100%;
    max-width: 100vw;
    min-height: auto;
    box-sizing: border-box;
    /* Dynamic margin transition - smooth movement with sidebar */
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Default: No margin when sidebar is closed */
    margin-left: 0;
    margin-right: 0;
}

/* ============================================
   CRITICAL FIX: Ensure ALL children move together
   ============================================ */

/* Ensure all direct children and sections inherit wrapper movement */
.content-wrapper>*,
.content-wrapper .main-content,
.content-wrapper .main-content-section {
    /* Remove any fixed/absolute positioning that would prevent movement */
    position: relative !important;
}

/* Prevent inline styles or other CSS from overriding movement */
.content-wrapper .main-content-section {
    /* Reset any margins that might conflict */
    margin-left: 0 !important;
    margin-right: 0 !important;
    /* Reset any positioning that might conflict */
    left: auto !important;
    right: auto !important;
    /* Reset any transforms that might conflict */
    transform: none !important;
    /* Ensure full width within wrapper */
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}


/* ============================================
   MAIN CONTENT - BASE SYSTEM
   ============================================ */

.main-content {
    position: relative;
    min-height: 100vh !important;
    /* Forces content to fill viewport even if short */
    padding: var(--content-padding-desktop);
    padding-bottom: 50px;
    box-sizing: border-box;
    background: var(--bg-main-gradient);
    z-index: var(--z-content);
    width: 100%;
    max-width: 100%;
    transition: padding 0.3s ease, background 0.3s ease;
}

.main-content-section {
    position: relative;
    padding: var(--content-padding-desktop);
    min-height: auto;
    box-sizing: border-box;
    background: var(--bg-main-gradient);
    z-index: var(--z-section);
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    transition:
        padding 0.3s ease,
        background 0.3s ease,
        opacity 0.3s ease,
        transform 0.3s ease;

    /* إضافة transitions سلسة للأقسام */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);

    /* Performance optimization */
    will-change: opacity, transform;
    /* Prevent layout shift */
    contain: layout style paint;
    /* GPU acceleration */
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* CRITICAL: Hide inactive sections completely to prevent content bleeding */
.main-content-section:not(.active) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    z-index: -1 !important;
    pointer-events: none !important;
    height: 0 !important;
    overflow: hidden !important;
    /* Prevent text selection from hidden sections */
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* Active section should be on top - merged rules */
.main-content-section.active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    /* CRITICAL: relative NOT fixed */
    z-index: 10 !important;
    /* CRITICAL: 10 NOT 100 */
    pointer-events: auto !important;
    transform: translateY(0) translateZ(0) !important;
    height: auto !important;
    overflow: visible !important;
    /* Remove will-change after animation completes */
    will-change: auto;
}

/* CRITICAL: Override any inline styles that try to set position: fixed */
.main-content-section.active[style*="position: fixed"],
.main-content-section.active[style*="position:fixed"] {
    position: relative !important;
}

/* CRITICAL: Override any inline styles that try to set z-index: 100 */
.main-content-section.active[style*="z-index: 100"],
.main-content-section.active[style*="z-index:100"] {
    z-index: 10 !important;
}

/* Ensure dashboardOnlyContent is hidden when any section is active */
.main-content-section.active~#dashboardOnlyContent,
body:has(.main-content-section.active) #dashboardOnlyContent,
body.has-active-section #dashboardOnlyContent,
body.has-active-section #dashboardOnlyContent[style*="display: block"],
body.has-active-section #dashboardOnlyContent[style*="display:block"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    z-index: -1 !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    clip-path: inset(0 0 0 0) !important;
    clip: rect(0, 0, 0, 0) !important;
}

/* Show dashboard when no sections are active */
body:not(:has(.main-content-section.active)):not(.has-active-section) #dashboardOnlyContent {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1 !important;
    height: auto !important;
    overflow: visible !important;
}

/* Section base positioning - handled by desktop media query */

/* ============================================
   RESPONSIVE BREAKPOINTS - MAIN CONTENT
   ============================================ */

/* Large Desktop: >= 1400px */
@media (min-width: 1400px) {

    .main-content,
    .main-content-section {
        max-width: 100% !important;
        padding-left: var(--content-padding-xl) !important;
        padding-right: var(--content-padding-xl) !important;
    }
}

/* Desktop: 1200px - 1399px */
@media (min-width: 1200px) and (max-width: 1399px) {

    .main-content,
    .main-content-section {
        max-width: 100% !important;
        padding-left: var(--content-padding-lg) !important;
        padding-right: var(--content-padding-lg) !important;
    }
}

/* Standard Desktop: 992px - 1199px */
@media (min-width: 992px) and (max-width: 1199px) {

    .main-content,
    .main-content-section {
        max-width: 100% !important;
        padding-left: var(--content-padding-desktop) !important;
        padding-right: var(--content-padding-desktop) !important;
    }
}

/* ============================================
   TABLET (769px - 991px)
   ============================================ */

@media (min-width: 769px) and (max-width: 991px) {
    :root {
        --sidebar-width: var(--sidebar-width-tablet);
    }

    /* RTL Tablet - Sidebar on right, hidden by default */
    html[dir="rtl"] .modern-sidebar {
        right: 0 !important;
        left: auto !important;
    }

    html[dir="rtl"] .modern-sidebar:not(.mobile-active) {
        transform: translateX(100%) !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    html[dir="rtl"] .modern-sidebar.mobile-active {
        transform: translateX(0) !important;
        right: 0 !important;
        left: auto !important;
    }

    /* LTR Tablet - Sidebar on left, hidden by default */
    html[dir="ltr"] .modern-sidebar {
        left: 0 !important;
        right: auto !important;
    }

    html[dir="ltr"] .modern-sidebar:not(.mobile-active) {
        transform: translateX(-100%) !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    html[dir="ltr"] .modern-sidebar.mobile-active {
        transform: translateX(0) !important;
        left: 0 !important;
        right: auto !important;
    }

    /* Active State - Show sidebar (common) */
    .modern-sidebar.mobile-active {
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        display: flex !important;
        z-index: 10000 !important;
    }

    /* Content wrapper: Full width on tablet (overlay mode - no push) */
    .content-wrapper {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .main-content,
    .main-content-section {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding-left: var(--content-padding-tablet) !important;
        padding-right: var(--content-padding-tablet) !important;
    }
}

/* ============================================
   MOBILE (Max 768px) - OVERLAY MODE
   ============================================ */

@media (max-width: 768px) {

    /* CRITICAL: Prevent body scroll when sidebar is open on mobile */
    body.sidebar-active,
    body.sidebar-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
    }

    html.sidebar-active {
        overflow: hidden !important;
    }

    /* OVERLAY LOGIC: Content NEVER moves on mobile */
    .content-wrapper {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .main-content,
    .main-content-section {
        margin-inline-start: 0 !important;
        margin-inline-end: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding-left: var(--content-padding-mobile) !important;
        padding-right: var(--content-padding-mobile) !important;
        padding-top: var(--content-padding-mobile) !important;
        padding-bottom: var(--content-padding-mobile) !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
        inset-inline-start: 0 !important;
        inset-inline-end: 0 !important;
    }

    /* Force zero margin even when sidebar is open */
    body.sidebar-open .content-wrapper {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        transform: none !important;
    }

    body.sidebar-open .main-content,
    body.sidebar-open .main-content-section {
        margin-inline-start: 0 !important;
        width: 100% !important;
        transform: none !important;
    }

    /* Ensure all internal containers use full width */
    .main-content>*,
    .main-content-section>* {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Dashboard cards and containers - Full width */
    /* CRITICAL: Scope to #dashboardOnlyContent only to prevent affecting sections */
    #dashboardOnlyContent .card,
    #dashboardOnlyContent .header,
    #dashboardOnlyContent .form-card,
    #dashboardOnlyContent .stat-card,
    #dashboardOnlyContent .ai-insights-widget,
    #dashboardOnlyContent .quick-actions-grid,
    #dashboardOnlyContent .grid-stats,
    #dashboardOnlyContent .actions-grid,
    #dashboardOnlyContent .dashboard-widget,
    #dashboardOnlyContent [class*="card"],
    #dashboardOnlyContent [class*="widget"],
    #dashboardOnlyContent [class*="container"]:not(.quick-search-container) {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-inline-start: 0 !important;
        margin-inline-end: 0 !important;
        box-sizing: border-box !important;
    }

    /* Header and breadcrumbs - Full width (dashboard only) */
    #dashboardOnlyContent .header,
    #dashboardOnlyContent .breadcrumbs {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Header title and text - Prevent text compression (dashboard only) */
    #dashboardOnlyContent .header-title,
    #dashboardOnlyContent .header-title h2,
    #dashboardOnlyContent .header-title p,
    #dashboardOnlyContent .header-title * {
        width: 100% !important;
        max-width: 100% !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        box-sizing: border-box !important;
    }

    /* Ensure flex containers don't compress content (dashboard only) */
    #dashboardOnlyContent .header {
        flex-wrap: wrap !important;
        gap: 12px !important;
    }

    /* Text content - Allow proper wrapping (dashboard only) */
    #dashboardOnlyContent p,
    #dashboardOnlyContent span,
    #dashboardOnlyContent div:not([class*="grid"]):not([class*="flex"]) {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        max-width: 100% !important;
    }

    /* Sidebar: Off-canvas */
    .modern-sidebar {
        width: var(--sidebar-width-mobile) !important;
        max-width: var(--sidebar-width-mobile-max) !important;
        min-width: var(--sidebar-width-mobile-min) !important;
    }

    /* RTL Mobile Sidebar - Position on right */
    html[dir="rtl"] .modern-sidebar {
        right: 0 !important;
        left: auto !important;
    }

    /* RTL Mobile - Hidden by default */
    html[dir="rtl"] .modern-sidebar:not(.mobile-active) {
        transform: translateX(100%) !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* RTL Mobile - Visible state */
    html[dir="rtl"] .modern-sidebar.mobile-active {
        transform: translateX(0) !important;
        right: 0 !important;
        left: auto !important;
    }

    /* LTR Mobile Sidebar - Position on left */
    html[dir="ltr"] .modern-sidebar {
        left: 0 !important;
        right: auto !important;
    }

    /* LTR Mobile - Hidden by default */
    html[dir="ltr"] .modern-sidebar:not(.mobile-active) {
        transform: translateX(-100%) !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* LTR Mobile - Visible state */
    html[dir="ltr"] .modern-sidebar.mobile-active {
        transform: translateX(0) !important;
        left: 0 !important;
        right: auto !important;
    }

    /* Active State - Show sidebar (common) */
    .modern-sidebar.mobile-active {
        transform: translateX(0) !important;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        display: flex !important;
        z-index: 10000 !important;
    }

    /* Prevent horizontal overflow */
    body,
    html {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* Mobile Menu Toggle Button */
    .mobile-menu-toggle,
    #mobileMenuToggle {
        display: flex !important;
        /* Fixed: Changed from block to flex for proper icon display */
    }

    /* Dark Overlay Background */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(3px);
        z-index: var(--z-overlay);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity var(--transition-sidebar), visibility var(--transition-sidebar);
    }

    body.sidebar-open .sidebar-overlay,
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

/* Small Mobile: Max 480px */
@media (max-width: 480px) {
    :root {
        --sidebar-width-mobile: 85vw;
        --sidebar-width-mobile-max: 280px;
    }

    .main-content,
    .main-content-section {
        padding-inline-start: 12px;
        padding-inline-end: 12px;
    }
}

/* ============================================
   LANGUAGE SWITCHING FIXES
   ============================================ */

/* Force correct positioning on direction change */
html[dir="rtl"] body .modern-sidebar,
html[dir="ltr"] body .modern-sidebar,
html[dir="rtl"] .modern-sidebar,
html[dir="ltr"] .modern-sidebar {
    will-change: transform, inset-inline-start, inset-inline-end;
    position: fixed !important;
}

/* Ultra-specific overrides for sidebar positioning */
html[dir="rtl"] body .modern-sidebar {
    inset-inline-end: 0 !important;
    inset-inline-start: auto !important;
    right: 0 !important;
    left: auto !important;
}

html[dir="ltr"] body .modern-sidebar {
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
    left: 0 !important;
    right: auto !important;
}

/* Prevent layout shift during language switch */
body.language-switching {
    overflow: hidden;
}

body.language-switching * {
    pointer-events: none;
}

body.language-switching .modern-sidebar,
body.language-switching .main-content,
body.language-switching .main-content-section {
    pointer-events: auto;
}

/* ============================================
   LANGUAGE SWITCHER - ENHANCED STYLING
   ============================================ */

.language-switcher {
    position: relative;
    display: inline-block;
    width: 100%;
    margin-block-end: 12px;
}

.lang-switch-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    width: 100%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border: 1.5px solid rgba(99, 102, 241, 0.3);
    border-radius: 14px;
    color: #ffffff !important;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

/* Force white text color on all language button elements */
.lang-switch-btn *,
.lang-switch-btn span,
.lang-switch-btn span *,
.lang-switch-btn #currentLangDisplay,
span#currentLangDisplay,
#currentLangDisplay,
button.lang-switch-btn *,
button.lang-switch-btn span,
button.lang-switch-btn #currentLangDisplay,
#langSwitchBtn *,
#langSwitchBtn span,
#langSwitchBtn #currentLangDisplay {
    color: #ffffff !important;
}

.lang-switch-btn #currentLangDisplay,
span#currentLangDisplay,
#currentLangDisplay {
    font-weight: 700 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5) !important;
}

.lang-switch-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.lang-switch-btn:hover::before {
    left: 100%;
}

.lang-switch-btn:disabled {
    opacity: 0.6;
    cursor: wait;
    pointer-events: none;
}

.lang-switch-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(139, 92, 246, 0.25) 100%);
    border-color: rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-start: 0;
    background: var(--card-bg, rgba(30, 41, 59, 0.95));
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    max-width: 200px;
    z-index: 10000;
    overflow: hidden;
    backdrop-filter: blur(10px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    transform-origin: top;
}

/* RTL Dropdown Position */
[dir="rtl"] .lang-dropdown,
html[dir="rtl"] .lang-dropdown {
    inset-inline-start: auto !important;
    inset-inline-end: 0 !important;
}

/* LTR Dropdown Position */
[dir="ltr"] .lang-dropdown,
html[dir="ltr"] .lang-dropdown {
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: #ffffff !important;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    text-align: start;
    box-sizing: border-box;
}

.lang-option:hover {
    background: rgba(96, 165, 250, 0.2) !important;
    color: #ffffff !important;
}

.lang-option.active {
    background: rgba(99, 102, 241, 0.3) !important;
    color: #60a5fa !important;
    font-weight: 700 !important;
}

/* Force white text color on lang-name elements */
.lang-option .lang-name,
.lang-dropdown .lang-option .lang-name,
.lang-dropdown .lang-option span {
    color: #ffffff !important;
    font-weight: 600 !important;
}

.lang-option.active .lang-name {
    color: #60a5fa !important;
    font-weight: 700 !important;
}

.lang-option:hover .lang-name {
    color: #ffffff !important;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.force-layout-recalc {
    transform: translateZ(0);
    will-change: transform;
}

.prevent-layout-shift {
    contain: layout style paint;
}

.smooth-transition {
    transition: all var(--transition-content);
}

/* ============================================
   RESPONSIVE FIXES
   ============================================ */

/* All containers flexible */
.container,
.container-fluid {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

/* Flexible grids */
.grid,
.grid-stats,
.actions-grid {
    display: grid;
    gap: 1rem;
    box-sizing: border-box;
}

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
}

/* Responsive tables */
/* Responsive tables - FIXED: Use wrapper instead of breaking table display */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    /* NEVER use display: block on table - it breaks table layout */
    display: table;
}

/* Flexible buttons */
button,
.btn,
.nav-btn {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

/* Responsive text */
@media (max-width: 480px) {
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    h4 {
        font-size: 1.1rem;
    }

    p,
    span,
    div {
        font-size: 0.9rem;
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {

    /* Fix images and media only - NOT all elements (FIXED: Removed dangerous wildcard) */
    img,
    video,
    canvas,
    iframe {
        max-width: 100%;
        height: auto;
    }

    /* Stack elements */
    .flex-row {
        flex-direction: column;
    }

    /* Full width buttons */
    button,
    .btn {
        width: 100%;
    }

    /* ============================================
       MOBILE & TABLET (Overlay Mode)
       ============================================ */
    /* في الموبايل، المحتوى لا يتحرك أبداً */
    /* القائمة تظهر فوق المحتوى (Overlay) */

    html[dir="ltr"] body.sidebar-open .main-content,
    html[dir="rtl"] body.sidebar-open .main-content,
    body.sidebar-open[dir="ltr"] .main-content,
    body.sidebar-open[dir="rtl"] .main-content {
        margin-left: 0;
        margin-right: 0;
        margin-inline-start: 0;
        margin-inline-end: 0;
        width: 100%;
        transform: none;
        /* إلغاء أي إزاحة */
    }
}

/* ============================================
   CRITICAL: Prevent Sidebar/Overlay from Affecting Page Scroll
   ============================================ */
/* When sidebar/overlay are hidden, ensure they don't contribute to page height */
/* This prevents the "invisible scrollable content" issue */

/* Hidden sidebar: position fixed, off-screen, no scroll contribution */
/* Hidden sidebar: use transform and visibility for smooth transitions */
.modern-sidebar:not(.sidebar-visible):not(.mobile-active),
#sidebar:not(.sidebar-visible):not(.mobile-active) {
    position: fixed !important;
    top: 0 !important;
    /* Removed left: -9999px to prevent layout jumps */
    width: var(--sidebar-width, 280px) !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
    /* Use visibility to hide from screen readers/tab order without layout hacks */
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    /* Use transform for smooth sliding off-screen */
    transform: translateX(-100%) !important;
    /* Ensure it doesn't affect document flow */
    margin: 0 !important;
    padding: 0 !important;
    z-index: 1000 !important;
    /* Keep z-index positive to avoid "popping" behind content */
}

/* RTL Support for hidden state */
html[dir="rtl"] .modern-sidebar:not(.sidebar-visible):not(.mobile-active),
html[dir="rtl"] #sidebar:not(.sidebar-visible):not(.mobile-active) {
    transform: translateX(100%) !important;
}

/* Hidden overlay: position fixed, no scroll contribution */
#sidebarOverlay:not(.active),
.sidebar-overlay:not(.active) {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
    /* Prevent scroll */
    z-index: -1 !important;
    /* Behind everything */
    pointer-events: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    /* Ensure it doesn't affect document flow */
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure hidden sidebar content doesn't affect page scroll */
/* Use contain: layout style paint to isolate it */
.modern-sidebar:not(.sidebar-visible):not(.mobile-active) *,
#sidebar:not(.sidebar-visible):not(.mobile-active) * {
    /* Prevent text selection from hidden sidebar */
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* Ensure sidebar content is clipped when hidden */
.modern-sidebar:not(.sidebar-visible):not(.mobile-active),
#sidebar:not(.sidebar-visible):not(.mobile-active) {
    contain: layout style paint !important;
    /* Isolate from page layout */
    will-change: transform !important;
    /* Optimize for transform animations */
}

/* RTL: Hidden sidebar off-screen to the right */
html[dir="rtl"] .modern-sidebar:not(.sidebar-visible):not(.mobile-active),
[dir="rtl"] .modern-sidebar:not(.sidebar-visible):not(.mobile-active),
html[dir="rtl"] #sidebar:not(.sidebar-visible):not(.mobile-active),
[dir="rtl"] #sidebar:not(.sidebar-visible):not(.mobile-active) {
    left: auto !important;
    right: -9999px !important;
    /* Off-screen to the right */
    transform: translateX(100%) !important;
}

/* LTR: Hidden sidebar off-screen to the left */
html[dir="ltr"] .modern-sidebar:not(.sidebar-visible):not(.mobile-active),
[dir="ltr"] .modern-sidebar:not(.sidebar-visible):not(.mobile-active),
html[dir="ltr"] #sidebar:not(.sidebar-visible):not(.mobile-active),
[dir="ltr"] #sidebar:not(.sidebar-visible):not(.mobile-active) {
    right: auto !important;
    left: -9999px !important;
    /* Off-screen to the left */
    transform: translateX(-100%) !important;
}

/* ============================================
   TABLET (769px - 991px) - Overlay Mode
   ============================================ */
@media (min-width: 769px) and (max-width: 991px) {

    /* OVERLAY LOGIC: Content NEVER moves on tablet */
    body.sidebar-open .main-content,
    body.sidebar-open .main-content-section {
        margin-inline-start: 0 !important;
        width: 100% !important;
        transform: none !important;
    }
}

/* ============================================
   SEO TOOLS - BACKLINKS TABS (Refactored)
   ============================================ */

.backlinks-tabs .tab-btn {
    padding: 12px 20px;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: var(--bg-dark);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.backlinks-tabs .tab-btn:hover {
    background: var(--bg-card);
    color: var(--text-main);
    border-color: var(--accent-light, #818cf8);
    transform: translateY(-2px);
}

.backlinks-tabs .tab-btn.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(139, 92, 246, 0.05)) !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
    color: var(--text-main) !important;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.1);
}

.backlinks-tabs .tab-btn i {
    margin-left: 8px;
    /* RTL support */
}

/* LTR Support for icons */
html[dir='ltr'] .backlinks-tabs .tab-btn i {
    margin-left: 0;
    margin-right: 8px;
}