/* ============================================================
   Waynah UI — نظام التصميم المشترك للوحات (الإدارة + المزود)
   ============================================================ */

:root {
    --brand: #00FF02;              /* الأخضر النيون — للهوية على الداكن فقط */
    --brand-dim: rgba(0, 255, 2, .12);
    --green-700: #0B8A3E;          /* أخضر قراءة على الفاتح */
    --green-600: #0FA84F;
    --green-soft: #EAF9EF;
    --ink: #101613;                /* نص أساسي */
    --body: #4B5550;
    --muted: #78827C;
    --bg: #F2F5F3;
    --card: #FFFFFF;
    --line: #E3E9E5;
    --control-h: 42px;
    --line-2: #EDF1EE;
    --danger: #D92D20;
    --danger-soft: #FDF1F0;
    --warn: #B54708;
    --warn-soft: #FFF4E5;
    --side: #0A0E0C;
    --side-ink: #9BA5A0;
    --side-line: transparent;
    --surface-2: #F7FAF8;          /* رأس الجداول، البادئات، الخلفيات الثانوية */
    --row-hover: #F8FCF9;
    --row-new: #FAFFF9;            /* صف إشعار غير مقروء */
    --input-bg: #FFFFFF;
    --input-line: #D8DFDA;
    --label: #333D37;
    --btn-bg: #0F1512;             /* الزر الأساسي */
    --btn-ink: var(--brand);
    --green-line: #CBEEDA;
    --flash-ink: #0A6B33;
    --danger-line: #F2C1BC;
    --disabled-ink: #B9C2BD;
    --pill-bg: #F1F4F2;
    --chart-grid: #EDF1EE;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 22, 19, .05);
    --shadow-md: 0 1px 2px rgba(16, 22, 19, .04), 0 10px 28px -14px rgba(16, 22, 19, .12);
    --font: "IBM Plex Sans Arabic", "Segoe UI", system-ui, -apple-system, sans-serif;
    color-scheme: light;
}

/* ---------- الوضع الداكن — نفس الهوية على خلفية فحمي مخضرة ---------- */
:root[data-theme="dark"] {
    --brand-dim: rgba(0, 255, 2, .16);
    --green-700: #3DDC84;          /* أخضر قراءة على الداكن */
    --green-600: #22C55E;
    --green-soft: rgba(34, 197, 94, .14);
    --ink: #E8F0EB;
    --body: #B4BFB9;
    --muted: #86928B;
    --bg: #0B100D;
    --card: #121915;
    --line: #232E28;
    --line-2: #1B241F;
    --danger: #F97066;
    --danger-soft: rgba(249, 112, 102, .12);
    --warn: #F5A524;
    --warn-soft: rgba(245, 165, 36, .14);
    --side: #070A08;
    --side-line: #1B241F;
    --surface-2: #17201B;
    --row-hover: #161F1A;
    --row-new: rgba(0, 255, 2, .04);
    --input-bg: #0E1411;
    --input-line: #2A3630;
    --label: #C9D3CD;
    --btn-bg: var(--brand);
    --btn-ink: #06120A;
    --green-line: rgba(34, 197, 94, .32);
    --flash-ink: #6FE9A2;
    --danger-line: rgba(249, 112, 102, .35);
    --disabled-ink: #4A5750;
    --pill-bg: #1E2823;
    --chart-grid: #1F2924;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -14px rgba(0, 0, 0, .6);
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; }

/* ---------- الهيكل ---------- */
.shell { display: flex; min-height: 100vh; }

.side {
    width: 248px;
    background:
        radial-gradient(420px 200px at 85% -40px, rgba(0, 255, 2, .09), transparent 65%),
        var(--side);
    color: #fff;
    padding: 22px 14px 28px;
    border-inline-end: 1px solid var(--side-line);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #263029 transparent;
}

