.select2-height-42 + .select2-container .select2-selection--single {
    height: 42px;
}

.select2-height-42 + .select2-container .select2-selection--single .select2-selection__rendered {
    line-height: 40px;
}

.select2-height-42 + .select2-container .select2-selection--single .select2-selection__arrow {
    height: 40px;
}

.select2-height-42-multiple + .select2-container .select2-selection--multiple {
    min-height: 42px;
}

.select2-height-42-multiple + .select2-container .select2-selection--multiple .select2-selection__rendered {
    min-height: 40px;
}

/* ============================================================
   Header theme toggle (moon/sun) — dedicated layout so the icon
   stays perfectly centered in the 70px admin header, instead of
   inheriting the notification-bell wrapper's asymmetric padding.
   ============================================================ */
.theme-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    margin-inline-end: 10px;
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #555555;
    font-size: 18px;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.theme-toggle-btn:hover,
.theme-toggle-btn:focus-visible {
    background: rgba(27, 0, 255, 0.08);
    color: #1b00ff;
    outline: none;
}

.theme-toggle-btn:active {
    transform: scale(0.92);
}

.theme-toggle-btn i {
    font-size: 1.15rem;
    line-height: 1;
    color: #ffc107;
}

.theme-toggle-btn .theme-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-toggle-btn {
    color: var(--text-secondary);
}

[data-theme="dark"] .theme-toggle-btn:hover,
[data-theme="dark"] .theme-toggle-btn:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    color: var(--app-primary);
}

/* ============================================================
   Header "Visit Store" button — jumps to the public storefront.
   Matches the theme-toggle button's height, colors, and dark mode.
   ============================================================ */
.header-view-store-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    margin-inline-end: 10px;
}

.view-store-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    background: rgba(27, 0, 255, 0.08);
    color: #1b00ff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.view-store-btn:hover,
.view-store-btn:focus-visible {
    background: rgba(27, 0, 255, 0.14);
    color: #1b00ff;
    text-decoration: none;
    outline: none;
    box-shadow: 0 2px 10px rgba(27, 0, 255, 0.18);
}

.view-store-btn:active {
    transform: scale(0.96);
}

.view-store-btn i {
    font-size: 1rem;
    line-height: 1;
}

[data-theme="dark"] .view-store-btn {
    background: rgba(63, 90, 169, 0.28);
    color: var(--app-primary, #8fa8ff);
}

[data-theme="dark"] .view-store-btn:hover,
[data-theme="dark"] .view-store-btn:focus-visible {
    background: rgba(63, 90, 169, 0.42);
    color: var(--app-primary, #8fa8ff);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

@media (max-width: 575.98px) {
    .view-store-btn {
        width: 40px;
        padding: 0;
        justify-content: center;
    }

    .view-store-btn .view-store-label {
        display: none;
    }
}

/* Modern Alert Styles */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 20px;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid transparent;
    animation: alertSlideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes alertSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert .close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.4;
    line-height: 1;
    padding: 0;
    transition: opacity 0.2s, transform 0.2s;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert .close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.alert::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin-top: 1px;
}

.alert-success {
    background-color: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}
.alert-success::before {
    /* Success Checkmark Icon */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 11.08V12a10 10 0 1 1-5.93-9.14'/%3E%3Cpolyline points='22 4 12 14.01 9 11.01'/%3E%3C/svg%3E");
}
[data-theme="dark"] .alert-success {
    background-color: rgba(6, 95, 70, 0.15);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.2);
}

.alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}
.alert-danger::before {
    /* Danger Alert Icon */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E");
}
[data-theme="dark"] .alert-danger {
    background-color: rgba(153, 27, 27, 0.15);
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.2);
}

.alert-info {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}
.alert-info::before {
    /* Info Icon */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
}
[data-theme="dark"] .alert-info {
    background-color: rgba(30, 64, 175, 0.15);
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.2);
}

.alert p {
    margin-bottom: 0;
}

