/* =====================================================
   نظام التصميم — POS Modern UI
   ===================================================== */

:root {
    /* الألوان الأساسية */
    --pos-bg: #FAF8F5;              /* خلفية دافئة فاتحة */
    --pos-surface: #FFFFFF;          /* خلفية البطاقات */
    --pos-surface-alt: #F3EFE8;      /* خلفية ثانوية (hover, stripes) */
    --pos-ink: #1A2233;              /* النص الأساسي - كحلي غامق */
    --pos-ink-soft: #5B6477;         /* نص ثانوي */
    --pos-line: #E8E1D5;             /* خطوط فاصلة */

    /* الألوان التفاعلية */
    --pos-primary: #3D3470;          /* بنفسجي-كحلي عميق - أساسي (لون نص وأيقونات) */
    --pos-primary-dark: #2A2350;
    --pos-primary-soft: #EDEAF6;

    /* خلفية بيتكتب عليها أبيض (أزرار، شريط التحية، الشارات). منفصلة عن --pos-primary
       لأن ده بيتفتح في الوضع الداكن عشان يبان كنص، وتفتيحه كخلفية كان بيخلي
       الأبيض فوقه غير مقروء (تباين 3.3:1) */
    --pos-primary-fill: #3D3470;
    --pos-primary-fill-dark: #2A2350;
    --pos-accent-fill: #B85C26;
    --pos-accent-fill-dark: #9C4A1F;
    --pos-success-fill-dark: #085F57;
    --pos-success-fill: #0B7A70;

    /* القائمة الجانبية ليها متغيراتها كاملة (خلفية + نص + hover) عشان تتبع المظهر:
       فاتحة في الوضع الفاتح وداكنة في الداكن. والتدرّج منفصل عن --pos-primary-dark
       عمدًا، وإلا تفتيح الزرار في الوضع الداكن كان هيفتّح القائمة معاه */
    --pos-sidebar-from: #FFFFFF;
    --pos-sidebar-to: #F6F2EC;
    --pos-sidebar-ink: #1A2233;          /* النص القوي */
    --pos-sidebar-ink-soft: #5B6477;     /* عناصر القائمة العادية */
    --pos-sidebar-ink-mute: #8A93A5;     /* عناوين الأقسام والـplaceholder */
    --pos-sidebar-hover: rgba(61, 52, 112, 0.07);
    --pos-sidebar-active: rgba(15, 155, 142, 0.13);
    --pos-sidebar-line: #E8E1D5;
    --pos-sidebar-accent: #0B7A70;       /* أيقونة العنصر النشط */
    --pos-sidebar-edge: rgba(0, 0, 0, 0.08);

    --pos-accent: #B85C26;           /* تيراكوتا - للتمييز والأرقام المهمة */
    --pos-accent-dark: #9C4A1F;

    --pos-success: #0F9B8E;          /* تركواز - نجاح/إيجابي */
    --pos-success-dark: #0B7A70;
    --pos-success-soft: #E3F5F2;

    --pos-warning: #D98E04;
    --pos-warning-soft: #FBF1DD;

    --pos-danger-fill: #C44536;
    --pos-danger-fill-dark: #9C3527;
    --pos-danger: #C44536;
    --pos-danger-soft: #FBEAE7;
    --pos-danger-dark: #9C3527;

    --pos-radius: 14px;
    --pos-radius-sm: 9px;
    --pos-shadow: 0 2px 10px rgba(26, 34, 51, 0.06);
    --pos-shadow-lg: 0 12px 32px rgba(26, 34, 51, 0.12);

    --sidebar-width: 252px;
    --sidebar-width-collapsed: 76px;
}

/* =====================================================
   الوضع الداكن
   =====================================================
   بيتفعّل بـ data-theme="dark" على <html>، والسيرفر هو اللي بيكتبها من الكوكي
   قبل ما الصفحة ترسم - عشان مايحصلش ومضة بيضا أول ما تفتح.
   مكوّنات Bootstrap (جداول، مودالات، حقول، قوائم) بتتولّى نفسها عن طريق
   data-bs-theme="dark" اللي بيتحط جنبها، فاللي تحت ده هو الطبقة بتاعتنا بس.

   الألوان مش معكوسة حسابيًا: الخلفية الداكنة بتخلي أي لون يبان أفتح وأشبع مما هو،
   فالبنفسجي والتركواز اتفتحوا والخلفيات الملوّنة الناعمة بقت غمقانة جدًا بدل فاتحة جدًا. */