.side .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 10px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    margin-bottom: 14px;
}
.side .brand img { height: 34px; width: auto; }
.side .brand .word { color: var(--brand); font-weight: 800; font-size: 19px; line-height: 1; }
.side .brand small { display: block; color: var(--side-ink); font-size: 11px; margin-top: 4px; font-weight: 500; }

.side .group { color: #5E6A64; font-size: 10.5px; font-weight: 700; letter-spacing: .6px; padding: 16px 12px 8px; }

.side a.item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    margin: 2px 0;
    border-radius: 10px;
    color: var(--side-ink);
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.side a.item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.side a.item:hover { background: rgba(255, 255, 255, .05); color: #E9F5EC; }
.side a.item.on {
    background: linear-gradient(90deg, rgba(0, 255, 2, .13), rgba(0, 255, 2, .04));
    color: var(--brand);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--brand);
}
[dir="ltr"] .side a.item.on {
    background: linear-gradient(270deg, rgba(0, 255, 2, .13), rgba(0, 255, 2, .04));
    box-shadow: inset -3px 0 0 var(--brand);
}
.side a.item.on svg { opacity: 1; }
.side a.item .badge {
    background: var(--brand);
    color: #06120A;
    border-radius: 99px;
    font-size: 10.5px;
    font-weight: 800;
    padding: 1px 7px;
    margin-inline-start: auto;
}

.main { flex: 1; min-width: 0; padding: 22px 28px 40px; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.topbar h2 { font-size: 19px; font-weight: 800; letter-spacing: -.2px; }
.topbar .crumb { color: var(--muted); font-size: 12px; margin-top: 3px; }
.topbar .user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar .user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--green-soft);
    color: var(--green-700);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 13px;
    border: 1px solid var(--green-line);
}
.topbar .user .who { text-align: start; line-height: 1.3; }
.topbar .user .who b { font-size: 13px; }
.topbar .user .who span { display: block; color: var(--muted); font-size: 11px; }

/* الاسم وزر الخروج فوق، وزر اللغة تحتهم في النص */
.topbar-end { display: flex; flex-direction: column; align-items: center; gap: 14px; }

/* زر اللغة وزر الثيم جنب بعض */
.prefs { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #DDE5DF;
    background: #EEF2EF;
    color: var(--body);
    cursor: pointer;
    flex: none;
    transition: background .15s ease, color .15s ease, transform .25s cubic-bezier(.16, 1, .3, 1);
}
.theme-toggle:hover { color: var(--ink); }
.theme-toggle:active { transform: rotate(-25deg) scale(.92); }
.theme-toggle:focus-visible { outline: 2px solid var(--green-600); outline-offset: 2px; }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); color: var(--brand); }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* توجل اللغة في الوضع الداكن (نفس شكل نسخة الهيدر الغامق في الموقع) */
[data-theme="dark"] .lang-toggle { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); }
[data-theme="dark"] .lang-toggle::before { background: var(--brand); box-shadow: 0 2px 10px rgba(0, 255, 2, .3); }
[data-theme="dark"] .lang-toggle a { color: #A9B4AE; }
[data-theme="dark"] .lang-toggle a:hover { color: #E8F2EB; }
[data-theme="dark"] .lang-toggle a.on { color: #06120A; }

/* ---------- الكروت ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.card > h3:first-child,
.card > h4:first-child { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.card > h3:first-child::before,
.card > h4:first-child::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-dim);
}

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--card); }
/* th مش لازم يكون جوه thead — أغلب الجداول بتحط صف العناوين على طول في table */
th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .3px;
    padding: 11px 12px;
    text-align: start;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--line-2);
    font-size: 13.5px;
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s ease; }
tr:has(td):hover { background: var(--row-hover); }

/* ---------- الأزرار ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--btn-bg);
    color: var(--btn-ink);
    border: 1px solid var(--btn-bg);
    border-radius: 10px;
    padding: 9px 18px;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    font-family: inherit;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
    width: fit-content;
    max-width: 100%;
    height: var(--control-h);
    padding-block: 0;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px -8px rgba(15, 21, 18, .5); }
.btn.out { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.out:hover { background: var(--row-hover); box-shadow: var(--shadow-sm); }
.btn.danger { background: var(--card); color: var(--danger); border: 1px solid var(--danger-line); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }

/* أزرار الإجراءات داخل صفوف الجداول */
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-actions form { margin: 0; display: contents; }

/* ---------- النماذج ---------- */
/* صف فيلدات ثنائي (عربي + إنجليزي) */
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
@media (max-width: 560px) { .form-row { grid-template-columns:1fr; } }
/* زر الحفظ ميلاصقش آخر فيلد */
.card form button.btn { margin-top: 18px; }
/* فورم البحث/التصفية: الفيلدات وزرار البحث في صف واحد، ومسافة 12 بينهم */
.search-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search-bar input { flex: 1 1 220px; width: auto; min-width: 0; }
.search-bar select { flex: 0 0 160px; width: 160px; }
.search-bar button.btn,
.card .search-bar button.btn,
.row-actions button.btn,
.card td form button.btn { margin-top: 0; }
label { display: block; margin: 12px 0 6px; font-size: 12.5px; font-weight: 700; color: var(--label); }
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--input-line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: var(--input-bg);
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--green-600);
    box-shadow: 0 0 0 3px rgba(15, 168, 79, .15);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select {
    height: var(--control-h);
    padding-block: 0;
}
textarea { line-height: 1.8; resize: vertical; }

