﻿/* ================= Sidebar ================= */
/* Shared geometry */
.sidebar {
    width: var(--sb-expanded);
    background: #fff;
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 1031;
    box-shadow: 0 0 10px rgba(0,0,0,.05);
    transition: width .25s ease, transform .30s ease, opacity .30s ease, box-shadow .30s ease;
    will-change: transform, opacity, width;
    transform: translateX(0);
    opacity: 1;
}

/* Sidebar position flips based on direction */

/* RTL: sidebar on the RIGHT */
html[dir="rtl"] .sidebar {
    right: 0;
    left: auto;
    border-left: 1px solid #eee;
    border-right: none;
}

/* Space between icon and label – logical, not left/right */
.sidebar .nav-link .label {
    margin-inline-start: .5rem; /* ~ ms-2 */
}


/* LTR: sidebar on the LEFT */
html[dir="ltr"] .sidebar {
    left: 0;
    right: auto;
    border-right: 1px solid #eee;
    border-left: none;
}

/* Mobile slide direction for LTR */
@media (max-width: 991.98px) {
    html[dir="ltr"] .sidebar {
        transform: translateX(-100%);
    }

    html[dir="ltr"] body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 12px 0 24px rgba(0,0,0,.18);
    }
}


.sidebar.is-collapsed {
    width: var(--sb-collapsed);
}

/* ================= Brand / User ================= */
.sidebar-toggle {
    position: absolute;
    inset-inline-start: 2px;
    inset-block-start: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    padding: 0;
}


.sidebar-logo img {
    max-width: 80%;
    max-height: 60px;
    height: auto;
}

.sidebar-user {
    font-size: 14px;
}

    .sidebar-user .avatar {
        width: 44px;
        height: 44px;
        object-fit: cover;
        border-radius: 50%;
    }

    .sidebar-user .user-text {
        line-height: 1.2;
    }

/* ================= Nav ================= */
.sidebar .nav-link {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    border-radius: 10px;
    margin: 6px 12px;
    background: transparent;
    transition: background-color .2s, color .2s; /* no margin transition */
}

.sidebar-submenu-toggle .submenu-caret {
    margin-inline-start: auto;
    font-size: .8rem;
    transition: transform .2s ease;
}

.sidebar-submenu-toggle:not(.collapsed) .submenu-caret {
    transform: rotate(180deg);
}

.sidebar-submenu {
    margin-top: -4px;
    margin-bottom: 4px;
}

.sidebar-submenu-link {
    font-size: 14px;
}

html[dir="ltr"] .sidebar-submenu-link {
    margin-inline-start: 22px;
}

html[dir="rtl"] .sidebar-submenu-link {
    margin-inline-end: 22px;
}

/* LTR (English): icon on the left, text to the right */
html[dir="ltr"] .sidebar .nav-link {
    flex-direction: row; /* default: icon then label */
    text-align: left;
}

/* RTL (Arabic): icon on the right, text to the left */
html[dir="rtl"] .sidebar .nav-link {
    flex-direction: row-reverse;
    text-align: right;
}

    /* RTL: swap visual order and spacing */
    html[dir="rtl"] .sidebar .nav-link i {
        order: 2; /* icon on the far right */
        margin-inline-start: 0;
        margin-inline-end: .5rem; /* gap between text and icon */
    }

    html[dir="rtl"] .sidebar .nav-link .label {
        order: 1; /* label before icon */
        margin-inline-start: 0; /* we use margin-inline-end above instead */
    }

    .sidebar .nav-link i {
        font-size: 18px;
    }

    .sidebar .nav-link:hover {
        background: #f8f8f8;
        color: #80002a;
    }

    .sidebar .nav-link.active {
        background: #80002a;
        color: #fff !important;
    }

    /* subtle active accent without pushing layout (pair with site.css 12px margin) */
    .sidebar .nav-link.active {
        position: relative;
    }

        .sidebar .nav-link.active::before {
            content: "";
            position: absolute;
            inset-inline-end: -6px;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 60%;
            border-radius: 2px;
            background: #80002a;
        }

/* Collapsed state tweaks */
.sidebar.is-collapsed .sidebar-logo img {
    max-width: 40px;
    max-height: 40px;
}

