/* Jawhar design system - "jeweller's atelier": ink, champagne gold, ivory paper. Arabic (RTL) and English (LTR). */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Amiri:wght@400;700&family=Inter:wght@400;500;600;700&family=Playfair+Display:wght@500;600;700&display=swap');

/* Arabic display face: Sakkal Majalla where installed (Windows, Office). Its license does not allow
   serving it as a web font, so other devices fall back to Amiri, the closest free Naskh (Google Fonts).
   Majalla is drawn small, so it is scaled up to match. */
@font-face { font-family: 'Majalla'; font-weight: 400 500; src: local('Sakkal Majalla'), local('SakkalMajalla'), local('Sakkal Majalla Regular'); size-adjust: 128%; }
@font-face { font-family: 'Majalla'; font-weight: 600 800; src: local('Sakkal Majalla Bold'), local('SakkalMajalla-Bold'), local('SakkalMajallaBold'); size-adjust: 128%; }

:root {
  --ink: #15110e;
  --ink-2: #221c17;
  --ink-3: #3a3029;
  --gold: #c9a46a;
  --gold-deep: #9a7b4f;
  --gold-soft: #ead9b8;
  --ivory: #faf6ef;
  --paper: #fffdf9;
  --sand: #f1e9dc;
  --line: #e6dccb;
  --text: #2a2420;
  --muted: #7d7166;
  --ok: #3f7d5c;
  --ok-bg: #e6f2ea;
  --warn: #a8661b;
  --warn-bg: #fbefdd;
  --bad: #a6402f;
  --bad-bg: #f8e4df;
  --info-bg: #ece8f5;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(21, 17, 14, .06), 0 8px 28px -12px rgba(21, 17, 14, .18);
  --shadow-lg: 0 30px 80px -30px rgba(21, 17, 14, .45);
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --display: 'Majalla', 'Amiri', 'IBM Plex Sans Arabic', serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* English UI: Inter for text, Playfair Display for headings (Arabic words inside fall back to the Arabic faces). */
html[lang='en'] {
  --font: 'Inter', 'IBM Plex Sans Arabic', 'Segoe UI', system-ui, sans-serif;
  --display: 'Playfair Display', 'Majalla', 'Amiri', Georgia, serif;
}
/* Set by lang.js until the English text is swapped in (failsafe: show anyway after 1.5s). */
html.i18n-wait body { visibility: hidden; animation: i18nShow 0s 1.5s forwards; }
@keyframes i18nShow { to { visibility: visible; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.7; color: var(--text);
  background: var(--ivory); -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--gold-deep); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.3; margin: 0 0 .5em; letter-spacing: 0; }
p { margin: 0 0 1em; }
::selection { background: var(--gold-soft); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.grain { position: relative; isolation: isolate; }
.grain::after {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- brand */
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 22px; font-weight: 600; color: inherit; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.brand small { font-family: var(--font); font-size: 11px; letter-spacing: .25em; color: var(--gold); font-weight: 500; }
/* Top navbar brand: Jawhar's face + the gold name pill - each language shows its own name */
.brand-jw { gap: 10px; }
.brand-jw .brand-face { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px rgba(201,164,106,.6); }
.brand-jw .brand-name { width: auto; height: 44px; }
html[lang="en"] .brand-jw .brand-name.ar, html:not([lang="en"]) .brand-jw .brand-name.en { display: none; }
.brand-jw.brand-sm .brand-face { width: 34px; height: 34px; }
.brand-jw.brand-sm .brand-name { height: 34px; }
@media (max-width: 520px) { .brand-jw { gap: 7px; } .brand-jw .brand-face, .brand-jw .brand-name { height: 32px; } .brand-jw .brand-face { width: 32px; } }

/* ---------------------------------------------------------------- buttons */
.btn {
  --b: var(--ink); --c: var(--ivory);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--b);
  background: var(--b); color: var(--c); font: 500 14.5px/1 var(--font); cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s, opacity .2s; white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 20px -10px rgba(21, 17, 14, .5); }
.btn:active { transform: translateY(0); }
.btn[disabled], .btn.loading { opacity: .55; pointer-events: none; }
.btn.loading::before { content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-gold { --b: var(--gold); --c: var(--ink); }
.btn-ghost { --b: transparent; --c: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--sand); }
.btn-danger { --b: transparent; --c: var(--bad); border-color: #e7c4bc; }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 13px; }
.btn-lg { min-height: 52px; padding: 0 28px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--sand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .label { font-weight: 500; font-size: 14px; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--paper); color: var(--text); font: 400 15px/1.5 var(--font); transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201, 164, 106, .18); }
.input[dir='ltr'] { text-align: left; }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); overflow: hidden; }
.input-group:focus-within { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201, 164, 106, .18); }
.input-group .input { border: 0; box-shadow: none !important; }
.input-group .addon { display: grid; place-items: center; padding: 0 12px; background: var(--sand); color: var(--muted); font-size: 13px; direction: ltr; white-space: nowrap; }
.form-error { color: var(--bad); font-size: 13.5px; min-height: 1.4em; margin: 4px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: 14px; transition: all .15s; }
.chip input:checked + span { background: var(--ink); color: var(--ivory); border-color: var(--ink); }
.chip input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
/* phone with country code (phone.js) */
.phone-in { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); overflow: hidden; }
.phone-in:focus-within { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201, 164, 106, .18); }
.phone-in .cc { position: relative; display: grid; place-items: center; padding: 0 12px; background: var(--sand); border-inline-end: 1px solid var(--line); min-width: 96px; }
.phone-in .cc-show { font: 500 14.5px/1 'Inter', var(--font); white-space: nowrap; }
.phone-in .cc::after { content: '▾'; font-size: 10px; color: var(--muted); margin-inline-start: 6px; position: absolute; inset-inline-end: 6px; }
.phone-in select { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 15px; width: 100%; }
.phone-in .input { border: 0; box-shadow: none !important; direction: ltr; text-align: left; letter-spacing: .02em; }
.lang-btn { font: 500 13px/1 var(--font); }
html[lang='en'] .lang-btn, .lang-btn:lang(ar) { font-family: 'IBM Plex Sans Arabic', sans-serif; }
.row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------------------------------------------------------------- surfaces */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card h3 { font-size: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--sand); color: var(--ink-3); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.gold { background: #f6ecd9; color: var(--gold-deep); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 54px; height: 54px; margin: 0 auto 12px; opacity: .5; }
.empty h4 { color: var(--text); font-size: 17px; }
.divider { height: 1px; background: var(--line); margin: 22px 0; border: 0; }

.table-wrap { overflow-x: auto; margin: 0 -22px; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 22px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 22px; border-bottom: 1px solid #f0e9dd; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #fcf8f1; }

/* ---------------------------------------------------------------- toast & modal */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { padding: 12px 18px; border-radius: 12px; background: var(--ink); color: var(--ivory); box-shadow: var(--shadow-lg); animation: rise .3s var(--ease); font-size: 14px; }
.toast.bad { background: var(--bad); }
.toast.ok { border-inline-start: 4px solid var(--gold); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(21, 17, 14, .45); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 90; padding: 16px; animation: fade .2s; }
.modal { background: var(--paper); border-radius: 18px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 26px; box-shadow: var(--shadow-lg); animation: rise .25s var(--ease); }
.modal h3 { font-size: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 18px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

.skeleton { background: linear-gradient(90deg, var(--sand) 25%, #f7f1e6 50%, var(--sand) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; min-height: 18px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