/* فيلد الجوال: كود الدولة جوه نفس الإطار */
.phone-field {
    display: flex;
    align-items: stretch;
    direction: ltr;
    height: var(--control-h);
    border: 1px solid var(--input-line);
    border-radius: 10px;
    background: var(--input-bg);
    overflow: hidden;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.phone-field:focus-within { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(15, 168, 79, .15); }
.phone-field .prefix {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--surface-2);
    border-right: 1px solid var(--input-line);
    color: var(--body);
    font-weight: 600;
    font-size: 13.5px;
    flex-shrink: 0;
}
.phone-field input { flex: 1; min-width: 0; height: 100%; border: 0; border-radius: 0; box-shadow: none; }
.phone-field input:focus { box-shadow: none; }
input[type="checkbox"] { accent-color: var(--green-600); }
input[type="file"] { padding: 8px; background: var(--surface-2); }

/* ---------- الرسائل ---------- */
.flash, .errors {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13.5px;
    font-weight: 600;
}
.flash { background: var(--green-soft); border: 1px solid var(--green-line); color: var(--flash-ink); }
.flash::before { content: "✓"; width: 20px; height: 20px; flex: none; background: var(--green-600); color: #fff; border-radius: 50%; display: grid; place-items: center; font-size: 12px; }
.errors { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger); }
.errors::before { content: "!"; width: 20px; height: 20px; flex: none; background: var(--danger); color: #fff; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; }

/* ---------- الإحصائيات ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.stat { position: relative; overflow: hidden; }
.stat .n { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin-top: 6px; }
.stat .icon {
    position: absolute;
    top: 18px;
    inset-inline-end: 18px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--green-soft);
    color: var(--green-700);
    display: grid;
    place-items: center;
    font-size: 18px;
}

/* ---------- شرائح الحالة ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 99px;
    padding: 3px 10px;
    font-size: 11.5px;
    font-weight: 700;
    background: var(--pill-bg);
    color: var(--body);
}
.pill.ok { background: var(--green-soft); color: var(--green-700); }
.pill.ok::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green-600); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.warn::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #E08A3C; }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.bad::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }

/* ---------- التنقل بين الصفحات (Laravel pagination) ---------- */
.pagination { display: flex; gap: 6px; list-style: none; padding: 0; margin: 16px 0 0; flex-wrap: wrap; }
.pagination li { display: inline-block; }
.pagination a, .pagination span {
    display: inline-block;
    min-width: 34px;
    padding: 7px 10px;
    text-align: center;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--card);
    font-size: 13px;
    font-weight: 600;
    color: var(--body);
    transition: all .12s ease;
}
.pagination a:hover { border-color: var(--green-600); color: var(--green-700); }
.pagination .active span, .pagination .active a {
    background: var(--btn-bg);
    color: var(--btn-ink);
    border-color: var(--btn-bg);
}
.pagination .disabled span { color: var(--disabled-ink); background: var(--surface-2); }
/* الأسهم ‹ › من غير transform: الحرفين Bidi_Mirrored فالمتصفح بيقلبهم لوحده في RTL
   («السابق» على اليمين وبيشاور يمين). القلب بالـ CSS كان بيعكسهم تاني. */