.sidebar.is-collapsed .sidebar-user {
    padding-block: 12px;
}

    .sidebar.is-collapsed .sidebar-user .user-text {
        display: none;
    }

.sidebar.is-collapsed .nav-link {
    justify-content: center;
    margin: 6px 8px;
    padding-inline: 0;
}

.sidebar.is-collapsed .sidebar-submenu {
    display: none !important;
}

.sidebar.is-collapsed .sidebar-submenu-toggle .submenu-caret {
    display: none;
}

    .sidebar.is-collapsed .nav-link .label {
        display: none;
    }

    .sidebar.is-collapsed .nav-link i {
        margin: 0 !important;
        font-size: 20px;
    }

/* ================= Desktop (push content with body padding) ================= */
/*@media (min-width: 992px) {
    body {
        padding-right: var(--sb-expanded);
    }

        body.sidebar-collapsed {
            padding-right: var(--sb-collapsed);
        }
}*/

@media (min-width: 992px) {
    /* Push content away from the sidebar side (inline-end) */
    body {
        padding-inline-end: var(--sb-expanded);
    }

        body.sidebar-collapsed {
            padding-inline-end: var(--sb-collapsed);
        }
}

@media (max-width: 991.98px) {
    body {
        padding-inline-end: 0 !important;
    }

    /* Start off-canvas */
    html[dir="rtl"] .sidebar {
        width: var(--sb-expanded);
        transform: translateX(100%); /* hidden to the right */
        opacity: 0;
        box-shadow: none;
    }

    html[dir="ltr"] .sidebar {
        width: var(--sb-expanded);
        transform: translateX(-100%); /* hidden to the left */
        opacity: 0;
        box-shadow: none;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    html[dir="rtl"] body.sidebar-open .sidebar {
        transform: translateX(0);
        opacity: 1;
        box-shadow: -12px 0 24px rgba(0,0,0,.18); /* shadow to the left */
    }

    html[dir="ltr"] body.sidebar-open .sidebar {
        transform: translateX(0);
        opacity: 1;
        box-shadow: 12px 0 24px rgba(0,0,0,.18); /* shadow to the right */
    }

    .sidebar .sidebar-toggle {
        inset-inline-start: 4px;
        z-index: 1;
    }
}


/* ================= Scrim ================= */
.sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity .30s ease;
    z-index: 1030;
}

@media (max-width: 991.98px) {
    body.sidebar-open .sidebar-scrim {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ================= FAB ================= */
.sidebar-fab {
    position: fixed;
    top: 16px;
    right: 6px; /* mobile default */
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg,#80002a,#a83250);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    cursor: pointer;
    z-index: 1100;
    transition: right .25s ease, transform .30s ease, box-shadow .30s ease, background .30s ease;
}

    .sidebar-fab i {
        display: inline-block;
        transition: transform .25s ease;
    }

    .sidebar-fab:hover {
        transform: scale(1.08);
        box-shadow: 0 6px 18px rgba(0,0,0,.35);
    }

    .sidebar-fab:active {
        transform: scale(0.95);
    }

/* Mobile: when sidebar is open, flip arrow */
body.sidebar-open .sidebar-fab i {
    transform: rotate(180deg);
}

@media (min-width: 992px) {
    .sidebar-fab {
        inset-inline-end: calc(var(--sb-expanded) + 12px);
    }

    body.sidebar-collapsed .sidebar-fab {
        inset-inline-end: calc(var(--sb-collapsed) + 12px);
    }

        /* Desktop:
       - collapsed  => base direction (towards content)
       - expanded   => rotated 180° (towards sidebar)
    */
        body.sidebar-collapsed .sidebar-fab i {
            transform: none; /* explicit, just to be clear */
        }

    body:not(.sidebar-collapsed) .sidebar-fab i {
        transform: rotate(180deg);
    }
}



@media (max-width: 991.98px) {
    .sidebar-fab {
        right: 6px;
    }
}

/* ================= Reduce motion ================= */
@media (prefers-reduced-motion: reduce) {
    .sidebar, .sidebar-scrim, .sidebar-fab {
        transition: none !important;
    }
}
