/* اسم الخط ولونه ورابط مكتبته تُدار الآن من public/js/brandData.js (مصدر واحد للهوية البصرية) */
/* body و h1/h2/h3/.font-display تأخذ خطوطها من كلاسات Tailwind (font-body / font-display) المبنية على brandData.js */

/* ==== العنصر المميز: "خط التحقق" — شريط متدرج نيلي↔فيروزي على حافة الكروت ==== */
/* شريط "الحافة" الملوّن على بداية البطاقة — يُرسم كخلفية للبطاقة نفسها فيتبع انحناء
   الزوايا بدقة ويبقى داخل الإطار (لا يبرز خارج الحواف مهما كان نصف القطر أو سُمك الحد) */
.rail {
  position: relative;
  background-image: linear-gradient(180deg, #3730A3, #0D9488);
  background-size: 5px 100%;
  background-repeat: no-repeat;
  background-origin: padding-box;
  background-clip: padding-box;
  background-position: left top;
}
[dir="rtl"] .rail { background-position: right top; }

/* حافة "تذكرة صعود" — قطع مسنّن بدل الوسوم الدائرية القديمة */
.stub-cut {
  position: relative;
  height: 1px;
  background-image: repeating-linear-gradient(90deg, #E5E7EB 0 8px, transparent 8px 14px);
}

.otp-input {
  width: 48px; height: 56px; text-align: center; font-size: 24px; font-weight: 700;
}

.scan-flash {
  position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 40;
  transition: opacity .25s ease;
}
.scan-flash.success { background: rgba(13,148,136,0.22); }
.scan-flash.error { background: rgba(225,29,72,0.2); }
.scan-flash.show { opacity: 1; }

/* انتقال ناعم بين واجهات الـ SPA */
.view-enter { animation: viewIn .25s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 8px; }

/* ==== بطاقة الدعوة (صفحة تذكرة الضيف) — هوية داكنة خاصة بها، منفصلة عن ثيم لوحة التحكم ==== */
.pcard { background:#1e293b; width:100%; max-width:380px; border-radius:20px; overflow:hidden; box-shadow:0 20px 40px rgba(0,0,0,.5); color:#f8fafc; border:1px solid rgba(255,255,255,.1); margin:0 auto; }
.pcard-header { padding:16px 20px; background:rgba(255,255,255,.03); display:flex; justify-content:space-between; align-items:center; border-bottom:1px solid rgba(255,255,255,.08); gap:10px; }
.pcard-logo { height: 40px; width: 40px; border-radius: 10px; object-fit: contain; display: block; }
.pcard-badge { font-size:.75rem; background:rgba(56,189,248,.15); color:#38bdf8; padding:4px 10px; border-radius:20px; white-space:nowrap; }
.pcard-media { width:100%; padding:20px; display:flex; justify-content:center; align-items:center; background: radial-gradient(circle at center, rgba(56,189,248,.08) 0%, transparent 70%); }
.pcard-media .pcard-img-wrap { max-width:100%; max-height:220px; display:flex; justify-content:center; align-items:center; border-radius:12px; overflow:hidden; box-shadow:0 8px 20px rgba(0,0,0,.3); background:rgba(0,0,0,.2); }
.pcard-media img { max-width:100%; max-height:220px; width:auto; height:auto; object-fit:contain; display:block; }
.pcard-body { padding:0 20px 20px; }
.pcard-field { margin-bottom:12px; }
.pcard-field-label { font-size:.7rem; color:#94a3b8; text-transform:uppercase; margin-bottom:2px; }
.pcard-field-value { font-size:.95rem; font-weight:600; }
.pcard-field-value.large { font-size:1.3rem; color:#fff; }
.pcard-row { display:flex; justify-content:space-between; gap:12px; }
.pcard-row .pcard-field { flex:1; min-width:0; }
.pcard-map-btn { display:inline-flex; align-items:center; gap:5px; margin-top:6px; padding:5px 10px; background:rgba(56,189,248,.12); color:#38bdf8; text-decoration:none; border-radius:6px; font-size:.75rem; font-weight:600; border:1px solid rgba(56,189,248,.25); transition: background .2s ease; }
.pcard-map-btn:hover { background: rgba(56,189,248,.25); }
.pcard-divider { position:relative; height:20px; display:flex; align-items:center; }
.pcard-divider::before, .pcard-divider::after { content:''; position:absolute; width:20px; height:20px; background:#0f172a; border-radius:50%; top:0; }
.pcard-divider::before { inset-inline-start:-10px; }
.pcard-divider::after { inset-inline-end:-10px; }
.pcard-dashed { width:100%; border-bottom:2px dashed rgba(255,255,255,.1); }
.pcard-qr-zone { background:#ffffff; padding:20px; text-align:center; }
.pcard-qr-zone img { width:130px; height:130px; }
.pcard-code { font-family:monospace; color:#0f172a; font-size:.8rem; margin-top:6px; font-weight:bold; }


/* ==== محرر تصميم الكرت ==== */
@font-face {
  font-family: 'CardFont';
  src: url('/fonts/card-font.ttf') format('truetype');
  font-display: swap;
}
.cd-stage {
  background-color: #e8eaf2;
  background-image: radial-gradient(#cfd3e3 1px, transparent 1px);
  background-size: 16px 16px;
}
.cd-canvas {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
  border-radius: 6px;
  touch-action: none;
}
.cd-el {
  position: absolute;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.cd-el:active { cursor: grabbing; }
.cd-text {
  font-family: var(--cd-font, 'CardFont'), 'Times New Roman', serif;
  font-weight: 700;
  line-height: 1.25;
  width: max-content;
  white-space: normal;
  overflow-wrap: anywhere;
}
.cd-qr { box-sizing: border-box; }
.cd-qr svg { display: block; }
.cd-el.selected { outline: 2px dashed #4f46e5; outline-offset: 4px; }
.cd-el.empty { opacity: .45; font-style: italic; }
.cd-guide {
  position: absolute; top: 0; bottom: 0; left: 50%;
  border-left: 1.5px dashed #14b8a6;
  pointer-events: none; z-index: 5;
}

.cd-root { height: 100vh; height: 100dvh; }
.cd-panel { height: 44vh; height: 44dvh; }
@media (min-width: 768px) { .cd-panel { height: auto; } }
.cd-tab { border-bottom: 2px solid transparent; }
.cd-tab.active { border-bottom-color: #3730A3; background: rgba(55,48,163,.04); }
.cd-nudge {
  display: flex; align-items: center; justify-content: center;
  height: 44px; border-radius: 10px; border: 1px solid #E5E7EB; background: #fff;
  transition: border-color .15s;
}
.cd-nudge:hover { border-color: #3730A3; color: #3730A3; }
.cd-nudge:active { background: rgba(55,48,163,.08); }
#cdPanel input[type=range] { touch-action: pan-y; }

.cd-el.ghost { opacity: .3; }
.cd-qr { position: absolute; }
.cd-qr-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 34%; height: 34%; border-radius: 22%;
  background: #0D9488; color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 3px #fff;
}
.cd-switch {
  appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 999px;
  background: #D1D5DB; position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0;
}
.cd-switch::after {
  content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: inset-inline-start .2s;
}
.cd-switch:checked { background: #3730A3; }
.cd-switch:checked::after { inset-inline-start: 21px; }

.cd-qr-icon { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); line-height: 0; pointer-events: none; }
.cd-qr-icon svg { display: block; width: 100%; height: 100%; }

.cd-img { overflow: visible; }
.cd-img img { width: 100%; height: 100%; object-fit: fill; display: block; pointer-events: none; user-select: none; }
.cd-shape-svg, .cd-shape-svg svg { display: block; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.cd-el.cd-img.selected, .cd-el.cd-shape.selected { outline-offset: 2px; }
.cd-canvas.bg-selected { outline: 3px solid rgba(55,48,163,.55); outline-offset: 3px; }
.cd-canvas.drop-target { outline: 3px dashed #0D9488; outline-offset: 3px; }
.cd-none-swatch { background: linear-gradient(to top right, #fff calc(50% - 1.5px), #E11D48 calc(50% - 1.5px), #E11D48 calc(50% + 1.5px), #fff calc(50% + 1.5px)); }

/* مقابض تغيير الحجم (4 زوايا) */
.cd-resize {
  position: absolute; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid #3730A3; box-shadow: 0 1px 4px rgba(0,0,0,.3);
  touch-action: none; z-index: 3; margin: -8px;
}
.cd-resize-nw { left: 0; top: 0; cursor: nwse-resize; }
.cd-resize-ne { right: 0; top: 0; cursor: nesw-resize; }
.cd-resize-sw { left: 0; bottom: 0; cursor: nesw-resize; }
.cd-resize-se { right: 0; bottom: 0; cursor: nwse-resize; }
@media (pointer: coarse) { .cd-resize { width: 26px; height: 26px; margin: -13px; } }

/* خطوط الإرشاد المتقاطعة أثناء السحب (Crosshairs Smart Guides) */
.cd-cross { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.cd-cross-v, .cd-cross-h { position: absolute; background: rgba(236, 72, 153, .85); }
.cd-cross-v { top: 0; bottom: 0; width: 1px; transform: translateX(-.5px); }
.cd-cross-h { left: 0; right: 0; height: 1px; transform: translateY(-.5px); }
.cd-cross-v.snapped, .cd-cross-h.snapped { background: #14B8A6; box-shadow: 0 0 0 1px rgba(20,184,166,.35); }
.cd-measure {
  position: absolute; transform: translate(-50%, -50%);
  background: #EC4899; color: #fff; font: 600 10px/1 system-ui, sans-serif;
  padding: 3px 5px; border-radius: 4px; white-space: nowrap; direction: ltr;
}

/* لوحة الحضور — تبويب الجميع */
.live-row-in { background: #DCFCE7; }
.live-row-in td { color: #14532D; }
.live-row-out { background: #FEE2E2; }
.live-row-out td { color: #7F1D1D; }
.live-flash { animation: liveFlash 2.4s ease-out; }
@keyframes liveFlash { 0% { background: #86EFAC; } 100% { } }

/* دور "عرض فقط": إخفاء كل أزرار وأقسام الإدارة */
body.role-viewer .manage-only { display: none !important; }

/* صفحة الشرح على الجوال: زر اللغة أيقونة فقط حتى لا يزدحم الشريط العلوي */
@media (max-width: 420px) {
  .landing-lang .lang-btn > span:nth-child(2), .landing-lang .lang-chevron { display: none; }
  .landing-lang .lang-btn { padding-inline: 0.65rem; }
}

/* خانة فيها خطأ: إطار أحمر + الرسالة تظهر تحتها مباشرة */
.field-invalid { border-color: #E11D48 !important; box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12); }
input[type="checkbox"].field-invalid { outline: 2px solid #E11D48; outline-offset: 2px; }

/* ==== الصفحة الرئيسية: كرت الدعوة على الجوال + مربع مسح QR بخط مسح متحرك ==== */
.landing-visual {
  --phone: 300px;
  --sq: 220px;
  display: flex;
  justify-content: center;
}
/* الجوال + المربع كوحدة واحدة: المربع يبرز من جانب الجوال ويتداخل معه قليلاً */
.landing-stage {
  position: relative;
  width: var(--phone);
  margin-inline-end: calc(var(--sq) * 0.55);
}
.landing-phone {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 24px 36px rgba(16, 20, 37, 0.22));
}
.landing-scan {
  position: absolute;
  bottom: 9%;
  inset-inline-end: calc(var(--sq) * -0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.landing-visual .square {
  position: relative;
  width: var(--sq);
  height: var(--sq);
  background: #fff;
  border: 10px solid #999;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(16, 20, 37, 0.18);
}
.landing-visual .qrimage {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 78%;
  height: 78%;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
}
.landing-visual .scan {
  position: absolute;
  inset-inline: 0;
  top: 0;
  width: 100%;
  height: 8px;
  background: linear-gradient(90deg, transparent, red 18%, red 82%, transparent);
  box-shadow: 0 0 14px 3px rgba(255, 0, 0, 0.45);
  animation: scanning 1.5s linear alternate infinite;
}
@keyframes scanning {
  0% { top: 0; }
  100% { top: calc(100% - 8px); }
}
.landing-visual .scan-label {
  font-size: 12px;
  font-weight: 700;
  color: #0D9488;
  background: #fff;
  border: 1px solid #E5E7EB;
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
@media (min-width: 768px) {
  .landing-visual { --phone: 300px; --sq: 230px; }
}
@media (min-width: 1100px) {
  .landing-visual { --phone: 320px; --sq: 250px; }
}
/* شاشات الجوال: نفس التداخل بأحجام أصغر نسبةً لعرض الشاشة */
@media (max-width: 480px) {
  .landing-visual { --phone: 56vw; --sq: 40vw; }
  .landing-visual .square { border-width: 7px; border-radius: 14px; }
  .landing-visual .scan { height: 6px; }
  .landing-visual .scan-label { font-size: 10px; padding: 3px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .landing-visual .scan { animation-duration: 4s; }
}
