/* هوية كراج: الألوان والخطوط من GARAGE_BRAND.md — خطوط مضمّنة محلياً (Noto Kufi Arabic + Montserrat في ملف واحد لكل وزن) */
@font-face { font-family: "GarageBrand"; src: url("fonts/garage_brand_regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "GarageBrand"; src: url("fonts/garage_brand_medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "GarageBrand"; src: url("fonts/garage_brand_semibold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "GarageBrand"; src: url("fonts/garage_brand_bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --garage-blue: #1A3D65; --white: #FFFFFF; --deep-navy: #0F2744;
  --steel: #46658C; --mist: #E8EDF3; --light-steel: #9FB4CF;
  /* حالات وظيفية (باهتة) — نفس ألوان الخطورة في التطبيق */
  --ok: #3B7A57; --low: #46658C; --medium: #8A6D1F; --high: #A0522D; --critical: #A8322D;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "GarageBrand", sans-serif; background: var(--mist); color: var(--garage-blue); }
button, input { font: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--steel); font-size: 14px; }

/* ---------- الدخول ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--garage-blue); padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--deep-navy); color: var(--white); border-radius: 12px; padding: 32px 24px; text-align: center; }
.login-logo { width: 120px; height: auto; margin: 8px auto 0; display: block; }
.tagline { font-weight: 600; letter-spacing: .25em; font-size: 11px; color: var(--light-steel); margin: 18px 0 6px; direction: ltr; }
.login h1 { font-size: 22px; margin: 0 0 24px; }
.login form { display: grid; gap: 10px; text-align: start; }
.login label { font-size: 14px; color: var(--light-steel); }
.phone-row { display: flex; direction: ltr; gap: 8px; }
.cc { display: grid; place-items: center; padding: 0 12px; border-radius: 10px; background: var(--garage-blue); font-weight: 700; }
.login input { width: 100%; padding: 14px; border-radius: 10px; border: 1px solid var(--steel); background: var(--garage-blue); color: var(--white); direction: ltr; text-align: left; font-weight: 700; letter-spacing: .05em; }
.login button { padding: 14px; border-radius: 10px; border: 0; background: var(--white); color: var(--garage-blue); font-weight: 700; cursor: pointer; }
.login button.link { background: none; color: var(--light-steel); padding: 4px; font-weight: 500; }
.login button:disabled { opacity: .6; cursor: wait; }
.error { color: #F2B8B5; min-height: 1.2em; font-size: 14px; margin: 12px 0 0; }

/* ---------- الرأس ---------- */
.top { background: var(--garage-blue); color: var(--white); display: flex; align-items: center; gap: 16px; padding: 14px 24px; }
.top-logo { height: 52px; width: auto; }
.top-title { flex: 1; border-inline-start: 1px solid rgba(255,255,255,.35); padding-inline-start: 16px; }
.top-title h1 { font-size: 20px; margin: 0; }
.who { font-size: 13px; color: var(--light-steel); }
.ghost { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; padding: 8px 14px; cursor: pointer; }

.main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; display: grid; gap: 16px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.periods { display: flex; background: var(--white); border-radius: 12px; padding: 4px; gap: 4px; }
.periods button { border: 0; background: transparent; color: var(--steel); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.periods button.active { background: var(--garage-blue); color: var(--white); }
#search { flex: 1; min-width: 220px; max-width: 420px; padding: 11px 16px; border-radius: 999px; border: 1px solid var(--light-steel); background: var(--white); color: var(--garage-blue); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { background: var(--garage-blue); color: var(--white); border-radius: 12px; padding: 16px 18px; display: grid; gap: 6px; }
.kpi-label { font-size: 13px; color: var(--light-steel); }
.kpi-value { font-size: 26px; font-weight: 700; }

.card { background: var(--white); border-radius: 12px; padding: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.card h2 { font-size: 17px; margin: 0; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th { text-align: start; color: var(--steel); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--light-steel); white-space: nowrap; }
.list td { padding: 12px 8px; border-bottom: 1px solid var(--mist); white-space: nowrap; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: var(--mist); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-weight: 700; }
.empty { text-align: center; color: var(--steel); padding: 32px 0; }

.pill { display: inline-block; color: var(--white); padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.sev-OK { background: var(--ok); } .sev-LOW { background: var(--low); } .sev-MEDIUM { background: var(--medium); }
.sev-HIGH { background: var(--high); } .sev-CRITICAL { background: var(--critical); }
.sev-NONE { background: var(--light-steel); color: var(--garage-blue); } /* لا شيء */

/* ---------- التفاصيل ---------- */
dialog#detail { width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 0; border-radius: 12px; padding: 0; color: var(--garage-blue); }
dialog::backdrop { background: rgba(15,39,68,.6); }
.detail-head { position: sticky; top: 0; background: var(--garage-blue); color: var(--white); display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; }
.detail-head h2 { margin: 0; font-size: 20px; }
.detail-head .muted { color: var(--light-steel); }
.detail-body { padding: 20px; display: grid; gap: 20px; }
.section h3 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.section h3::before { content: ""; width: 8px; height: 8px; background: var(--light-steel); transform: rotate(45deg); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.fact { background: var(--mist); border-radius: 10px; padding: 10px 12px; }
.fact span { display: block; font-size: 12px; color: var(--steel); }
.fact b { font-size: 15px; }
.files { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; gap: 8px; align-items: center; background: var(--garage-blue); color: var(--white); text-decoration: none; border-radius: 10px; padding: 10px 16px; font-weight: 600; }
.btn.secondary { background: var(--mist); color: var(--garage-blue); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; background: var(--mist); display: block; }
.gallery figcaption { font-size: 12px; color: var(--steel); margin-top: 4px; text-align: center; }
.parts img { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; display: block; }
.parts-cell { display: flex; gap: 6px; }
.parts-cell small { display: block; font-size: 10px; color: var(--steel); text-align: center; }
.totals { display: grid; gap: 6px; max-width: 320px; margin-inline-start: auto; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { background: var(--garage-blue); color: var(--white); padding: 10px 12px; border-radius: 10px; font-weight: 700; }
audio { width: 100%; max-width: 420px; }
.transcript { background: var(--mist); border-radius: 10px; padding: 12px; line-height: 1.8; font-size: 14px; white-space: pre-wrap; }

@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .top { padding: 12px 16px; }
  .top-logo { height: 42px; }
  .kpi-value { font-size: 20px; }
}

/* ---------- المستخدمون ---------- */
.u-actions { display: flex; gap: 8px; }
.u-actions .btn, .u-result .btn, .u-form .btn { border: 0; cursor: pointer; }
.u-actions .btn { padding: 6px 12px; font-size: 13px; }
.u-form { display: flex; flex-wrap: wrap; gap: 8px; }
.u-form input, .u-form select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--light-steel); background: var(--white); color: var(--garage-blue); }
.u-form input { direction: ltr; text-align: left; flex: 1; min-width: 160px; }
.u-form input.rtl { direction: rtl; text-align: start; }
.u-form .btn:disabled { opacity: .6; cursor: wait; }
.u-result { background: var(--mist); border-radius: 10px; padding: 12px; line-height: 2; margin: 0; }
.u-result code { background: var(--white); padding: 4px 10px; border-radius: 8px; font-weight: 700; letter-spacing: .05em; }
.u-result .btn { padding: 4px 10px; }

/* ---------- إعدادات التطبيق (للمالك) ---------- */
.setting { display: flex; gap: 16px; align-items: center; justify-content: space-between; background: var(--mist); border-radius: 10px; padding: 14px 16px; }
.setting b { display: block; margin-bottom: 4px; }
.switch { position: relative; flex: none; width: 52px; height: 30px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--light-steel); border-radius: 999px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--white); transition: transform .15s; }
.switch input:checked + span { background: var(--garage-blue); }
.switch input:checked + span::after { transform: translateX(-22px); } /* RTL: يتحرك نحو اليسار */
.switch input:disabled + span { opacity: .5; }
.switch input:focus-visible + span { outline: 2px solid var(--steel); outline-offset: 2px; }

.migrate-note { font-size: 14px; color: var(--light-steel); line-height: 1.8; margin: 0 0 6px; }

/* ---------- الأقسام: الفحوصات / الحجوزات ---------- */
.views { display: flex; gap: 4px; background: var(--white); border-radius: 12px; padding: 4px; justify-self: start; }
.views button { border: 0; background: transparent; color: var(--steel); padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; }
.views button.active { background: var(--garage-blue); color: var(--white); }
.badge { background: var(--medium); color: var(--white); border-radius: 999px; min-width: 22px; padding: 0 7px; font-size: 12px; line-height: 22px; text-align: center; }
.view { display: grid; gap: 16px; }
.toolbar .btn { border: 0; cursor: pointer; }
.list.bookings tbody tr { cursor: default; }
.list.bookings tr.dim td { color: var(--steel); }
.list.bookings a { color: inherit; font-weight: 700; text-decoration: none; }
.list.bookings .u-actions .btn { padding: 6px 12px; font-size: 13px; text-decoration: none; }
.st-pending { background: var(--medium); } .st-confirmed { background: var(--ok); } .st-done { background: var(--garage-blue); }
.st-cancelled, .st-noshow { background: var(--light-steel); color: var(--garage-blue); }

/* ---------- إعدادات الحجز ---------- */
dialog#b-settings { width: min(640px, calc(100vw - 32px)); border: 0; border-radius: 12px; padding: 0; color: var(--garage-blue); }
.bs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.bs-grid label { display: grid; gap: 6px; font-size: 14px; color: var(--steel); font-weight: 600; }
.bs-grid input, .bs-grid select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--light-steel); background: var(--white); color: var(--garage-blue); font: inherit; }
.bs-days { border: 1px solid var(--light-steel); border-radius: 10px; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0; }
.bs-days legend { color: var(--steel); font-size: 14px; font-weight: 600; padding: 0 6px; }
.bs-days label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
#bs-form .btn { border: 0; cursor: pointer; }
#bs-form .btn:disabled { opacity: .6; cursor: wait; }