:root[data-theme="dark"] {
    --pos-bg: #14161D;
    --pos-surface: #1C1F29;
    --pos-surface-alt: #252936;
    --pos-ink: #E9EBF2;
    --pos-ink-soft: #99A2B5;
    --pos-line: #2F3442;

    --pos-primary: #8F83DD;
    --pos-primary-dark: #A79DE7;
    --pos-primary-soft: #272240;

    /* بتفضل غامقة في الوضع الداكن - الأبيض فوقها 8.8:1 */
    --pos-primary-fill: #4A3F86;
    --pos-primary-fill-dark: #3A3069;

    /* التيراكوتا كخلفية مابتتغيرش بين الوضعين خالص: هي سطح هوية بيتكتب عليه أبيض،
       وتفتيحها مع الوضع الداكن كان بينزّل التباين من 4.1 لـ2.7 */
    --pos-accent-fill: #B85C26;
    --pos-accent-fill-dark: #9C4A1F;

    /* التركواز كنص بيتفتح لـ#2ED3C2، لكن كخلفية تحت أبيض بيفضل غامق -
       الأبيض فوق الفاتح كان 1.9:1 وأفاتار المستخدم كان شبه غير مقروء */
    --pos-success-fill-dark: #085F57;
    --pos-success-fill: #0B7A70;

    --pos-sidebar-from: #211C3D;
    --pos-sidebar-to: #191534;
    --pos-sidebar-ink: #FFFFFF;
    --pos-sidebar-ink-soft: rgba(255, 255, 255, 0.78);
    --pos-sidebar-ink-mute: rgba(255, 255, 255, 0.5);
    --pos-sidebar-hover: rgba(255, 255, 255, 0.09);
    --pos-sidebar-active: rgba(15, 155, 142, 0.26);
    --pos-sidebar-line: rgba(255, 255, 255, 0.12);
    --pos-sidebar-accent: #4FD1C5;
    --pos-sidebar-edge: rgba(0, 0, 0, 0.2);

    --pos-accent: #E8824A;
    --pos-accent-dark: #F0996B;

    --pos-success: #2ED3C2;
    --pos-success-dark: #4FE0D1;
    --pos-success-soft: #10332F;

    --pos-warning: #EBA92E;
    --pos-warning-soft: #352A12;

    --pos-danger-fill: #C44536;
    --pos-danger-fill-dark: #9C3527;
    --pos-danger: #E4705F;
    --pos-danger-soft: #351E1A;
    --pos-danger-dark: #ED8A7B;

    --pos-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    --pos-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
}

/* خطوط Cairo وIBM Plex Sans Arabic بقت محلية في fonts.css (مش عبر إنترنت) - شايفها ~/css/fonts.css */

* { box-sizing: border-box; }

body {
    font-family: 'IBM Plex Sans Arabic', 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background-color: var(--pos-bg);
    color: var(--pos-ink);
    font-size: 0.92rem;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Cairo', 'IBM Plex Sans Arabic', sans-serif;
    font-weight: 700;
    color: var(--pos-ink);
}

a { color: var(--pos-primary); }
a:hover { color: var(--pos-primary-dark); }

/* =====================================================
   App Shell: Sidebar + Main
   ===================================================== */

.app-shell {
    min-height: 100vh;
}

/* =====================================================
   القائمة الجانبية
   خلفية داكنة بلون النظام الأساسي: بتفصل التنقّل عن المحتوى بصريًا من أول نظرة،
   وبتخلي العنصر النشط يبان من غير ما يزاحمه لون تاني. كل الاتجاهات بخصائص منطقية
   عشان نفس القواعد تشتغل في العربي والإنجليزي.
   ===================================================== */
.app-sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    bottom: 0;
    background: linear-gradient(180deg, var(--pos-sidebar-from) 0%, var(--pos-sidebar-to) 100%);
    color: var(--pos-sidebar-ink-soft);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1030;
    transition: width 0.2s ease;
    border-inline-end: 1px solid var(--pos-sidebar-edge);
}

.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: var(--pos-sidebar-ink-mute); border-radius: 3px; }
.app-sidebar::-webkit-scrollbar-thumb:hover { background: var(--pos-sidebar-ink-soft); }

/* ===== الهوية ===== */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 16px 14px;
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--pos-sidebar-ink);
    white-space: nowrap;
    flex-shrink: 0;
}

.sidebar-brand .brand-icon {
    width: 38px;
    height: 38px;
    background: var(--pos-success-fill);
    color: #fff;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(15, 155, 142, 0.4);
}

/* شعار تِرياق في القائمة: الملف نفسه فيه الخلفية والحواف، فبنشيل الخلفية
   الخضرا والظل اللي كانوا للأيقونة القديمة عشان ميبقاش فيه مربع جوه مربع */
.sidebar-brand .brand-icon.brand-icon-mark {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}
.sidebar-brand .brand-icon.brand-icon-mark img {
    width: 100%;
    height: 100%;
    display: block;
}

