/* اتجاه الواجهة يتبع لغة البرنامج (html[dir]) — يُحمَّل آخراً بعد قشور الستايل */
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}
html[dir="ltr"] {
    direction: ltr;
}
html[dir="ltr"] body {
    direction: ltr;
    text-align: left;
}

html[dir="ltr"] .main-header,
html[dir="ltr"] .main-content {
    margin-right: 0;
    margin-left: var(--fx-sidebar-w);
}
html[dir="ltr"] .sidebar-container {
    right: auto !important;
    left: 0 !important;
    border-left-width: 0 !important;
    border-right: 1px solid var(--fx-border);
}
html[dir="ltr"] .sidebar .nav-link {
    text-align: left;
}
html[dir="ltr"] .fx-quick-menu {
    right: auto;
    left: calc(var(--fx-sidebar-w) + 0.75rem);
}

html[dir="ltr"][data-fx-shell="glass"] .sidebar-container {
    right: auto !important;
    left: 0 !important;
    border-left-width: 0 !important;
    border-right: 1px solid var(--fx-glass-border, var(--fx-border)) !important;
}
html[dir="ltr"][data-fx-shell="glass"] .main-header,
html[dir="ltr"][data-fx-shell="glass"] .main-content {
    margin-right: 0 !important;
    margin-left: var(--fx-sidebar-w) !important;
}

html[dir="ltr"] body.fx-cashier-shell .main-header,
html[dir="ltr"] body.fx-cashier-shell .main-content {
    margin-left: 0;
    margin-right: 0;
}

html[dir="ltr"][data-fx-shell="windows7"] .sidebar-container {
    border-right-color: var(--fx-w7-border, var(--fx-border));
}
html[dir="ltr"][data-fx-shell="windows7"] .main-header,
html[dir="ltr"][data-fx-runtime="desktop"] .main-header {
    right: 0 !important;
    left: var(--fx-sidebar-w) !important;
    margin-left: 0;
    margin-right: 0;
}
html[dir="ltr"][data-fx-shell="windows7"] .main-content,
html[dir="ltr"][data-fx-runtime="desktop"] .main-content {
    right: 0 !important;
    left: var(--fx-sidebar-w) !important;
    margin-left: 0;
    margin-right: 0;
}
html[dir="ltr"][data-fx-runtime="desktop"] body.fx-cashier-shell .main-header,
html[dir="ltr"][data-fx-runtime="desktop"] body.fx-cashier-shell .main-content,
html[dir="ltr"][data-fx-shell="windows7"] body.fx-cashier-shell .main-header,
html[dir="ltr"][data-fx-shell="windows7"] body.fx-cashier-shell .main-content {
    left: 0 !important;
    right: 0 !important;
}

/* سايدبار: سكة أيقونات 72px، تنبسط فوق الصفحة عند المرور دون قفز النص */
@media (min-width: 992px) {
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) {
        --fx-sidebar-rail: 72px;
        --fx-sidebar-open: 260px;
        --fx-sidebar-w: var(--fx-sidebar-rail);
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container {
        width: var(--fx-sidebar-rail);
        overflow: hidden;
        z-index: 1400;
        transition: width .3s ease-in-out, box-shadow .3s ease-in-out;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container:hover,
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container:focus-within {
        width: var(--fx-sidebar-open);
        box-shadow: 0 8px 28px rgba(16, 24, 40, .18);
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-project-head,
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-sidebar-hr {
        width: var(--fx-sidebar-open);
        min-width: var(--fx-sidebar-open);
        max-width: var(--fx-sidebar-open);
        align-self: flex-start;
        flex-shrink: 0;
        box-sizing: border-box;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .sidebar {
        width: var(--fx-sidebar-open);
        min-width: var(--fx-sidebar-open);
        max-width: var(--fx-sidebar-open);
        align-self: flex-start;
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-project-head {
        padding: 0.7rem 0 0.35rem;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-project-brand,
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-project-brand-home {
        width: var(--fx-sidebar-open);
        gap: 0;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-project-logo-wrap {
        width: var(--fx-sidebar-rail);
        flex: 0 0 var(--fx-sidebar-rail);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-project-logo {
        width: 40px;
        height: 40px;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-nav-group-label {
        max-height: 2.4rem;
        overflow: hidden;
        transition: opacity .22s ease, max-height .25s ease, margin .25s ease, padding .25s ease;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-project-name,
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-project-logo-edit,
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-page-search-trigger-label,
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-page-search-trigger-kbd {
        transition: opacity .22s ease;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-project-name {
        white-space: nowrap;
        -webkit-line-clamp: 1;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .sidebar {
        padding: 0.15rem 0 0.75rem;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-page-search-trigger,
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .sidebar .nav-link {
        width: var(--fx-sidebar-open);
        justify-content: flex-start;
        gap: 0;
        padding-inline: 0;
        margin-inline: 0;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .sidebar .nav-link > span {
        display: flex;
        align-items: center;
        gap: 0;
        width: var(--fx-sidebar-open);
        white-space: nowrap;
        font-size: 1.02rem;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .sidebar .nav-link .fx-ico,
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container .fx-page-search-trigger-ico {
        width: 22px;
        height: 22px;
        flex: 0 0 22px;
        margin-inline-start: 25px;
        margin-inline-end: 25px;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container:not(:hover):not(:focus-within) .fx-project-name,
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container:not(:hover):not(:focus-within) .fx-project-logo-edit,
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container:not(:hover):not(:focus-within) .fx-page-search-trigger-label,
    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container:not(:hover):not(:focus-within) .fx-page-search-trigger-kbd {
        opacity: 0;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container:not(:hover):not(:focus-within) .fx-page-search-trigger {
        border-color: transparent;
        background: transparent;
        box-shadow: none;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container:not(:hover):not(:focus-within) .fx-nav-group-label {
        opacity: 0;
        max-height: 0;
        margin: 0;
        padding: 0;
        overflow: hidden;
        border: 0;
        pointer-events: none;
    }

    html body:not(.fx-cashier-shell):not(.fx-invoice-shell):not(.fx-assistant-shell) .sidebar-container:not(:hover):not(:focus-within) #fxShortcutPicker {
        display: none !important;
    }
}

@media (max-width: 991.98px) {
    html[dir="ltr"] .main-header,
    html[dir="ltr"] .main-content {
        margin-left: 0;
        margin-right: 0;
    }
    html[dir="ltr"][data-fx-shell="windows7"] .main-header,
    html[dir="ltr"][data-fx-shell="windows7"] .main-content,
    html[dir="ltr"][data-fx-runtime="desktop"] .main-header,
    html[dir="ltr"][data-fx-runtime="desktop"] .main-content {
        left: 0 !important;
        right: 0 !important;
    }
}
