/* ═══════════════════════════════════════════════
   WOS — الثيم الليلي + تحسينات الجوال (v1.1)
   html[data-theme="dark"] — يُفعَّل من زر القمر في الشريط العلوي ويُحفظ في المتصفح
═══════════════════════════════════════════════ */

/* ───────── Dark theme ───────── */
html[data-theme="dark"]{
  color-scheme:dark;
  --brand:#a78bfa; --brand-d:#c4b5fd; --brand-m:#f472b6; --brand2:#fb923c;
  --brand-pale:rgba(167,139,250,.10); --brand-light:rgba(167,139,250,.16);
  --surface:rgba(30,27,46,.92); --surface2:rgba(38,34,58,.95);
  --border:rgba(167,139,250,.18); --border2:#2e2a45;
  --tx:#ece9f6; --tx2:#c3bdd8; --tx3:#8c86a3;
  --sh:0 1px 3px rgba(0,0,0,.35),0 4px 18px rgba(0,0,0,.25);
  --sh2:0 10px 34px rgba(0,0,0,.45);
}
html[data-theme="dark"] body{background:#13111d;color:var(--tx)}
html[data-theme="dark"] body::before{
  background:
    radial-gradient(38% 32% at 8% 6%,rgba(124,58,237,.22) 0%,transparent 70%),
    radial-gradient(34% 30% at 96% 12%,rgba(236,72,153,.12) 0%,transparent 70%),
    radial-gradient(40% 36% at 90% 92%,rgba(249,115,22,.08) 0%,transparent 70%),
    linear-gradient(160deg,#14121f 0%,#171426 50%,#13111d 100%);
}
html[data-theme="dark"] .topbar{background:rgba(22,20,34,.88);border-bottom-color:var(--border);box-shadow:0 4px 22px rgba(0,0,0,.35)}
html[data-theme="dark"] .sidebar{background:rgba(22,20,34,.94);border-color:var(--border)}
html[data-theme="dark"] .card,html[data-theme="dark"] .stat-card{background:var(--surface);border-color:var(--border)}
html[data-theme="dark"] .card-hd{background:linear-gradient(180deg,rgba(167,139,250,.07),transparent);border-bottom-color:var(--border2)}
html[data-theme="dark"] .tbl th{background:linear-gradient(180deg,#221f35,#1d1a2e);color:var(--tx2);border-bottom-color:var(--border)}
html[data-theme="dark"] .tbl td{border-bottom-color:var(--border2);color:var(--tx)}
html[data-theme="dark"] .tbl tbody tr:hover{background:rgba(167,139,250,.07)}
html[data-theme="dark"] .form-ctrl,html[data-theme="dark"] .form-sel,
html[data-theme="dark"] input:not([type=checkbox]):not([type=radio]):not([type=range]),html[data-theme="dark"] select,html[data-theme="dark"] textarea{
  background:#1c1a2b!important;color:var(--tx)!important;border-color:#363151!important}
html[data-theme="dark"] .form-ctrl:focus,html[data-theme="dark"] .form-sel:focus{background:#221f35!important;border-color:var(--brand-m)!important}
html[data-theme="dark"] ::placeholder{color:#6f6988}
html[data-theme="dark"] input[type=date]::-webkit-calendar-picker-indicator,html[data-theme="dark"] input[type=month]::-webkit-calendar-picker-indicator{filter:invert(.85)}
html[data-theme="dark"] .dd-menu,html[data-theme="dark"] .modal-box,html[data-theme="dark"] .chat-win{background:#1d1a2e!important;border-color:var(--border)}
html[data-theme="dark"] .btn-ghost{color:var(--tx2)}
html[data-theme="dark"] .btn-ghost:hover{background:rgba(167,139,250,.12);color:var(--brand)}
html[data-theme="dark"] .btn-outline{color:var(--brand);border-color:var(--brand)}
html[data-theme="dark"] .empty-state,html[data-theme="dark"] .text-muted{color:var(--tx3)}
html[data-theme="dark"] .bdg-new{background:#2a2640;color:var(--tx2)}
html[data-theme="dark"] footer{background:transparent!important;color:var(--tx3)!important;border-color:var(--border2)!important}
/* أنماط مكتوبة داخل الصفحات (inline) بألوان فاتحة → مقابلها الليلي */
html[data-theme="dark"] [style*="background:#fff"],html[data-theme="dark"] [style*="background: #fff"],html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background:white"]{background:#1d1a2e!important}
html[data-theme="dark"] [style*="background:#f8fafc"],html[data-theme="dark"] [style*="background:#f1f5f9"],html[data-theme="dark"] [style*="background:var(--surface2)"],
html[data-theme="dark"] [style*="background:#fafafa"],html[data-theme="dark"] [style*="background:#f9fafb"]{background:#221f35!important}
html[data-theme="dark"] [style*="background:#f0fdf4"],html[data-theme="dark"] [style*="background:#dcfce7"]{background:rgba(22,163,74,.15)!important}
html[data-theme="dark"] [style*="background:#fef2f2"],html[data-theme="dark"] [style*="background:#fff1f2"],html[data-theme="dark"] [style*="background:#fee2e2"]{background:rgba(220,38,38,.14)!important}
html[data-theme="dark"] [style*="background:#fffbeb"],html[data-theme="dark"] [style*="background:#fef3c7"]{background:rgba(217,119,6,.14)!important}
html[data-theme="dark"] [style*="background:#eff6ff"],html[data-theme="dark"] [style*="background:#f0f9ff"],html[data-theme="dark"] [style*="background:#e0f2fe"],html[data-theme="dark"] [style*="background:#eef2ff"]{background:rgba(59,130,246,.14)!important}
html[data-theme="dark"] [style*="color:#1e293b"],html[data-theme="dark"] [style*="color:#0f172a"],html[data-theme="dark"] [style*="color:#334155"],html[data-theme="dark"] [style*="color:var(--tx)"]{color:var(--tx)!important}
html[data-theme="dark"] [style*="color:#475569"],html[data-theme="dark"] [style*="color:#64748b"]{color:var(--tx2)!important}
html[data-theme="dark"] [style*="border:1px solid #e2e8f0"],html[data-theme="dark"] [style*="border:1.5px solid #e2e8f0"],html[data-theme="dark"] [style*="border:2px solid #e2e8f0"],
html[data-theme="dark"] [style*="border:1px dashed #cbd5e1"]{border-color:#363151!important}
html[data-theme="dark"] .success-hero{filter:saturate(.9) brightness(.92)}
/* الشعار مفرغ: يظهر أبيض في الوضع الليلي */
html[data-theme="dark"] img[src*="logo"]{filter:brightness(0) invert(1)!important;background:none!important}

/* زر الثيم */
.theme-btn .bi-sun{display:none}
html[data-theme="dark"] .theme-btn .bi-moon-stars{display:none}
html[data-theme="dark"] .theme-btn .bi-sun{display:inline}

/* ───────── Mobile polish ───────── */
@media(max-width:768px){
  .pg-header{gap:.45rem;margin-bottom:.8rem}
  .pg-header>div,.pg-header>form{width:100%;display:flex;flex-wrap:wrap;gap:.35rem}
  .pg-header .btn{flex:1 1 auto;justify-content:center;font-size:12px;padding:.45rem .6rem}
  .card{border-radius:12px}
  .btn{min-height:38px}
  .btn-sm{min-height:32px}
  .tbl-wrap{margin:0 -.1rem}
  .main-wrap{padding-bottom:5rem!important}
  .dd-menu{min-width:200px}
  .topbar-right{gap:.15rem}
  .topbar-right .btn{min-height:34px}
  .modal-box{max-width:100%;border-radius:16px}
  .overlay{padding:.6rem;align-items:flex-end}
}

/* ───────── زر المحادثة: لا يغطي القوائم ───────── */
.chat-fab{transition:transform .25s ease,opacity .25s ease,box-shadow var(--tr)}
.chat-fab.fab-hide{transform:translateY(140%)!important;opacity:0;pointer-events:none}
.main-wrap{padding-bottom:5.5rem}
@media(max-width:768px){
  .chat-fab{width:42px;height:42px;font-size:1rem;bottom:.7rem;opacity:.92}
}

/* زر المحادثة انتقل إلى الشريط العلوي — لا زر عائم يغطي القوائم */
.chat-fab{display:none!important}
.chat-top .chat-dot{top:-2px;left:-2px}
.chat-win{top:calc(var(--th) + 8px)!important;bottom:auto!important;max-height:calc(100vh - var(--th) - 24px)}
html[data-theme="dark"] .stat-card::before{background:linear-gradient(135deg,rgba(255,255,255,.05) 0%,transparent 60%)}
html[data-theme="dark"] .chat-dot{border-color:#1d1a2e}
[dir=rtl] .chat-win{right:auto!important;left:1.3rem!important}
[dir=ltr] .chat-win{left:auto!important;right:1.3rem!important}
@media(max-width:768px){[dir=rtl] .chat-win,[dir=ltr] .chat-win{left:.8rem!important;right:.8rem!important;width:auto!important}}

.topbar .logo img[src*="logo_wide"]{height:34px;max-width:150px;object-fit:contain;filter:none}
@media(max-width:768px){.topbar .logo img[src*="logo_wide"]{height:28px;max-width:110px}}

/* قائمة الحساب (الشعار الدائري): تفتح داخل الشاشة في العربي والإنجليزي */
[dir=rtl] .topbar .dd-menu{right:auto!important;left:0!important}
[dir=ltr] .topbar .dd-menu{left:auto!important;right:0!important}
.topbar .dd-menu{z-index:1100;max-height:calc(100vh - var(--th) - 16px);overflow-y:auto}
/* شريط «التصفح كـ» */
.viewas-bar{position:fixed;top:var(--th);left:0;right:0;z-index:960;background:#f59e0b;color:#1f1300;font-size:12.5px;font-weight:700;text-align:center;padding:.4rem .8rem}
.viewas-bar button{margin-inline-start:.6rem;border:0;border-radius:8px;background:#1f1300;color:#fff;font:inherit;font-size:12px;padding:.2rem .7rem;cursor:pointer}
.viewas-bar~.sidebar{top:calc(var(--th) + 32px)}
.viewas-bar~.main-wrap{margin-top:calc(var(--th) + 32px)}

/* ───────── الجولة التعريفية ───────── */
#tour-mask{position:fixed;inset:0;z-index:3000;background:rgba(15,10,30,.58)}
#tour-mask.clear{background:transparent}
#tour-hole{position:fixed;z-index:3001;border-radius:12px;box-shadow:0 0 0 9999px rgba(15,10,30,.58);outline:2px solid #fbbf24;outline-offset:0;pointer-events:none}
#tour-tip{position:fixed;z-index:3002;width:min(340px,calc(100vw - 16px));background:#fff;color:#1e1b2e;border-radius:14px;box-shadow:0 18px 50px rgba(0,0,0,.3);padding:.9rem 1rem .75rem;font-size:13.5px;line-height:1.75}
#tour-tip.center{top:50%;left:50%;transform:translate(-50%,-50%);width:min(380px,calc(100vw - 24px))}
#tour-tip .tt-h{display:flex;justify-content:space-between;align-items:center;gap:.5rem;margin-bottom:.3rem}
#tour-tip .tt-h b{font-size:14.5px;color:#5b21b6}
#tour-tip .tt-n{font-size:11px;color:#94a3b8;white-space:nowrap}
#tour-tip .tt-f{display:flex;gap:.4rem;align-items:center;margin-top:.7rem}
#tour-tip button{border:0;border-radius:9px;padding:.42rem .9rem;font:inherit;font-size:12.5px;font-weight:700;cursor:pointer}
#tour-tip .tt-next{background:linear-gradient(135deg,#7c3aed,#ec4899);color:#fff}
#tour-tip .tt-prev{background:#f1f5f9;color:#334155}
#tour-tip .tt-skip{background:none;color:#94a3b8;padding-inline:.2rem}
html[data-theme="dark"] #tour-tip{background:#1d1a2e;color:#ece9f6}
html[data-theme="dark"] #tour-tip .tt-h b{color:#c4b5fd}
html[data-theme="dark"] #tour-tip .tt-prev{background:#2a2640;color:#ece9f6}

/* وصف البند مع زر لغة الكتابة (ع / EN) — الزر بجانب الحقل (لا يغطي النص) */
.ltg-wrap{display:flex;gap:.35rem;align-items:flex-start}
.ltg-wrap>.form-ctrl{flex:1;min-width:0}
.lang-tg{flex:none;margin-top:4px;border:1px solid var(--border,#e2e8f0);background:var(--surface,#fff);color:var(--tx3,#64748b);
  border-radius:7px;font:700 11px/1 inherit;padding:.4rem .45rem;cursor:pointer;min-width:2.5rem}
.lang-tg:hover{border-color:var(--brand);color:var(--brand)}.lang-tg.is-en{color:#4338ca;border-color:#c7d2fe}
/* بند أمر التشغيل: الوحدة ظاهرة وقابلة للتعديل */
.irow .iunit{text-align:center;padding-inline:.3rem}
@media (max-width:640px){
  .irow{grid-template-columns:1fr 1fr 1fr !important}
  .irow>.pick-wrap{grid-column:1/-1}
  .irow>.irow-total{grid-column:1/3}
  #items-hdr{display:none !important}
}

/* نماذج الطلب: العمودان فوق بعض على الجوال */
@media (max-width:768px){ .form-2col{grid-template-columns:1fr !important} }