/* ===== البحث داخل القائمة ===== */
.sidebar-search {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 12px 10px;
    flex-shrink: 0;
}
.sidebar-search > .bi-search {
    position: absolute;
    inset-inline-start: 11px;
    font-size: 0.85rem;
    color: var(--pos-sidebar-ink-mute);
    pointer-events: none;
}
.sidebar-search input {
    width: 100%;
    padding: 9px 12px;
    padding-inline-start: 32px;
    padding-inline-end: 30px;
    border-radius: 9px;
    border: 1px solid var(--pos-sidebar-line);
    background: rgba(0, 0, 0, 0.22);
    color: var(--pos-sidebar-ink);
    font-family: inherit;
    font-size: 0.82rem;
}
.sidebar-search input::placeholder { color: var(--pos-sidebar-ink-mute); }
.sidebar-search input:focus {
    outline: none;
    border-color: var(--pos-success);
    background: rgba(0, 0, 0, 0.32);
}
/* زر المسح الافتراضي في المتصفح شكله مختلف عن تصميمنا */
.sidebar-search input::-webkit-search-cancel-button { display: none; }
.sidebar-search-clear {
    position: absolute;
    inset-inline-end: 8px;
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--pos-sidebar-ink-mute);
    font-size: 0.85rem;
    line-height: 1;
}
.sidebar-search-clear:hover { color: var(--pos-sidebar-ink); }

.sidebar-no-results {
    color: var(--pos-sidebar-ink-mute);
    font-size: 0.8rem;
    text-align: center;
    padding: 18px 12px;
    margin: 0;
}

/* ===== عناوين الأقسام ===== */
.sidebar-section { margin-bottom: 2px; }

.section-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    text-align: inherit;
    font-family: inherit;
    padding: 16px 16px 8px;
    color: var(--pos-sidebar-ink-soft);
    font-size: 0.86rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}
.section-toggle .section-title { flex: 1; }
.section-toggle:hover { color: var(--pos-sidebar-ink); }

.section-count {
    background: var(--pos-sidebar-line);
    color: var(--pos-sidebar-ink-soft);
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 0.68rem;
    font-weight: 700;
}

.section-toggle .nav-expand {
    font-size: 0.7rem;
    opacity: 0.8;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.sidebar-section.collapsed .section-toggle .nav-expand { transform: rotate(-90deg); }
.sidebar-section.collapsed .sidebar-section-body { display: none; }

/* ===== الروابط ===== */
.sidebar-nav {
    flex: 1;
    padding: 4px 0 16px;
}

.sidebar-pinned {
    padding: 0 10px 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--pos-sidebar-line);
}

.sidebar-section-body { padding: 0 10px; }

.nav-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 9px 11px;
    margin: 1px 0;
    border-radius: 9px;
    background: transparent;
    border: none;
    text-align: inherit;
    color: var(--pos-sidebar-ink-soft);
    text-decoration: none;
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.nav-btn .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* خانة ثابتة للأيقونة: بتخلي كل النصوص تبدأ من نفس الخط حتى لو الأيقونات بعرض مختلف */
.nav-icon {
    width: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    opacity: 0.9;
}

.nav-btn:hover { background: var(--pos-sidebar-hover); color: var(--pos-sidebar-ink); }

.nav-btn.active {
    background: var(--pos-sidebar-active);
    color: var(--pos-sidebar-ink);
}
/* شريط على حافة العنصر النشط - أوضح علامة على مكانك الحالي */
.nav-btn.active::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    border-radius: 0 3px 3px 0;
    background: var(--pos-success-fill);
}
.nav-btn.active .nav-icon { color: var(--pos-sidebar-accent); opacity: 1; }


.nav-group-btn .nav-expand {
    font-size: 0.65rem;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    opacity: 0.55;
}
.nav-group-btn.open .nav-expand { transform: rotate(180deg); }

.sidebar-group { margin: 0; }

/* ===== العناصر الفرعية ===== */
.sidebar-submenu {
    display: none;
    position: relative;
    margin: 2px 0 4px;
    padding-inline-start: 20px;
}
.sidebar-submenu.open { display: block; }
/* خط رأسي بيربط العناصر الفرعية ببعضها بصريًا تحت المجموعة */
.sidebar-submenu::before {
    content: "";
    position: absolute;
    inset-inline-start: 20px;
    top: 4px;
    bottom: 4px;
    width: 1px;
    background: var(--pos-sidebar-line);
}