.bulk-actions { display: flex; align-items: center; gap: 8px; }
.bulk-actions .btn[disabled] { opacity: .45; cursor: not-allowed; }
.check-col { width: 36px; }
.pager-summary { margin: 8px 0 0; }

/* ---------- متنوعات ---------- */
.muted { color: var(--muted); font-size: 12.5px; }
.center { max-width: 420px; margin: 8vh auto; }
.stars { color: #F59E0B; font-weight: 800; }
details { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--card); }
details summary { font-weight: 700; cursor: pointer; }
.hr { border: 0; border-top: 1px solid var(--line-2); margin: 18px 0; }

/* ============ الريسبونسف (موبايل/تابلت) ============ */
.scrim { display: none; }
.menu-btn {
    display: none;
    align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--card); cursor: pointer; flex: none;
}
.menu-btn svg { width: 20px; height: 20px; color: var(--ink); }
[data-theme="dark"] .btn:hover { box-shadow: 0 6px 18px -8px rgba(0, 255, 2, .35); }
[data-theme="dark"] .btn.out:hover, [data-theme="dark"] .btn.danger:hover { box-shadow: var(--shadow-sm); }

@media (max-width: 900px) {
    .shell { display: block; }

    /* السايدبار يبقى درج منزلق من اليمين */
    .side {
        position: fixed; top: 0; right: 0; bottom: 0;
        width: min(84vw, 280px); height: 100vh;
        transform: translateX(100%);
        transition: transform .25s ease;
        z-index: 100;
        box-shadow: -20px 0 60px rgba(0, 0, 0, .25);
    }
    .side.open { transform: translateX(0); }
    /* الإنجليزي (LTR): الدرج من الشمال */
    [dir="ltr"] .side { right: auto; left: 0; transform: translateX(-100%); box-shadow: 20px 0 60px rgba(0, 0, 0, .25); }
    [dir="ltr"] .side.open { transform: translateX(0); }
    .scrim {
        display: block; position: fixed; inset: 0;
        background: rgba(10, 14, 12, .45); z-index: 99;
        opacity: 0; pointer-events: none; transition: opacity .2s ease;
    }
    .scrim.show { opacity: 1; pointer-events: auto; }

    .menu-btn { display: inline-flex; }

    .main { padding: 16px 14px 32px; }
    .topbar { margin-bottom: 14px; }
    .topbar h2 { font-size: 17px; }
    .topbar .user .who { display: none; }
    .topbar-end { flex-direction: row; align-items: center; gap: 10px; }

    /* الجداول: أقل عرض منطقي والكارت بيعمل سكرول أفقي */
    .card { padding: 14px; overflow-x: auto; }
    .card > table { min-width: 560px; }
    .table-wrap > table { min-width: 560px; }
    th { padding: 9px 10px; font-size: 10.5px; }
    tbody td { padding: 9px 10px; font-size: 12.5px; }

    .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .stat .n { font-size: 24px; }
    .stat .icon { width: 34px; height: 34px; top: 14px; inset-inline-end: 14px; }

    .btn { padding: 0 14px; font-size: 13px; }
    input, select, textarea { font-size: 16px; } /* منع الزووم التلقائي في iOS */
    .center { margin: 4vh auto; }
}
