/* =====================================================================
   al3jman.com — الواجهة العامة (المرحلة الثالثة)
   الألوان والخطوط تأتي من إعدادات الهوية في لوحة التحكم (brand.theme)
   ===================================================================== */
:root {
  --bg: #0A1426;
  --surface: #111E36;
  --surface-2: #0d1930;
  --line: #22314f;
  --accent: #B8975A;
  --accent-soft: #D4BC8A;
  --text: #EDE6D6;
  --muted: #9aa6bd;
  --danger: #d0605e;
  --ok: #3fa37a;
  --mourn: #9aa3b2;
  --font: "Cairo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Amiri", "Cairo", serif;
  --radius: 16px;
  --top-h: 64px;
  --bar-h: 74px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F6F2E9;
  --surface: #FFFFFF;
  --surface-2: #FBF8F2;
  --line: #E4DACA;
  --accent: #9A7A3E;
  --accent-soft: #7d6230;
  --text: #1C2436;
  --muted: #6B7180;
  --mourn: #6b7280;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 17px; line-height: 1.7; min-height: 100dvh; -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- الشعار ---------- */
.flag-dot { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; display: inline-block; flex: none; box-shadow: 0 0 0 1.5px var(--accent); }
.flag-dot svg { width: 100%; height: 100%; display: block; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 30px; color: var(--accent-soft); line-height: 1; }

/* ---------- الشريط العلوي ---------- */
.top {
  position: sticky; top: 0; z-index: 30; height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 10px 0; display: grid; grid-template-columns: 52px 1fr 52px; align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top .brand { justify-self: center; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 14px; border: 0; background: transparent; display: grid; place-items: center;
  position: relative; color: var(--text);
}
.icon-btn:active { background: var(--surface); }
.icon-btn svg { width: 26px; height: 26px; }
.dot-badge {
  position: absolute; top: 5px; inset-inline-start: 5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; line-height: 1;
}

/* ---------- الشريط السفلي ---------- */
.bar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 30; height: calc(var(--bar-h) + env(safe-area-inset-bottom));
  padding: 6px 6px env(safe-area-inset-bottom); display: flex; justify-content: space-around; align-items: stretch;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.bar a {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 12.5px; font-weight: 600; border-radius: 14px;
}
.bar a .ic { font-size: 23px; line-height: 1; }
.bar a.on { color: var(--accent-soft); }
.bar a.hi .ic {
  width: 58px; height: 58px; margin-top: -26px; border-radius: 50%; background: var(--accent); color: #0A1426;
  display: grid; place-items: center; font-size: 28px; box-shadow: 0 6px 18px rgba(0,0,0,.35), 0 0 0 4px var(--bg);
}
.bar a.hi { color: var(--accent-soft); }

/* ---------- القائمة الجانبية ---------- */
.scrim { position: fixed; inset: 0; background: rgba(3,8,18,.6); z-index: 40; animation: fade .15s; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(330px, 86vw); z-index: 41;
  background: var(--surface); border-inline-end: 1px solid var(--line); overflow: auto;
  padding: calc(18px + env(safe-area-inset-top)) 14px 24px; animation: slide .2s ease-out;
}
@keyframes slide { from { transform: translateX(100%); } }
:root[dir=ltr] .drawer { animation-name: slide-l; }
@keyframes slide-l { from { transform: translateX(-100%); } }
@keyframes fade { from { opacity: 0; } }
.drawer .plaque { margin-bottom: 14px; }
.drawer-x { display: block; margin: -6px 0 6px auto; font-size: 20px; background: var(--surface-2); border: 1px solid var(--line); }
.drawer nav a {
  display: flex; align-items: center; gap: 12px; padding: 13px 12px; border-radius: 12px; text-decoration: none;
  font-weight: 600; font-size: 17px;
}
.drawer nav a .ic { width: 28px; text-align: center; font-size: 21px; }
.drawer nav a.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-soft); }
.drawer nav a.sub { padding-inline-start: 52px; font-size: 15px; color: var(--muted); }
.drawer hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.theme-row { display: flex; gap: 6px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.theme-row button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 4px; font-weight: 600; font-size: 14px; color: var(--muted); }
.theme-row button.on { background: var(--accent); color: #0A1426; }

/* ---------- اللوحة (الشعار الكبير) ---------- */
.plaque {
  text-align: center; padding: 18px 12px 16px; border-radius: 20px; position: relative;
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%), var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
}
.plaque .name { font-family: var(--font-head); font-size: 50px; font-weight: 700; color: var(--accent-soft); line-height: 1.15; }
.plaque .sub { color: var(--muted); font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ---------- المحتوى ---------- */
main { max-width: 760px; margin: 0 auto; padding: 14px 14px 30px; }
.today { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 16px 2px 8px; }
.today b { font-size: 18px; }
.today span { color: var(--muted); font-size: 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 22px; padding: 8px 16px;
  font-weight: 600; font-size: 15px; min-height: 42px;
}
.chips button.on { background: var(--accent); color: #0A1426; border-color: transparent; }
.day-h { display: flex; align-items: center; gap: 10px; margin: 18px 4px 8px; font-weight: 700; font-size: 16px; color: var(--accent-soft); }
.day-h::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.day-h small { color: var(--muted); font-weight: 400; font-size: 13px; }

.ev {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: start; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  border-inline-start: 4px solid var(--type, var(--accent));
}
.ev:active { transform: scale(.99); }
.ev .ico { font-size: 28px; line-height: 1.2; width: 36px; text-align: center; flex: none; }
.ev .b { flex: 1; min-width: 0; }
.ev .k { font-size: 13px; font-weight: 700; color: var(--type, var(--accent-soft)); }
.ev .t { font-weight: 700; font-size: 18px; line-height: 1.45; overflow-wrap: anywhere; }
.ev .h { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.ev .m { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14.5px; margin-top: 4px; }
.ev .m span { display: inline-flex; gap: 5px; align-items: center; }
.ev.mourn { --type: var(--mourn); }
.tag { display: inline-block; font-size: 12px; padding: 0 9px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-soft); font-weight: 700; margin-inline-start: 6px; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 44px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 12px 18px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 16px;
  text-decoration: none; color: var(--text);
}
.btn.gold { background: var(--accent); color: #0A1426; border-color: transparent; }
.btn.wa { background: #1f8f4e; color: #fff; border-color: transparent; }
.btn.block { width: 100%; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.btns .full { grid-column: 1 / -1; }

/* ---------- صفحة المناسبة ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted); font-weight: 600; padding: 6px 2px; margin-bottom: 6px; }
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 20px 18px; border-top: 5px solid var(--type, var(--accent)); }
.detail.mourn { --type: var(--mourn); }
.detail .k { font-weight: 700; color: var(--type, var(--accent-soft)); font-size: 15px; }
.detail h1 { font-family: var(--font-head); font-size: 32px; line-height: 1.35; margin: 4px 0 2px; overflow-wrap: anywhere; }
.detail .host { color: var(--muted); font-size: 16px; }
.facts { margin: 16px 0 4px; display: grid; gap: 10px; }
.fact { display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.fact .i { font-size: 22px; width: 28px; text-align: center; flex: none; }
.fact b { display: block; font-size: 17px; }
.fact small { color: var(--muted); font-size: 14px; display: block; }
.invite { width: 100%; border-radius: 14px; border: 1px solid var(--line); margin-top: 12px; display: block; }
.desc { white-space: pre-wrap; margin-top: 12px; color: var(--text); }
.mourn-note { text-align: center; color: var(--mourn); font-family: var(--font-head); font-size: 20px; margin: 4px 0 10px; }

/* ---------- عام ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card h2 { margin: 0 0 6px; font-size: 19px; }
.page-title { font-family: var(--font-head); font-size: 30px; margin: 10px 2px 12px; color: var(--accent-soft); }
.notif { display: block; text-decoration: none; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif:last-child { border-bottom: 0; }
.notif .t { font-weight: 700; }
.notif .s { color: var(--muted); font-size: 14px; }
.notif.new { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.social { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 26px; }
.offline { background: #3a2a10; color: #f1d9a3; text-align: center; font-size: 14px; padding: 6px; }
.skel { height: 96px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 10px; border: 1px solid var(--line); }
@keyframes sk { to { background-position: -200% 0; } }
#toast { position: fixed; bottom: calc(var(--bar-h) + 16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.35); max-width: 90vw; }

/* ---------- الشاشات الكبيرة ---------- */
@media (min-width: 900px) {
  .bar { max-width: 640px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0; }
  .events-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
  .top { padding-inline: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* =====================================================================
   المرحلة الرابعة: النماذج والخدمات
   ===================================================================== */
.center { text-align: center; }
.small { font-size: 14px; }
.row-b { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.btn.sm { min-height: 40px; padding: 6px 14px; font-size: 14px; }
.btn.big-btn { min-height: 58px; font-size: 18px; }
.btn.danger-t { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: transparent; }
.btn:disabled { opacity: .6; }
.alert { border-radius: 12px; padding: 10px 14px; margin: 10px 0; font-size: 15px; }
.alert.err { background: #3a1716; border: 1px solid #6b2b29; color: #f3c2c0; }
.alert.warn { background: #3a2a10; border: 1px solid #6b5020; color: #f1d9a3; }
.alert.ok { background: #13322a; border: 1px solid #275f4b; color: #b8ead4; }
:root[data-theme="light"] .alert.err { background: #fdecec; color: #8a1f1d; border-color: #f2c4c3; }
:root[data-theme="light"] .alert.warn { background: #fff5e0; color: #7a5410; border-color: #f0dba8; }
:root[data-theme="light"] .alert.ok { background: #e8f6ef; color: #1c5e40; border-color: #bfe3d0; }
.pill { font-size: 13px; padding: 2px 10px; border-radius: 12px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { color: #3fa37a; border-color: #3fa37a; } .pill.warn { color: #d9a441; border-color: #d9a441; }
.pill.info { color: var(--accent-soft); border-color: var(--accent); } .pill.err { color: var(--danger); border-color: var(--danger); }

.form .card { padding: 14px 14px 6px; }
.f { display: block; margin: 0 0 12px; }
.f > span { display: block; font-size: 15px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.form input:not([type=checkbox]):not([type=radio]):not([type=file]), .form select, .form textarea, .filters input, .filters select {
  width: 100%; min-height: 52px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 17px; outline: none;
}
.form textarea { min-height: 96px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus, .filters input:focus, .filters select:focus { border-color: var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chk { display: flex; align-items: center; gap: 10px; margin: -2px 0 12px; font-weight: 600; }
.chk input { width: 22px; height: 22px; accent-color: var(--accent); }
.pick-h { font-weight: 700; margin: 4px 0 8px; }
.who { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 2px; margin: 0 0 12px; background: var(--surface); }
.who legend { padding: 0 6px; color: var(--accent-soft); font-weight: 700; }
.types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.type-opt input, .seg input, .days input { position: absolute; opacity: 0; pointer-events: none; }
.type-opt span { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface-2); font-size: 26px; cursor: pointer; }
.type-opt b { font-size: 15px; }
.type-opt input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.type-opt input:focus-visible + span, .seg input:focus-visible + span, .days input:focus-visible + span { outline: 2px solid var(--accent); }
.seg { display: flex; gap: 6px; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 12px; }
.seg label { flex: 1; }
.seg span { display: block; text-align: center; padding: 10px 6px; border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 15px; }
.seg input:checked + span { background: var(--accent); color: #0A1426; }
.days { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.days span { display: inline-block; padding: 9px 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-weight: 600; font-size: 15px; }
.days input:checked + span { background: var(--accent); color: #0A1426; border-color: transparent; }
.upload { display: block; border: 2px dashed color-mix(in srgb, var(--accent) 55%, var(--line)); border-radius: 14px; padding: 18px; text-align: center; font-weight: 700; cursor: pointer; margin-bottom: 10px; color: var(--accent-soft); }
.done-card { text-align: center; padding: 28px 18px; }
.done-card .big { font-size: 52px; }
.done-card h2 { font-family: var(--font-head); font-size: 26px; }
.mine .btn { margin-top: 8px; width: 100%; }
.steps { padding-inline-start: 22px; } .steps li { margin: 6px 0; }

.filters { display: grid; gap: 10px; }
.filters .chips { padding-bottom: 2px; }
.dw-h { display: flex; gap: 12px; align-items: flex-start; }
.dw-h .ico { font-size: 28px; }
.dw-h b { font-size: 18px; }
.facts-s { display: grid; gap: 4px; margin: 10px 0 0; font-size: 15px; }
.dw .btns { margin-bottom: 0; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }

.svc { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.svc-i { text-decoration: none; display: flex; flex-direction: column; gap: 2px; margin: 0; min-height: 120px; }
.svc-i .ic { font-size: 30px; } .svc-i b { font-size: 17px; } .svc-i small { color: var(--muted); font-size: 13px; }

.cal { padding: 12px 8px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 8px; font-size: 18px; }
.cal-nav .icon-btn { font-size: 26px; }
.cal-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-wd span { text-align: center; font-size: 11px; white-space: nowrap; overflow: hidden; color: var(--muted); padding: 4px 0; }
.cal-d { border: 0; background: transparent; border-radius: 10px; min-height: 58px; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.cal-d b { font-size: 16px; } .cal-d small { font-size: 10px; color: var(--muted); }
.cal-d i { display: flex; gap: 2px; min-height: 7px; } .cal-d em { width: 6px; height: 6px; border-radius: 50%; display: block; }
.cal-d.today b { color: var(--accent-soft); text-decoration: underline; text-underline-offset: 3px; }
.cal-d.sel { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.cal-d.past { opacity: .55; }

.pt-next { text-align: center; }
.pt-big { font-family: var(--font-head); font-size: 34px; color: var(--accent-soft); }
.pt-big span { font-family: var(--font); font-size: 26px; color: var(--text); }
.pt-row { display: flex; justify-content: space-between; padding: 12px 6px; border-bottom: 1px solid var(--line); font-size: 18px; }
.pt-row:last-of-type { border-bottom: 0; }
.pt-row.on { color: var(--accent-soft); font-weight: 700; }
.compass { display: grid; place-items: center; padding: 10px 0; }
.dial { width: 220px; height: 220px; border-radius: 50%; border: 3px solid var(--accent); position: relative; transition: transform .15s linear;
  background: radial-gradient(circle, var(--surface-2) 60%, color-mix(in srgb, var(--accent) 12%, var(--surface)) 100%); }
.dial .n { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); font-weight: 700; color: var(--danger); }
.needle { position: absolute; inset: 0; transition: transform .15s linear; }
.needle i { position: absolute; left: 50%; top: 18px; width: 0; height: 0; transform: translateX(-50%);
  border-left: 14px solid transparent; border-right: 14px solid transparent; border-bottom: 92px solid var(--accent); }
.needle i::after { content: "🕋"; position: absolute; top: -34px; left: -12px; font-size: 22px; }

/* شاشة العرض */
body.kiosk { padding: 0; overflow: hidden; }
.k { height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; padding: 2.2vh 3vw; gap: 2vh; position: relative; }
.k-top { display: flex; justify-content: space-between; align-items: center; }
.k-clock { font-size: clamp(40px, 9vh, 110px); font-weight: 700; line-height: 1; }
.k-date { color: var(--muted); font-size: clamp(16px, 2.6vh, 30px); }
.k-brand { display: flex; align-items: center; gap: 12px; } .k-brand .brand-name { font-size: clamp(40px, 8vh, 96px); }
.k-brand .flag-dot { width: 6vh; height: 6vh; }
.k-body { overflow: hidden; }
.k-h { font-family: var(--font-head); color: var(--accent-soft); font-size: clamp(24px, 4vh, 48px); margin: 1vh 0; }
.k-ev { display: flex; gap: 2vw; align-items: center; background: var(--surface); border: 1px solid var(--line); border-inline-start: 6px solid var(--accent); border-radius: 18px; padding: 1.6vh 2vw; margin-bottom: 1.4vh; }
.k-ev.mourn { border-inline-start-color: var(--mourn); }
.k-ev .ic { font-size: clamp(30px, 5vh, 60px); }
.k-t { font-size: clamp(20px, 3.6vh, 44px); font-weight: 700; }
.k-s { color: var(--muted); font-size: clamp(16px, 2.6vh, 30px); }
.k-empty { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 4vh; }
.k-pt { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1vw; }
.k-pt div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-align: center; padding: 1.2vh 0; }
.k-pt span { display: block; color: var(--muted); font-size: clamp(14px, 2.2vh, 26px); } .k-pt b { font-size: clamp(18px, 3.2vh, 38px); }
.k-pt .on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.k-fs { position: absolute; bottom: 1vh; left: 1vw; opacity: .25; background: none; border: 0; font-size: 22px; color: var(--muted); }
@media (max-width: 380px) { .types { grid-template-columns: repeat(2, 1fr); } .two { grid-template-columns: 1fr; } }