/* Shared KPI card treatment for dashboards and all legacy backend summary widgets. */
.widget-style3 {
    position: relative;
    min-height: 96px;
    overflow: hidden;
    background: var(--app-surface, #ffffff);
    border: 1px solid transparent;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.widget-style3:hover,
.widget-style3:focus-within {
    transform: translateY(-3px);
    border-color: rgba(63, 90, 169, 0.18);
    border-color: color-mix(in srgb, var(--app-primary, #3f5aa9) 18%, transparent);
    box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.2);
}

.widget-style3 > .d-flex {
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 96px;
}

.widget-style3 .widget-data {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    padding: 18px 20px;
}

.widget-style3 .widget-data .weight-700,
.widget-style3 .widget-data .font-24 {
    font-size: 26px;
    line-height: 1.2;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.widget-style3 .widget-data .font-14 {
    margin-top: 2px;
    color: var(--app-text-muted, #667085);
    font-size: 13px;
    line-height: 1.4;
}

.widget-style3 .widget-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 72px;
    width: 72px;
    min-height: 96px;
    padding-right: 18px;
    background: transparent;
    color: var(--app-text-strong, #1f2937);
}

.widget-style3 .widget-icon .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background-color: rgba(63, 90, 169, 0.12);
    background: color-mix(in srgb, currentColor 16%, transparent);
    color: inherit;
    font-size: 23px;
    line-height: 1;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.widget-style3:hover .widget-icon .icon {
    transform: scale(1.1) rotate(-5deg);
}

[data-theme="dark"] .widget-style3 {
    background: var(--app-surface, #18232b);
}

[data-theme="dark"] .widget-style3 .widget-data .text-dark {
    color: var(--app-text-strong, #f2f4f7) !important;
}

@supports not (background: color-mix(in srgb, currentColor 16%, transparent)) {
    .widget-style3 .widget-icon .icon {
        background: rgba(63, 90, 169, 0.14);
    }
}

/* Compact centered KPI cards used by analytics, health, and inventory summaries. */
.kpi-card {
    position: relative;
    height: 100%;
    overflow: hidden;
    border: 1px solid transparent;
    background: var(--app-surface, #ffffff);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.kpi-card:hover,
.kpi-card:focus-within {
    transform: translateY(-3px);
    border-color: rgba(63, 90, 169, 0.18);
    border-color: color-mix(in srgb, var(--app-primary, #3f5aa9) 18%, transparent);
    box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .kpi-card {
    background: var(--app-surface, #18232b);
}

/* Compact centered KPI cards used by analytics and inventory summaries. */
.summary-stat-card {
    position: relative;
    height: 100%;
    overflow: hidden;
    border: 1px solid transparent;
    background: var(--app-surface, #ffffff);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.summary-stat-card:hover,
.summary-stat-card:focus-within {
    transform: translateY(-3px);
    border-color: rgba(63, 90, 169, 0.18);
    border-color: color-mix(in srgb, var(--app-primary, #3f5aa9) 18%, transparent);
    box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.2);
}

.summary-stat-card .font-36 {
    color: var(--app-primary, #3f5aa9);
    font-size: 30px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.summary-stat-card .font-14 {
    color: var(--app-text-muted, #667085);
}

.summary-stat-card.summary-stat-success .font-36 { color: #0aa03f; }
.summary-stat-card.summary-stat-warning .font-36 { color: #dd8f0b; }
.summary-stat-card.summary-stat-danger .font-36 { color: #e0444b; }
.summary-stat-card.summary-stat-info .font-36 { color: #3468e6; }

[data-theme="dark"] .summary-stat-card {
    background: var(--app-surface, #18232b);
}

[data-theme="dark"] .summary-stat-card .font-36 {
    color: var(--app-text-strong, #f2f4f7);
}

/* Report KPI cards keep their semantic status colors while gaining the shared interaction. */
.report-stat-card {
    position: relative;
    overflow: hidden;
    min-height: 96px;
    border: 1px solid transparent;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.report-stat-card:hover,
.report-stat-card:focus-within {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.55);
    box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.28);
}

.report-stat-card h5 {
    font-size: 25px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

/* Gradient stat cards shared by dashboards, notifications, and activity log. */
.stat-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.stat-card:hover,
.stat-card:focus-within {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.2);
}

.stat-card-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 96px;
    padding: 18px 20px;
}

.stat-card-data {
    min-width: 0;
}

.stat-card-value {
    color: var(--stat-c, var(--app-text-strong));
    font-size: 26px;
    font-weight: 800;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s ease;
}

.stat-card-label {
    margin-top: 2px;
    color: var(--app-text-muted);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}

.stat-card-detail {
    margin-top: 5px;
    color: var(--app-text-muted);
    font-size: 12px;
    line-height: 1.35;
}

.stat-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 54px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background-color: rgba(63, 90, 169, 0.12);
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--stat-g1) 22%, transparent),
        color-mix(in srgb, var(--stat-g2) 22%, transparent));
    color: var(--stat-c, var(--app-text-strong));
    font-size: 24px;
    line-height: 1;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.stat-card:hover .stat-card-icon {
    transform: scale(1.1) rotate(-5deg);
}

.stat-card-teal {
    --stat-g1: #00c3b4;
    --stat-g2: #37e6d8;
    --stat-c: #00a89b;
}

.stat-card-green {
    --stat-g1: #0ab44d;
    --stat-g2: #3fdc7c;
    --stat-c: #0aa03f;
}

.stat-card-blue {
    --stat-g1: #3d7bfd;
    --stat-g2: #6ba1ff;
    --stat-c: #3468e6;
}

.stat-card-indigo {
    --stat-g1: #5b5bff;
    --stat-g2: #8a7bff;
    --stat-c: #5144e0;
}

.stat-card-red {
    --stat-g1: #f2575e;
    --stat-g2: #ff8a8f;
    --stat-c: #e0444b;
}

.stat-card-amber {
    --stat-g1: #f5a623;
    --stat-g2: #ffc95e;
    --stat-c: #dd8f0b;
}

.stat-card-alert {
    background-color: var(--app-surface);
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--stat-c) 9%, var(--app-surface)),
        var(--app-surface));
}

[data-theme="dark"] .stat-card-teal { --stat-c: #38e8da; }
[data-theme="dark"] .stat-card-green { --stat-c: #4be084; }
[data-theme="dark"] .stat-card-blue { --stat-c: #6fa2ff; }
[data-theme="dark"] .stat-card-indigo { --stat-c: #8e81ff; }
[data-theme="dark"] .stat-card-red { --stat-c: #ff7a80; }
[data-theme="dark"] .stat-card-amber { --stat-c: #ffc95e; }

.stat-card-anchor {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.stat-card-anchor:hover,
.stat-card-anchor:focus {
    color: inherit;
    text-decoration: none;
}

.stat-card-anchor .stat-card::after {
    content: "\f285";
    font-family: bootstrap-icons;
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 13px;
    line-height: 1;
    color: var(--stat-c, var(--app-primary));
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.stat-card-anchor:hover .stat-card::after,
.stat-card-anchor:focus-visible .stat-card::after {
    opacity: 1;
    transform: translateX(0);
}

.stat-card-anchor:focus-visible {
    outline: none;
}

.stat-card-anchor:focus-visible .stat-card {
    outline: 3px solid var(--app-primary);
    outline-offset: 3px;
}

[dir="rtl"] .stat-card-anchor .stat-card::after {
    right: auto;
    left: 12px;
    transform: translateX(4px) scaleX(-1);
}

[dir="rtl"] .stat-card-anchor:hover .stat-card::after,
[dir="rtl"] .stat-card-anchor:focus-visible .stat-card::after {
    transform: translateX(0) scaleX(-1);
}

@media (max-width: 575.98px) {
    .summary-stat-card .font-36 {
        font-size: 27px;
    }

    .report-stat-card h5 {
        font-size: 22px;
    }

    .widget-style3 .widget-data {
        padding: 16px;
    }

    .widget-style3 > .d-flex,
    .widget-style3 .d-flex.flex-wrap {
        min-height: 88px;
    }

    .widget-style3 .widget-icon {
        flex-basis: 62px;
        width: 62px;
        min-height: 88px;
        padding-right: 14px;
    }

    .widget-style3 .widget-icon .icon {
        width: 48px;
        height: 48px;
        font-size: 21px;
    }

    .widget-style3 .widget-data .weight-700,
    .widget-style3 .widget-data .font-24 {
        font-size: 23px;
    }

    .stat-card-body {
        min-height: 88px;
        padding: 16px;
    }

    .stat-card-value {
        font-size: 23px;
    }

    .stat-card-icon {
        flex-basis: 48px;
        width: 48px;
        height: 48px;
        font-size: 21px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .kpi-card,
    .summary-stat-card,
    .report-stat-card,
    .widget-style3,
    .widget-style3 .widget-icon .icon,
    .stat-card,
    .stat-card-icon,
    .stat-card-value {
        transition: none;
    }
}

/* ============================================================
   Sidebar hover-expand / click-to-pin behavior
   Desktop starts icon-only, expands while hovered, and stays
   expanded after the top circle toggle is clicked.
   ============================================================ */
.sidebar-pin-toggle {
    align-items: center;
    justify-content: center;
    border: 0;
    padding: 0;
    background: transparent;
    line-height: 1;
}

.sidebar-pin-toggle:focus-visible {
    outline: 2px solid var(--app-primary, #1b00ff);
    outline-offset: 2px;
}

.sidebar-favicon {
    display: none;
    width: 32px !important;
    height: 32px !important;
    max-width: 32px !important;
    object-fit: contain;
}

.sidebar-toggle-expanded,
.sidebar-toggle-mobile {
    display: none;
}

@media (min-width: 1301px) {
    /* Keep the old DeskApp click handler from moving the desktop sidebar off-screen. */
    body.sidebar-shrink .left-side-bar {
        left: 0 !important;
    }

    .left-side-bar,
    .left-side-bar.open {
        left: 0;
        width: 68px;
        overflow: visible;
        transition: width 0.25s ease-in-out;
    }

    .left-side-bar .brand-logo {
        width: 68px;
        overflow: hidden;
        position: relative;
        transition: width 0.25s ease-in-out;
    }

    .left-side-bar .brand-logo > a {
        justify-content: center;
        padding: 0;
    }

    .left-side-bar .brand-logo > a .dark-logo,
    .left-side-bar .brand-logo > a .light-logo {
        display: none !important;
    }

    .left-side-bar .brand-logo > a .sidebar-favicon {
        display: block !important;
    }

    .left-side-bar .sidebar-pin-toggle {
        display: flex !important;
        position: absolute;
        right: 7px;
        top: 24px;
        width: 24px;
        height: 24px;
        z-index: 2;
        color: var(--app-text-muted, #888);
        font-size: 17px;
        cursor: pointer;
    }

    .left-side-bar .sidebar-toggle-collapsed {
        display: none;
    }

    .left-side-bar .sidebar-pin-toggle:hover {
        color: var(--app-primary, #1b00ff);
    }

    body:not(.sidebar-pinned) .left-side-bar .sidebar-menu .mtext,
    body:not(.sidebar-pinned) .left-side-bar .sidebar-menu .sidebar-small-cap,
    body:not(.sidebar-pinned) .left-side-bar .sidebar-menu .dropdown-toggle::after,
    body:not(.sidebar-pinned) .left-side-bar .sidebar-menu .badge,
    body:not(.sidebar-pinned) .left-side-bar .sidebar-menu .dropdown-divider {
        display: none !important;
    }

    body:not(.sidebar-pinned) .left-side-bar:not(:hover) .sidebar-menu .submenu {
        display: none !important;
    }

    /* While hovering (non-pinned) or pinned, only the active group's submenu
       is shown — sibling groups must not all expand at once. */
    body:not(.sidebar-pinned) .left-side-bar:hover .sidebar-menu li.dropdown.show > .submenu,
    body.sidebar-pinned .left-side-bar .sidebar-menu li.dropdown.show > .submenu {
        display: revert !important;
    }

    body:not(.sidebar-pinned) .left-side-bar .sidebar-menu > ul > li {
        padding-left: 8px;
        padding-right: 8px;
    }

    body:not(.sidebar-pinned) .left-side-bar .sidebar-menu .dropdown-toggle {
        padding-left: 0;
        padding-right: 0;
        text-align: center;
        min-height: 48px;
    }

    body:not(.sidebar-pinned) .left-side-bar .sidebar-menu .dropdown-toggle .micon {
        left: 1px;
        width: 42px;
    }

    body:not(.sidebar-pinned) .left-side-bar:hover,
    body.sidebar-pinned .left-side-bar {
        width: 280px;
    }

    body:not(.sidebar-pinned) .left-side-bar:hover .brand-logo,
    body.sidebar-pinned .left-side-bar .brand-logo {
        width: 280px;
    }

    body:not(.sidebar-pinned) .left-side-bar:hover .brand-logo > a,
    body.sidebar-pinned .left-side-bar .brand-logo > a {
        justify-content: flex-start;
        padding: 0 20px;
    }

    body:not(.sidebar-light):not(.sidebar-pinned) .left-side-bar:hover .brand-logo > a .dark-logo,
    body:not(.sidebar-light).sidebar-pinned .left-side-bar .brand-logo > a .dark-logo,
    body.sidebar-light:not(.sidebar-pinned) .left-side-bar:hover .brand-logo > a .light-logo,
    body.sidebar-light.sidebar-pinned .left-side-bar .brand-logo > a .light-logo {
        display: none !important;
    }

    body:not(.sidebar-light):not(.sidebar-pinned) .left-side-bar:hover .brand-logo > a .light-logo,
    body:not(.sidebar-light).sidebar-pinned .left-side-bar .brand-logo > a .light-logo,
    body.sidebar-light:not(.sidebar-pinned) .left-side-bar:hover .brand-logo > a .dark-logo,
    body.sidebar-light.sidebar-pinned .left-side-bar .brand-logo > a .dark-logo {
        display: block !important;
    }

    body:not(.sidebar-pinned) .left-side-bar:hover .brand-logo > a .sidebar-favicon,
    body.sidebar-pinned .left-side-bar .brand-logo > a .sidebar-favicon {
        display: none !important;
    }

    body:not(.sidebar-pinned) .left-side-bar:hover .sidebar-menu .mtext,
    body:not(.sidebar-pinned) .left-side-bar:hover .sidebar-menu .sidebar-small-cap,
    body:not(.sidebar-pinned) .left-side-bar:hover .sidebar-menu .dropdown-toggle:not(.no-arrow)::after,
    body:not(.sidebar-pinned) .left-side-bar:hover .sidebar-menu .badge,
    body:not(.sidebar-pinned) .left-side-bar:hover .sidebar-menu .dropdown-divider,
    body.sidebar-pinned .left-side-bar .sidebar-menu .mtext,
    body.sidebar-pinned .left-side-bar .sidebar-menu .sidebar-small-cap,
    body.sidebar-pinned .left-side-bar .sidebar-menu .dropdown-toggle:not(.no-arrow)::after,
    body.sidebar-pinned .left-side-bar .sidebar-menu .badge,
    body.sidebar-pinned .left-side-bar .sidebar-menu .dropdown-divider {
        display: revert !important;
    }

    body:not(.sidebar-pinned) .left-side-bar:hover .sidebar-menu .dropdown-toggle,
    body.sidebar-pinned .left-side-bar .sidebar-menu .dropdown-toggle {
        padding-left: 67px;
        padding-right: 15px;
        text-align: left;
    }

    body:not(.sidebar-pinned) .left-side-bar:hover .sidebar-menu .dropdown-toggle .micon,
    body.sidebar-pinned .left-side-bar .sidebar-menu .dropdown-toggle .micon {
        left: 10px;
    }

    body:not(.sidebar-pinned) .left-side-bar:hover .sidebar-pin-toggle,
    body.sidebar-pinned .left-side-bar .sidebar-pin-toggle {
        right: 10px;
    }

    body:not(.sidebar-pinned) .left-side-bar:hover .sidebar-toggle-collapsed {
        display: inline-block;
    }

    body.sidebar-pinned .left-side-bar .sidebar-toggle-collapsed {
        display: none;
    }

    body:not(.sidebar-pinned) .left-side-bar:hover .sidebar-toggle-expanded {
        display: none;
    }

    body.sidebar-pinned .left-side-bar .sidebar-toggle-expanded {
        display: inline-block;
    }

    body:not(.sidebar-pinned) .main-container,
    body.sidebar-shrink:not(.sidebar-pinned) .main-container {
        padding-left: 88px !important;
    }

    body:not(.sidebar-pinned) .header,
    body.sidebar-shrink:not(.sidebar-pinned) .header {
        width: calc(100% - 68px) !important;
    }

    body.sidebar-pinned .main-container {
        padding-left: 300px !important;
    }

    body.sidebar-pinned .header {
        width: calc(100% - 280px) !important;
    }

    /* The dir attribute lives on <html>, so select against html[dir="rtl"] body
       (same pattern as app-rtl.css) instead of body[dir="rtl"], which never matches. */
    [dir="rtl"] body .left-side-bar,
    [dir="rtl"] body .left-side-bar.open {
        right: 0;
        left: auto !important;
    }

    [dir="rtl"] body:not(.sidebar-pinned) .main-container {
        padding-left: 20px !important;
        padding-right: 88px !important;
    }

    [dir="rtl"] body.sidebar-pinned .main-container {
        padding-left: 20px !important;
        padding-right: 300px !important;
    }
}

@media (max-width: 1300px) {
    .left-side-bar .sidebar-toggle-collapsed,
    .left-side-bar .sidebar-toggle-expanded {
        display: none;
    }

    .left-side-bar .sidebar-toggle-mobile {
        display: inline-block;
    }
}

/* Keep sidebar scrolling available while hiding the scrollbar visuals. */
.left-side-bar .menu-block.customscroll,
.left-side-bar .menu-block.customscroll .mCustomScrollBox,
.left-side-bar .menu-block.customscroll .mCSB_container {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.left-side-bar .menu-block.customscroll::-webkit-scrollbar,
.left-side-bar .menu-block.customscroll .mCustomScrollBox::-webkit-scrollbar,
.left-side-bar .menu-block.customscroll .mCSB_container::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.left-side-bar .menu-block.customscroll .mCSB_scrollTools {
    opacity: 0 !important;
    visibility: hidden;
    pointer-events: none;
}

/* Apply the saved pinned state before the body finishes rendering. */
@media (min-width: 1301px) {
    html.sidebar-pinned-preload .left-side-bar,
    html.sidebar-pinned-preload .left-side-bar.open {
        left: 0 !important;
        width: 280px !important;
    }

    html.sidebar-pinned-preload .left-side-bar .brand-logo {
        width: 280px !important;
    }

    html.sidebar-pinned-preload .left-side-bar .brand-logo > a {
        justify-content: flex-start;
        padding: 0 20px;
    }

    html.sidebar-pinned-preload .left-side-bar .brand-logo > a .dark-logo {
        display: none !important;
    }

    html.sidebar-pinned-preload .left-side-bar .brand-logo > a .light-logo {
        display: block !important;
    }

    html.sidebar-pinned-preload .left-side-bar .brand-logo > a .sidebar-favicon {
        display: none !important;
    }

    html.sidebar-pinned-preload .left-side-bar .sidebar-menu .mtext,
    html.sidebar-pinned-preload .left-side-bar .sidebar-menu .sidebar-small-cap,
    html.sidebar-pinned-preload .left-side-bar .sidebar-menu .badge,
    html.sidebar-pinned-preload .left-side-bar .sidebar-menu .dropdown-divider {
        display: revert !important;
    }

    html.sidebar-pinned-preload .left-side-bar .sidebar-menu .dropdown-toggle:not(.no-arrow)::after {
        display: revert !important;
    }

    /* Only the current page's group may show expanded when pinned — never
       every group at once. Sibling submenus stay hidden (their inline
       display:none from the accordion wins because nothing reverts them). */
    html.sidebar-pinned-preload .left-side-bar .sidebar-menu li.dropdown.show > .submenu {
        display: revert !important;
    }

    html.sidebar-pinned-preload .left-side-bar .sidebar-menu .dropdown-toggle {
        padding-left: 67px;
        padding-right: 15px;
        text-align: left;
    }

    html.sidebar-pinned-preload .left-side-bar .sidebar-menu .dropdown-toggle .micon {
        left: 10px;
    }

    html.sidebar-pinned-preload .left-side-bar .sidebar-toggle-collapsed {
        display: none !important;
    }

    html.sidebar-pinned-preload .left-side-bar .sidebar-toggle-expanded {
        display: inline-block !important;
    }

    html.sidebar-pinned-preload .main-container {
        padding-left: 300px !important;
    }

    html.sidebar-pinned-preload .header {
        width: calc(100% - 280px) !important;
    }

    /* RTL: the pinned sidebar sits on the right, so mirror the preload layout. */
    html[dir="rtl"].sidebar-pinned-preload .left-side-bar,
    html[dir="rtl"].sidebar-pinned-preload .left-side-bar.open {
        left: auto !important;
        right: 0 !important;
    }

    html[dir="rtl"].sidebar-pinned-preload .main-container {
        padding-left: 20px !important;
        padding-right: 300px !important;
    }
}

/* Desktop uses hover-expand and the pin circle instead of the legacy hamburger. */
@media (min-width: 1301px) {
    .header-left .menu-icon {
        display: none !important;
    }
}

/* ============================================================
   Responsive hardening for small screens
   ------------------------------------------------------------
   These rules keep the shared admin layout from overflowing on
   phones/tablets without editing dozens of page templates:

   1. In the md range (768-991px) filter forms with many narrow
      columns get cramped (buttons overflow their col). Lay the
      columns out two-per-row so every field stays usable.
   2. On phones, header rows that pair a title with action
      buttons wrap instead of pushing the page wider, and button
      groups (filters, bulk actions) wrap with rounded corners.
   ============================================================ */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* Filter rows inside card boxes: two columns per row on tablets. */
    .card-box .pd-20 form.row > [class*="col-md-"],
    .card-box.pd-20 > form.row > [class*="col-md-"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 767.98px) {
    /* Title + actions header rows: wrap the actions below the title. */
    .d-flex.justify-content-between {
        flex-wrap: wrap;
        row-gap: 10px;
    }

    /* Button groups (order filters, bulk actions): wrap instead of
       overflowing the viewport; restore full rounded corners so the
       wrapped buttons look like separate buttons. */
    .btn-group {
        flex-wrap: wrap;
        gap: 6px;
    }

    .btn-group > .btn {
        border-radius: 8px !important;
        margin-left: 0 !important;
    }

    /* Inline action clusters (e.g. the AI toolbar on the product form): let
       them wrap so their selects/buttons never push the page wider. */
    .d-flex.align-items-center.gap-2 {
        flex-wrap: wrap;
        row-gap: 8px;
    }
}

/* ============================================================
   Products toolbar: filters, search, apply/reset and bulk actions
   share one 42px control height so everything lines up.
   ============================================================ */
.products-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.products-filter .pf-search { flex: 2 1 220px; min-width: 200px; }
.products-filter .pf-select { flex: 1 1 140px; min-width: 130px; }
.products-filter .pf-select .select2-container { width: 100% !important; }
.products-filter .pf-search .form-control { height: 42px; }
.products-filter .pf-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.products-filter .pf-actions .btn {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.bulk-action-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bulk-action-bar .bulk-select + .select2-container { width: 220px !important; max-width: 100%; }
.bulk-action-bar .bulk-apply {
    height: 42px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
@media (max-width: 575.98px) {
    .products-filter .pf-search,
    .products-filter .pf-select { flex-basis: 100%; }
    .products-filter .pf-actions { flex: 1 1 100%; }
    .products-filter .pf-actions .btn { flex: 1 1 0; width: auto; }
}