.sub-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    padding-inline-start: 14px;
    margin: 1px 0;
    border-radius: 7px;
    color: var(--pos-sidebar-ink-soft);
    text-decoration: none;
    font-size: 0.79rem;
    font-weight: 500;
}
.sub-row .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sub-row .nav-icon { width: 16px; font-size: 0.85rem; }
.sub-row:hover { background: var(--pos-sidebar-hover); color: var(--pos-sidebar-ink); }
.sub-row.active {
    color: var(--pos-sidebar-ink);
    font-weight: 600;
    background: var(--pos-sidebar-active);
}
.sub-row.active .nav-icon { color: var(--pos-sidebar-accent); }

/* ===== التذييل ===== */
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--pos-sidebar-line);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--pos-sidebar-ink);
    margin-bottom: 10px;
}
.sidebar-user .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .user-avatar {
    width: 31px; height: 31px;
    border-radius: 50%;
    background: var(--pos-success-fill);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem;
    flex-shrink: 0;
}

/* ===== مبدّل لغة الواجهة =====
   شريط ثابت أعلى الشاشة على الجهة المقابلة للقائمة الجانبية (يمين في الإنجليزي، يسار في
   العربي) عشان يفضل ظاهر في كل الشاشات من غير ما يزاحم القائمة أو زر الموبايل. */
/* الحاوية هي اللي ثابتة أعلى الشاشة، والمبدّلان جواها في صف واحد بمسافة ثابتة.
   قبل كده كان كل واحد fixed لوحده والمسافة بينهما إزاحة بالبكسل محسوبة على عرض
   مبدّل اللغة - وده بيتغيّر مع اللغة وطول الخط، فكانوا بيتلازقوا. */
.top-switches {
    position: fixed;
    top: 14px;
    inset-inline-end: 18px;
    z-index: 1035;
    display: flex;
    align-items: center;
    gap: 14px;
}

