/* ====== أساسيات RTL ====== */
html[dir="rtl"] body {
    text-align: right;
    font-family: Tahoma,Arial,sans-serif;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ====== Topbar (الزر فوق كل شيء) ====== */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1050; /* أعلى من الشريط الجانبي */
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,.08);
}

.sidebar-toggle {
    position: relative;
    z-index: 1051;
}
/* يظل قابل للنقر دائماً */

/* ====== ستارة الموبايل ====== */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: .2s;
}

/* ====== Sidebar يمين + زجاجي داكن ====== */
.app-sidebar {
    order: 2; /* يبقيها يمين في RTL */
    width: 260px;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 1040;
    padding: 14px 10px;
    color: #e9eef3;
    background: rgba(12,16,22,.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-inline-start: 1px solid rgba(255,255,255,.08);
    box-shadow: -4px 0 24px rgba(0,0,0,.18) inset;
    right: 0;
    left: auto; /* ثبّت يميناً */
}

/* عناصر داخلية أساسية للقائمة */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 10px;
}

.brand-chip {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: #9de9ff;
    background: linear-gradient(135deg, rgba(127,216,255,.16), rgba(120,196,210,.10));
    border: 1px solid rgba(255,255,255,.12);
}

.brand-text small {
    color: #a9b4bf;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-group-title {
    margin: 10px 6px 4px;
    font-size: .8rem;
    color: #a9b4bf;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    color: #e9eef3;
    text-decoration: none;
    cursor: pointer;
    padding: .62rem .7rem;
    border-radius: .8rem;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.10);
    transition: transform .15s, box-shadow .15s, background .15s, border-color .15s, color .15s;
}

    .sidebar-link i {
        font-size: 1rem;
        color: #a8ecff;
    }

    .sidebar-link:hover {
        transform: translateX(-3px);
        background: rgba(255,255,255,.10);
        border-color: rgba(127,216,255,.35);
        box-shadow: 0 10px 22px rgba(0,0,0,.25);
    }

    .sidebar-link.active {
        background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.08));
        border-color: rgba(127,216,255,.55);
        color: #eefbff;
    }

        .sidebar-link.active i {
            color: #c7f4ff;
        }

/* زر خروج بشكل رابط */
.as-link-button {
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.10);
    color: #e9eef3;
    padding: .62rem .7rem;
    border-radius: .8rem;
    width: 100%;
    text-align: start;
}

    .as-link-button:hover {
        transform: translateX(-3px);
        background: rgba(255,255,255,.10);
        border-color: rgba(127,216,255,.35);
        box-shadow: 0 10px 22px rgba(0,0,0,.25);
    }

/* ====== سلوك الإخفاء/الإظهار ====== */
/* Desktop & Mobile: الإخفاء = خروج كامل يميناً */
body.sidebar-collapsed .app-sidebar {
    transform: translateX(100%);
    position: fixed;
    right: 0;
    top: 0;
}

/* ====== موبايل ====== */
@media (max-width: 992px) {
    .app-sidebar {
        position: fixed;
        inset: 0 0 0 auto; /* يمين */
        transform: translateX(0);
        transition: transform .22s ease;
        box-shadow: -4px 0 24px rgba(0,0,0,.25);
    }

    body.sidebar-collapsed .app-sidebar {
        transform: translateX(100%);
    }

    body:not(.sidebar-collapsed) .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }
}

/* ====== تحسينات عامة ====== */
.form-control:focus, .form-select:focus, .btn:focus {
    box-shadow: 0 0 0 .2rem rgba(127,216,255,.25);
    border-color: rgba(127,216,255,.65);
}

.btn-primary {
    background: #0ea5b5;
    border-color: #0ea5b5;
}

    .btn-primary:hover {
        background: #0b8f9c;
        border-color: #0b8f9c;
    }
/* تثبيت موضع القائمة يمين دائمًا على الديسكتوب */
.app-shell {
    display: flex;
    min-height: 100vh;
    direction: ltr; /* مهم: اجعل اتجاه التخطيط LTR */
}

.app-main,
.app-sidebar {
    direction: rtl; /* محتوى القائمه والمحتوى يظل RTL */
}

/* ترتيب العناصر: المحتوى أولاً (يسار في LTR) والقائمة ثانيًا (يمين) */
.app-main {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
}

.app-sidebar {
    order: 2;
}

/* لا تغيّر أي شيء آخر — موبايل سيبقى يعمل لأننا نستخدم position:fixed هناك */


/* ==== لوحة ألوان زرقاء هادئة ==== */
:root {
    --blue-1: #0ea5b5; /* أزرق فيروزي أنيق للهوفر */
    --blue-2: #12bcd0; /* درجة أقوى للحدود/التوهج */
    --ink-light: #e9eef3;
    --muted-light: #a9b4bf;
}

/* ==== Sidebar زجاجي داكن (Glassmorphism) ==== */
.app-sidebar {
    background: rgba(20, 28, 36, .78); /* داكن شفاف */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-inline-start: 1px solid rgba(255,255,255,.10);
    box-shadow: -6px 0 28px rgba(0,0,0,.22) inset;
    color: var(--ink-light);
}

/* رأس الهوية */
.brand-chip {
    background: linear-gradient(135deg, rgba(127,216,255,.16), rgba(18,188,208,.10));
    color: #aaf2ff;
    border: 1px solid rgba(255,255,255,.14);
}

.brand-text small {
    color: var(--muted-light);
}

/* روابط القائمة: زجاج + هوفر أزرق واضح */
.sidebar-link {
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.10);
    color: var(--ink-light);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}

    .sidebar-link i {
        color: #9feaff;
    }

    .sidebar-link:hover {
        transform: translateX(-3px);
        background: rgba(255,255,255,.10);
        border-color: rgba(18,188,208,.45); /* أزرق على الهوفر */
        box-shadow: 0 10px 22px rgba(0,0,0,.28), /* ظل ناعم */
        0 0 0 2px rgba(18,188,208,.12) inset; /* توهج خفيف */
    }

    /* تمييز الصفحة المفتوحة (Active) */
    .sidebar-link.active {
        background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.08));
        border-color: rgba(18,188,208,.65);
        color: #f0fbff;
        box-shadow: 0 12px 26px rgba(0,0,0,.30), 0 0 0 2px rgba(18,188,208,.18) inset;
    }

        .sidebar-link.active i {
            color: #c7f7ff;
        }

/* زر الخروج بنفس روح الروابط */
.as-link-button {
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.10);
    color: var(--ink-light);
}

    .as-link-button:hover {
        transform: translateX(-3px);
        background: rgba(255,255,255,.10);
        border-color: rgba(18,188,208,.45);
        box-shadow: 0 10px 22px rgba(0,0,0,.28), 0 0 0 2px rgba(18,188,208,.12) inset;
    }

/* ستارة الموبايل (تبقى كما هي) */
.sidebar-backdrop {
    background: rgba(0,0,0,.45);
}

/* تحسين تركيز الحقول والأزرار ليتماشى مع الأزرق */
.form-control:focus, .form-select:focus, .btn:focus {
    box-shadow: 0 0 0 .2rem rgba(18,188,208,.25);
    border-color: rgba(18,188,208,.65);
}

.btn-primary {
    background: #0ea5b5;
    border-color: #0ea5b5;
}

    .btn-primary:hover {
        background: #0d93a3;
        border-color: #0d93a3;
    }