/* مبدّل المظهر: نفس شكل مبدّل اللغة بالظبط ومرصوص جنبه */
.theme-switch {
    display: flex;
    align-items: center;
    padding: 4px;
    background: var(--pos-surface);
    border: 1px solid var(--pos-line);
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.theme-switch button {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--pos-ink-soft);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.theme-switch button:hover { background: var(--pos-surface-alt); color: var(--pos-ink); }
.theme-switch button i { font-size: 0.95rem; }

@media (max-width: 991.98px) {
    /* على الموبايل الاسم بيتشال وتفضل الأيقونة بس، والمسافة تضيق */
    .top-switches { gap: 9px; }
    .theme-switch .theme-name { display: none; }
}

/* التثبيت بقى على .top-switches، ودي بقت عنصرًا عاديًا جواها */
.lang-switch {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: var(--pos-surface);
    border: 1px solid var(--pos-line);
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.lang-switch-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-inline-start: 2px;
    color: var(--pos-ink-soft);  /* كان --pos-muted وهو متغير مش معرّف أصلًا، فاللون كان بيُورَّث */
    font-size: 0.95rem;
}
.lang-switch button {
    display: flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: var(--pos-ink-soft);  /* كان --pos-muted وهو متغير مش معرّف أصلًا، فاللون كان بيُورَّث */
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.lang-switch button:hover { background: var(--pos-surface-alt); color: var(--pos-ink); }
.lang-switch button.active {
    background: var(--pos-primary-fill);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.lang-switch .lang-code {
    font-size: 0.7rem;
    letter-spacing: .4px;
    opacity: .75;
}
.lang-switch button.active .lang-code { opacity: .9; }

/* الشاشات الضيقة: زر الموبايل بياخد أعلى الجهة دي، فنزيح المبدّل جنبه ونسيب الكود بس */
@media (max-width: 900px) {
    .lang-switch { inset-inline-end: 66px; padding: 3px; }
    .lang-switch .lang-name { display: none; }
    .lang-switch button { padding: 5px 9px; }
    .lang-switch-icon { display: none; }
}

.btn-logout {
    width: 100%;
    background: var(--pos-danger-soft);
    border: 1px solid var(--pos-danger);
    color: var(--pos-danger-dark);
    border-radius: var(--pos-radius-sm);
    padding: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.15s ease;
}
.btn-logout:hover { background: var(--pos-danger); color: #fff; }

/* ===== حالة الطي (Collapsed) =====
   بتسيب الأيقونات ظاهرة والنص بس هو اللي بيختفي. قبل إضافة الأيقونات كانت الحالة دي
   بتدي أزرار فاضية، فكانت عمليًا بلا فايدة. اسم الشاشة بيظهر في tooltip عند الوقوف. */
.app-sidebar.collapsed .sidebar-brand .label,
.app-sidebar.collapsed .nav-btn .label,
.app-sidebar.collapsed .section-toggle,
.app-sidebar.collapsed .sidebar-search,
.app-sidebar.collapsed .nav-expand,
.app-sidebar.collapsed .sidebar-submenu,
.app-sidebar.collapsed .sidebar-user span:not(.user-avatar),
.app-sidebar.collapsed .btn-logout .label {
    display: none !important;
}

.app-sidebar.collapsed .sidebar-brand,
.app-sidebar.collapsed .nav-btn {
    justify-content: center;
    padding-left: 6px;
    padding-right: 6px;
    gap: 0;
}

/* الأقسام بتفضل مفرودة وهي مطوية: زرار العنوان مخفي فمفيش طريقة يفتحها المستخدم */
.app-sidebar.collapsed .sidebar-section.collapsed .sidebar-section-body { display: block; }
/* فاصل بسيط بين الأقسام بدل العناوين المخفية */
.app-sidebar.collapsed .sidebar-section + .sidebar-section .sidebar-section-body {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 6px;
    margin-top: 6px;
}
.app-sidebar.collapsed .nav-icon { opacity: 1; font-size: 1.1rem; }

.app-sidebar.collapsed .sidebar-user { justify-content: center; }
.app-sidebar.collapsed .btn-logout { padding: 8px 0; }
.app-sidebar.collapsed .sidebar-footer { padding: 14px 10px; }

/* Mobile toggler */
.sidebar-mobile-toggle {
    display: none;
    position: fixed;
    top: 14px;
    inset-inline-end: 14px;
    z-index: 1040;
    background: var(--pos-primary-fill);
    color: #fff;
    border: none;
    border-radius: 10px;
    width: 42px;
    height: 42px;
}

.app-sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

.sidebar-collapse-btn {
    position: absolute;
    top: 24px;
    inset-inline-end: -13px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--pos-success-fill);
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 1px 5px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    z-index: 1031;
    transition: transform 0.2s ease, background 0.15s ease;
}
.sidebar-collapse-btn:hover { background: var(--pos-success-fill-dark); }
.app-sidebar.collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

.app-main {
    margin-inline-start: var(--sidebar-width);
    min-width: 0;
    /* الحشو العلوي مكبَّر عشان مبدّل اللغة الثابت (top:14px وارتفاعه ~36px) ميغطّيش
       عناوين الشاشات ولا الأزرار اللي في أعلى يمين/يسار كل صفحة */
    padding: 60px 28px 40px;
    transition: margin-inline-start 0.2s ease;
}

.app-shell.collapsed .app-main {
    margin-inline-start: var(--sidebar-width-collapsed);
}

@media (max-width: 900px) {
    .app-sidebar {
        position: fixed;
        inset-inline-start: 0;
        /* درج الموبايل مخفي برّه الشاشة. translateX مالهاش نسخة منطقية، فالقيمة دي للعربي (rtl)
           والاتجاه معكوس في الإنجليزي عبر القاعدة تحت */
        transform: translateX(100%);
        transition: transform 0.25s ease;
        box-shadow: var(--pos-shadow-lg);
        width: var(--sidebar-width) !important;
    }
    html[dir="ltr"] .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open,
    html[dir="ltr"] .app-sidebar.open { transform: translateX(0); }
    /* على الموبايل الدرج بيفتح بعرضه الكامل دايمًا، فحالة الطي بتتلغى كلها */
    .app-sidebar.collapsed .label,
    .app-sidebar.collapsed .nav-expand {
        display: inline-block !important;
    }
    .app-sidebar.collapsed .section-toggle { display: flex !important; }
    .app-sidebar.collapsed .sidebar-search { display: flex !important; }
    .app-sidebar.collapsed .sidebar-section.collapsed .sidebar-section-body { display: none; }
    .app-sidebar.collapsed .sidebar-section + .sidebar-section .sidebar-section-body {
        border-top: none;
        padding-top: 0;
        margin-top: 0;
    }
    .app-sidebar.collapsed .sidebar-submenu.open {
        display: block !important;
    }
    .app-sidebar.collapsed .sidebar-user span:not(.user-avatar) {
        display: inline !important;
    }
    .app-sidebar.collapsed .btn-logout .label {
        display: inline !important;
    }
    .app-sidebar.collapsed .sidebar-brand,
    .app-sidebar.collapsed .nav-btn {
        justify-content: flex-start !important;
        padding-right: 16px !important;
        padding-left: 16px !important;
        gap: 10px !important;
    }
    .app-sidebar.collapsed .sidebar-user { justify-content: flex-start !important; }
    .app-sidebar.collapsed .btn-logout { padding: 8px !important; }
    .app-sidebar.collapsed .sidebar-footer { padding: 14px 18px !important; }
    .sidebar-collapse-btn { display: none; }
    .sidebar-mobile-toggle { display: flex; align-items: center; justify-content: center; }
    .app-main { margin-inline-start: 0 !important; padding: 64px 16px 32px; }
    .sidebar-backdrop {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1025;
    }
    .sidebar-backdrop.show { display: block; }
}

/* =====================================================
   مكوّنات عامة: بطاقات، أزرار، جداول، باجات
   ===================================================== */

.card {
    border: 1px solid var(--pos-line);
    border-radius: var(--pos-radius);
    box-shadow: var(--pos-shadow);
    background: var(--pos-surface);
}

.card-header {
    background: var(--pos-surface);
    border-bottom: 1px solid var(--pos-line);
    font-weight: 600;
    border-radius: var(--pos-radius) var(--pos-radius) 0 0 !important;
}

.btn { border-radius: var(--pos-radius-sm); font-weight: 600; font-size: 0.88rem; }

.form-label { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.btn-primary {
    background: var(--pos-primary-fill);
    border-color: var(--pos-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--pos-primary-fill-dark);
    border-color: var(--pos-primary-dark);
}

.btn-success { background: var(--pos-success-fill); border-color: var(--pos-success-fill); }
.btn-success:hover { background: var(--pos-success-fill-dark); border-color: var(--pos-success-fill-dark); }

.btn-danger { background: var(--pos-danger-fill); border-color: var(--pos-danger-fill); }
.btn-danger:hover { background: var(--pos-danger-fill-dark); border-color: var(--pos-danger-fill-dark); }

.btn-outline-primary { color: var(--pos-primary); border-color: var(--pos-primary); }
.btn-outline-primary:hover { background: var(--pos-primary-fill); border-color: var(--pos-primary-fill); }

.btn-outline-secondary { color: var(--pos-ink-soft); border-color: var(--pos-line); }
.btn-outline-secondary:hover { background: var(--pos-ink-soft); border-color: var(--pos-ink-soft); }

.table { color: var(--pos-ink); }
.table thead th {
    background: var(--pos-surface-alt);
    border-bottom: 1px solid var(--pos-line);
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--pos-ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.table > :not(caption) > * > * { border-bottom-color: var(--pos-line); }
.table-hover > tbody > tr:hover > * { background-color: var(--pos-surface-alt); }

.badge { border-radius: 20px; font-weight: 600; padding: 5px 10px; font-size: 0.74rem; }
/* الشارات دي بيتكتب عليها أبيض، فبتستخدم ألوان التعبئة الغامقة مش ألوان النص */
.bg-success { background-color: var(--pos-success-fill) !important; }
.bg-danger { background-color: var(--pos-danger-fill) !important; }
.bg-warning { background-color: var(--pos-warning) !important; }
.bg-primary { background-color: var(--pos-primary-fill) !important; }

.form-control, .form-select {
    border-radius: var(--pos-radius-sm);
    border-color: var(--pos-line);
    font-size: 0.88rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--pos-primary);
    box-shadow: 0 0 0 3px var(--pos-primary-soft);
}

.alert { border-radius: var(--pos-radius-sm); border: none; }
.alert-success { background: var(--pos-success-soft); color: var(--pos-success-dark); }
.alert-danger { background: var(--pos-danger-soft); color: var(--pos-danger-dark); }

.modal-content { border-radius: var(--pos-radius); border: none; }

/* عناوين الصفحات الداخلية */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.page-header h3 { margin: 0; font-size: 1.35rem; }

/* =====================================================
   شاشة البيع POS (محافظة على الكلاسات القديمة المستخدمة بالفعل)
   ===================================================== */

.pos-product-card {
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    user-select: none;
    border-radius: var(--pos-radius-sm);
}
.pos-product-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--pos-shadow-lg);
}
.pos-product-card .stock-badge {
    position: absolute;
    top: 5px;
    left: 5px;
}
.cart-table tbody tr td { vertical-align: middle; }
.qty-input { width: 60px; text-align: center; }

#cartPanel {
    position: sticky;
    top: 10px;
    max-height: 90vh;
    overflow-y: auto;
}

/* ===== طباعة الفاتورة (Receipt) ===== */
.receipt-box {
    width: 300px;
    margin: 0 auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}
.receipt-box hr { border-top: 1px dashed #000; }
.receipt-box table { width: 100%; }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
}

/* ===== طباعة الباركود ===== */
.barcode-label {
    display: inline-block;
    width: 200px;
    text-align: center;
    border: 1px dashed #999;
    margin: 5px;
    padding: 8px;
    page-break-inside: avoid;
}

/* =====================================================
   نافذة تنبيه/تأكيد موحّدة (بديل alert/confirm الافتراضية)
   ===================================================== */
.pos-dialog-backdrop {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(26, 34, 51, 0.45);
    backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    opacity: 0; pointer-events: none;
    transition: opacity 0.18s ease;
}
.pos-dialog-backdrop.show { opacity: 1; pointer-events: auto; }

.pos-dialog {
    width: 100%; max-width: 400px;
    background: var(--pos-surface);
    border-radius: var(--pos-radius);
    box-shadow: var(--pos-shadow-lg);
    padding: 28px 26px 22px;
    text-align: center;
    transform: scale(0.85) translateY(10px);
    opacity: 0;
    transition: transform 0.24s cubic-bezier(.34, 1.56, .64, 1), opacity 0.2s ease;
}
.pos-dialog-backdrop.show .pos-dialog { transform: scale(1) translateY(0); opacity: 1; }

.pos-dialog-icon {
    width: 56px; height: 56px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.6rem;
    background: var(--pos-primary-soft); color: var(--pos-primary);
}
.pos-dialog-icon.type-success { background: var(--pos-success-soft); color: var(--pos-success-dark); }
.pos-dialog-icon.type-warning { background: var(--pos-warning-soft); color: var(--pos-warning); }
.pos-dialog-icon.type-danger { background: var(--pos-danger-soft); color: var(--pos-danger-dark); }
.pos-dialog-icon.type-question { background: var(--pos-primary-soft); color: var(--pos-primary); }

.pos-dialog-message {
    color: var(--pos-ink);
    font-size: 0.98rem; font-weight: 600; line-height: 1.6;
    white-space: pre-line;
    margin-bottom: 22px;
}

.pos-dialog-actions { display: flex; gap: 10px; }
.pos-dialog-actions .btn { flex: 1; padding: 9px 0; }

/* ===== دروب داون بحث قابل لإعادة الاستخدام (initSearchableSelect في site.js) ===== */
.searchable-select-wrapper { position: relative; }
.searchable-select-hidden-native { display: none !important; }
.searchable-select-list {
    display: none;
    position: absolute; top: 100%; right: 0; left: 0; z-index: 1000;
    max-height: 220px; overflow-y: auto; margin-top: 2px;
    background: var(--pos-surface); border: 1px solid var(--pos-line);
    border-radius: var(--pos-radius-sm); box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.searchable-select-list.show { display: block; }
.searchable-select-item { padding: 8px 12px; cursor: pointer; font-size: 0.9rem; }
.searchable-select-item:hover { background: var(--pos-surface-alt); }
.searchable-select-empty { padding: 8px 12px; color: var(--pos-ink-soft, #999); font-size: 0.85rem; }
.searchable-select-create { color: var(--pos-primary, #0d6efd); font-weight: 600; border-top: 1px solid var(--pos-line); }
.searchable-select-create:hover { background: var(--pos-primary-soft, rgba(13,110,253,.08)); }

/* ===== صندوق رفع صورة الصنف - حجم ثابت دايمًا (فاضي أو فيه صورة) عشان التصميم ميتزحزحش ===== */
.product-image-box {
    width: 140px;
    height: 140px;
    border: 2px dashed var(--pos-line);
    border-radius: var(--pos-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    background: var(--pos-surface-alt);
    position: relative;
    transition: border-color .15s ease;
}
.product-image-box:hover { border-color: var(--pos-primary); }
.product-image-box img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.product-image-placeholder { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--pos-ink-soft, #999); font-size: 0.78rem; text-align: center; padding: 0 6px; }
.product-image-placeholder i { font-size: 1.8rem; }
.product-image-remove-btn {
    position: absolute; top: 4px; left: 4px;
    background: rgba(220,53,69,.9); color: #fff; border: none; border-radius: 50%;
    width: 22px; height: 22px; line-height: 1; font-size: .8rem;
    display: flex; align-items: center; justify-content: center;
}

/* =====================================================
   فئات Bootstrap اللي مابتتبعش data-bs-theme
   =====================================================
   bg-light وtext-dark وbg-white ألوانها ثابتة في بوتستراب 5.3 - مابتنعكسش مع
   الوضع الداكن. وهي مستخدمة في ترويسات الكروت والشارات في شاشات كتير، فكانت
   بتفضل بيضا والنص فوقها فاتح (تباين 1.2:1).
   وbtn-outline-dark لونه #212529 وبيبقى غير مرئي على خلفية داكنة. */
:root[data-theme="dark"] .bg-light { background-color: var(--pos-surface-alt) !important; }
:root[data-theme="dark"] .bg-white { background-color: var(--pos-surface) !important; }
/* text-dark بيتفلت بس جوّه bg-light اللي غمّقناه. لو غمّقناه في كل مكان،
   شارات bg-warning وbg-info (وهي بتفضل فاتحة) كان نصها هيبقى فاتح على فاتح */
:root[data-theme="dark"] .bg-light.text-dark,
:root[data-theme="dark"] .bg-light .text-dark { color: var(--pos-ink) !important; }

:root[data-theme="dark"] .btn-outline-dark {
    color: var(--pos-ink);
    border-color: var(--pos-line);
}
:root[data-theme="dark"] .btn-outline-dark:hover {
    background-color: var(--pos-surface-alt);
    border-color: var(--pos-ink-soft);
    color: var(--pos-ink);
}

/* ألوان بوتستراب الخام (#198754 و#dc3545) تباينها ضعيف على خلفية داكنة،
   فبنستخدم نسخنا المفتّحة. مهم: الحالة النشطة/المضغوطة مستثناة - لما الزرار
   يتملّي، نصه بيبقى أبيض على خلفية غامقة مش العكس */
:root[data-theme="dark"] .text-success { color: var(--pos-success) !important; }
:root[data-theme="dark"] .text-danger { color: var(--pos-danger) !important; }

:root[data-theme="dark"] .btn-outline-success {
    color: var(--pos-success);
    border-color: var(--pos-success);
}
:root[data-theme="dark"] .btn-outline-success:hover,
:root[data-theme="dark"] .btn-outline-success:active,
:root[data-theme="dark"] .btn-outline-success.active,
:root[data-theme="dark"] .btn-check:checked + .btn-outline-success {
    color: #fff;
    background-color: var(--pos-success-fill);
    border-color: var(--pos-success-fill);
}

:root[data-theme="dark"] .btn-outline-danger {
    color: var(--pos-danger-dark);
    border-color: var(--pos-danger-dark);
}
:root[data-theme="dark"] .btn-outline-danger:hover,
:root[data-theme="dark"] .btn-outline-danger:active,
:root[data-theme="dark"] .btn-outline-danger.active,
:root[data-theme="dark"] .btn-check:checked + .btn-outline-danger {
    color: #fff;
    background-color: var(--pos-danger-fill-dark);
    border-color: var(--pos-danger-fill-dark);
}


/* ===== أزرار outline في الوضع الفاتح =====
   Bootstrap بيستخدم #ffc107 و #dc3545 كلون نص، والاتنين بيسقطوا على خلفية فاتحة
   (1.63:1 و 4.01:1). بنستبدلهم بنسخ أغمق من ألوان النظام، وخلفية التمرير بتفضل
   غامقة عشان النص الأبيض يفضل مقروء. */
:root:not([data-theme="dark"]) .btn-outline-warning {
    color: #9E6400;
    border-color: #9E6400;
}
:root:not([data-theme="dark"]) .btn-outline-warning:hover,
:root:not([data-theme="dark"]) .btn-outline-warning:active,
:root:not([data-theme="dark"]) .btn-outline-warning.active,
:root:not([data-theme="dark"]) .btn-check:checked + .btn-outline-warning {
    color: #fff;
    background-color: #9E6400;
    border-color: #9E6400;
}

:root:not([data-theme="dark"]) .btn-outline-danger {
    color: var(--pos-danger);
    border-color: var(--pos-danger);
}
:root:not([data-theme="dark"]) .btn-outline-danger:hover,
:root:not([data-theme="dark"]) .btn-outline-danger:active,
:root:not([data-theme="dark"]) .btn-outline-danger.active,
:root:not([data-theme="dark"]) .btn-check:checked + .btn-outline-danger {
    color: #fff;
    background-color: var(--pos-danger-fill-dark);
    border-color: var(--pos-danger-fill-dark);
}

/* في الوضع الداكن الكهرماني الغامق بيختفي على الخلفية السودا، فبنرجّع النسخة الفاتحة */
:root[data-theme="dark"] .btn-outline-warning {
    color: var(--pos-warning);
    border-color: var(--pos-warning);
}
:root[data-theme="dark"] .btn-outline-warning:hover,
:root[data-theme="dark"] .btn-outline-warning:active,
:root[data-theme="dark"] .btn-outline-warning.active,
:root[data-theme="dark"] .btn-check:checked + .btn-outline-warning {
    color: #fff;
    background-color: #9E6400;
    border-color: #9E6400;
}

/* ‎#C44536‎ و‎#dc3545‎ كلون نص على خلفية فاتحة بيوقفوا عند 4.1–4.4:1، فالنسخة الغامقة
   هي اللي بتتستخدم كنص والفاتحة تفضل للخلفيات */
:root:not([data-theme="dark"]) .text-danger { color: var(--pos-danger-dark) !important; }
:root:not([data-theme="dark"]) .btn-outline-danger {
    color: var(--pos-danger-dark);
    border-color: var(--pos-danger-dark);
}

/* إخفاء روابط أو عناصر الفوتر الخاصة بـ Somee */
a[href*="somee.com"],
div[style*="z-index"][style*="somee"],
center:has(a[href*="somee.com"]),
footer a[href*="somee.com"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}