/* ============================================================
   دواتيك — نظام التصميم
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700;800&family=Amiri:wght@400;700&display=swap');

:root {
  --navy:       #0F172A;
  --navy-soft:  #1E293B;
  --page:       #F8FAFC;
  --card:       #FFFFFF;
  --ink:        #0F172A;
  --ink-soft:   #475569;
  --ink-faint:  #94A3B8;
  --line:       #E2E8F0;
  --indigo:     #4F46E5;
  --indigo-bg:  #EEF2FF;
  --amber:      #E07B0C;
  --amber-bg:   #FEF3E2;
  --rose:       #E11D48;
  --rose-bg:    #FFF1F3;
  --beige:      #7c6a52;
  --beige-dark: #5c4e3b;
  --beige-bg:   #f5f0e8;
  --gold:       #C9A227;
  --accent:     var(--beige);
  --accent-bg:  var(--beige-bg);
  --w:     min(100% - 2rem, 42rem);
  --r:     14px;
  --font:  'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-card: 'Amiri', 'Times New Roman', serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--beige); outline-offset: 2px; }
.wrap { width: var(--w); margin-inline: auto; }

/* ── الهيدر ───────────────────────────────────────────── */
.site-header {
  background: var(--navy);
  color: #fff;
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.site-header .brand {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: -.02em;
}
.site-header nav a {
  color: #94A3B8;
  font-size: .85rem;
  font-weight: 600;
  margin-inline-start: 1rem;
  transition: color .15s;
}
.site-header nav a:hover { color: #fff; }

/* ── الهيرو ───────────────────────────────────────────── */
.hero {
  background: linear-gradient(160deg, var(--navy) 0%, #1a2744 100%);
  color: #fff;
  text-align: center;
  padding: 2.5rem 1rem 5rem;
  position: relative;
}
.hero h1 {
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  font-weight: 800;
  margin-bottom: .5rem;
  line-height: 1.3;
}
.hero p { color: #CBD5E1; font-size: .95rem; margin-bottom: 0; }

/* ── اختيار النوع — بطاقات ────────────────────────────── */
.type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  margin: -2.5rem auto 2rem;
  width: var(--w);
  position: relative;
  z-index: 10;
}
.type-card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--r);
  padding: 1.1rem .75rem;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  transition: all .2s;
  box-shadow: 0 4px 16px rgba(15,23,42,.07);
}
.type-card .tc-icon { font-size: 1.8rem; display: block; margin-bottom: .35rem; }
.type-card .tc-label { font-size: .88rem; font-weight: 700; display: block; }
.type-card .tc-sub { font-size: .72rem; color: var(--ink-faint); display: block; margin-top: .15rem; }
.type-card:hover, .type-card.active {
  border-color: var(--beige);
  background: var(--beige-bg);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(124,106,82,.15);
}
.type-card.active .tc-label { color: var(--beige-dark); }

/* ── Segmented nav ─────────────────────────────────────── */
.seg {
  display: flex;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .25rem;
  gap: .2rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg a {
  white-space: nowrap;
  font-size: .88rem;
  font-weight: 600;
  padding: .45rem 1rem;
  border-radius: 999px;
  color: var(--ink-soft);
  transition: all .15s;
}
.seg a.on { background: var(--beige); color: #fff; }
.seg a:not(.on):hover { background: #fff; }

/* ── النموذج ──────────────────────────────────────────── */
.form-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.form-wrap h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: .35rem;
}
.field label .note { font-weight: 400; color: var(--ink-faint); }
.field input[type=text],
.field input[type=tel],
.field input[type=date],
.field select,
.field textarea {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-family: var(--font);
  font-size: .93rem;
  color: var(--ink);
  background: var(--page);
  transition: border-color .15s, background .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--beige);
  background: #fff;
}

/* group حقول مجمّعة */
.group {
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.group h4 {
  font-size: .88rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: .75rem;
}
.group input {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  font-family: var(--font);
  font-size: .9rem;
  background: #fff;
  margin-bottom: .5rem;
  transition: border-color .15s;
}
.group input:focus { outline: none; border-color: var(--beige); }
.group input:last-of-type { margin-bottom: 0; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 480px) { .row2 { grid-template-columns: 1fr; } }

/* زر إضافة */
.addbtn, .addbtn-college {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  color: var(--beige);
  background: transparent;
  border: 1.5px dashed var(--beige);
  border-radius: 8px;
  padding: .4rem .85rem;
  cursor: pointer;
  margin-top: .5rem;
  transition: all .15s;
}
.addbtn:hover, .addbtn-college:hover { background: var(--beige-bg); }

/* ── معاينة البطاقة ────────────────────────────────────── */
.preview-section {
  position: sticky;
  top: 60px;
}
.preview-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-faint);
  text-align: center;
  margin-bottom: .5rem;
}

/* card-shell: نسبة 9:16 بدون overflow-x */
.card-shell {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  margin-inline: auto;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(15,23,42,.18);
  position: relative;
  background: #FDFBF3;
}

/* stage: 1080×1920, مُصغَّر ليناسب card-shell */
#stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 1080px;
  height: 1920px;
  transform-origin: top left;
  /* transform يُضبط بـ JS */
}

/* ── البطاقة الداخلية (مطابق للملف المرفق) ─────────────── */
.inv {
  width: 1080px;
  height: 1920px;
  background: #FDFBF3;
  font-family: var(--font-card);
  color: #1B2333;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding: 160px 120px 110px;
  position: absolute;
  top: 0; left: 0;
}
.inv .inv-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
}
/* الزوايا */
.inv .cor { position: absolute; width: 170px; height: 170px; border: 12px solid var(--navy); }
.inv .cor.c1 { top: 60px;    right: 60px; border-left: 0;  border-bottom: 0; border-top-right-radius: 34px; }
.inv .cor.c2 { top: 60px;    left: 60px;  border-right: 0; border-bottom: 0; border-top-left-radius: 34px; }
.inv .cor.c3 { bottom: 60px; right: 60px; border-left: 0;  border-top: 0;    border-bottom-right-radius: 34px; }
.inv .cor.c4 { bottom: 60px; left: 60px;  border-right: 0; border-top: 0;    border-bottom-left-radius: 34px; }

/* العنوان والنصوص */
.inv .ttl  { font-size: 86px; font-weight: 700; line-height: 1.3; margin-bottom: 20px; overflow-wrap: anywhere; }
.inv .sub  { font-size: 50px; color: #8A8F9C; margin-bottom: 40px; }
.inv .ln   { font-size: 72px; line-height: 1.6; overflow-wrap: anywhere; margin-bottom: 10px; }
.inv .ln:last-child { margin-bottom: 0; }

/* الشريط الفاصل الذهبي */
.inv .rule {
  display: flex; align-items: center; gap: 26px; width: 100%; margin: 40px 0;
}
.inv .rule::before, .inv .rule::after {
  content: ''; flex: 1; height: 3px; background: #E3D6A8;
}
.inv .rule span { font-size: 46px; font-weight: 700; color: #000; white-space: normal; text-align: center; line-height: 1.45; }

/* أسماء المعاريس */
.inv .gr-wrap { width: 100%; }
.inv .gr-box {
  background: linear-gradient(135deg, #fdf5dc, #fef9e7);
  border: 3px solid #E3D6A8;
  border-radius: 18px;
  padding: 28px 48px;
  font-size: 76px;
  font-weight: 800;
  color: #1B2333;
  line-height: 1.35;
  overflow-wrap: anywhere;
  margin-bottom: 16px;
}
.inv .gr-box--multi { font-size: 64px; padding: 20px 36px; }
.inv .amp-and { font-size: 52px; color: var(--gold); margin: 6px 0; }

/* الوقت والتاريخ */
.inv .when { font-size: 50px; color: #000; margin: 34px 0 24px; }
.inv .when b { color: var(--gold); font-weight: 700; }
.inv .datepill {
  display: inline-flex; align-items: center; gap: 30px;
  background: var(--navy); color: #fff;
  border-radius: 999px; padding: 22px 56px;
  font-size: 50px; font-weight: 700; letter-spacing: 3px; margin-bottom: 32px;
}
.inv .datepill svg { color: var(--gold); flex: 0 0 auto; }
.inv .datepill i   { width: 10px; height: 50px; background: rgba(255,255,255,.28); }

/* المكان */
.inv .venue {
  display: inline-flex; align-items: center; gap: 16px;
  font-size: 44px; font-weight: 700; margin-bottom: 28px;
}
.inv .venue svg { color: var(--gold); }

/* الخاتمة */
.inv .bless   { font-size: 40px; color: #000; }
.inv .sep     { width: 55%; height: 2px; background: #000; margin: 26px 0 22px; }
.inv .apology { font-size: 34px; color: #000; }

/* أسماء save_date */
.inv .nmbox {
  background: linear-gradient(135deg,#fdf5dc,#fef9e7);
  border: 3px solid #E3D6A8; border-radius: 18px;
  padding: 28px 56px; font-size: 76px; font-weight: 800;
  color: #1B2333; line-height: 1.3; overflow-wrap: anywhere; margin-bottom: 24px;
}
.inv .note { font-size: 44px; color: #8A8F9C; line-height: 1.6; margin-bottom: 40px; }

/* دعوة عشاء */
.inv.dinner { padding: 140px 120px; }
.inv.dinner .ttl { font-size: 80px; margin-bottom: 28px; }
.inv.dinner .sub { font-size: 60px; margin-bottom: 36px; }
.inv.dinner .rule { margin: 48px 0; }
.din-honor-wrap {
  display: flex; flex-direction: column; align-items: center;
  background: #F8F5EE; border: 3px solid #E3D6A8;
  border-radius: 32px; padding: 56px 48px 48px; margin: 0 0 10px;
}
.din-honor-name { font-size: 76px; font-weight: 800; color: #1B2333; line-height: 1.35; text-align: center; overflow-wrap: anywhere; }
.din-honor-college { font-size: 44px; color: var(--beige); margin-top: 14px; font-weight: 600; }
.din-honor-multi { width: 100%; margin: 0 0 10px; }
.din-honor-name--multi { display: block; text-align: center; overflow-wrap: anywhere; }
.din-honor-sep { font-size: 48px; color: #E3D6A8; margin: 4px 0; }
.din-honor-sub { font-size: 60px; }

/* بطاقة العزاء */
.inv.mourn { background: #1a1a2e; color: #e8e8e8; }
.inv.mourn .ttl { color: #fff; }
.inv.mourn .rule::before, .inv.mourn .rule::after { background: #555; }
.inv.mourn .cor { border-color: #555; }

/* العلامة التجارية في أسفل البطاقة */
.card-brand {
  width: 100%; border-top: 2px solid #E3D6A8; padding-top: 28px; margin-top: 16px;
  border-collapse: collapse;
}
.card-brand-cell-text { text-align: right; padding-right: 24px; }
.card-brand-cell-qr   { text-align: left;  padding-left: 24px; width: 120px; }
.card-brand-name { font-size: 38px; font-weight: 700; color: var(--navy); }
.card-brand-sub  { font-size: 30px; color: #8A8F9C; }
.card-brand-qr   { width: 120px; height: 120px; }
.card-brand-qr svg { width: 100% !important; height: 100% !important; }

/* ── Layout بنائي ──────────────────────────────────────── */
.builder-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
  margin-top: 1.5rem;
}
@media (max-width: 860px) {
  .builder-layout { grid-template-columns: 1fr; }
  .preview-section { position: static; order: -1; }
  .card-shell { max-width: 240px; }
}

/* ── الأزرار ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-family: var(--font); font-size: .93rem; font-weight: 700;
  padding: .7rem 1.35rem; border: none; border-radius: 999px;
  background: #fff; color: var(--ink); cursor: pointer;
  transition: transform .12s, filter .15s; text-decoration: none;
}
.btn:hover  { filter: brightness(.94); }
.btn:active { transform: scale(.97); }
.btn-dark   { background: var(--navy); color: #fff; }
.btn-gold   { background: var(--gold); color: #fff; }
.btn-ghost  { background: transparent; border: 1.5px solid var(--line); color: var(--ink-soft); }
.btn-block  { width: 100%; }
.btn-sm     { padding: .4rem .8rem; font-size: .82rem; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Alert ─────────────────────────────────────────────── */
.alert { padding: .85rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600; font-size: .9rem; }
.alert.success { background: #d1e7dd; color: #0f5132; }
.alert.error   { background: #f8d7da; color: #842029; }
.alert.info    { background: #cff4fc; color: #055160; }

/* ── صفحة الشكر ───────────────────────────────────────── */
.thanks-box {
  max-width: 480px; margin: 3rem auto; text-align: center;
  background: #fff; border-radius: 20px; padding: 2.5rem;
  box-shadow: 0 4px 24px rgba(15,23,42,.08);
}
.thanks-icon { font-size: 4rem; margin-bottom: 1rem; }
.thanks-ref  { font-size: 1.4rem; font-weight: 900; color: var(--gold); margin: .5rem 0; }
.thanks-meta { font-size: .88rem; color: var(--ink-soft); line-height: 1.8; }

/* ── مودال معاينة كاملة ───────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.75); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-card-wrap {
  width: 90vmin; max-width: 360px;
  aspect-ratio: 9/16; border-radius: 16px;
  overflow: hidden; position: relative; background: #FDFBF3;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-close {
  position: absolute; top: 1rem; left: 1rem;
  background: rgba(0,0,0,.5); color: #fff; border: none;
  border-radius: 50%; width: 36px; height: 36px; font-size: 1.1rem;
  cursor: pointer; z-index: 10; display: flex; align-items: center; justify-content: center;
}

/* ── شريط الإجراءات السفلي (جوال) ─────────────────────── */
.action-bar {
  position: sticky; bottom: 0;
  background: #fff; border-top: 1px solid var(--line);
  padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
  display: flex; gap: .5rem; z-index: 50;
}
.action-bar .btn { flex: 1; font-size: .9rem; }

/* ── لوحة التحكم ──────────────────────────────────────── */
.admin-header {
  background: var(--navy); color: #fff;
  padding: .85rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
}
.admin-header .brand { color: var(--gold); font-weight: 800; font-size: 1.05rem; }
.admin-header nav a { color: #94A3B8; font-size: .85rem; margin-inline-start: 1rem; }
.admin-header nav a:hover { color: #fff; }

.admin-wrap { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: .75rem; margin-bottom: 1.5rem; }
.stat  { background: #fff; border-radius: var(--r); padding: 1rem; text-align: center; border: 1px solid var(--line); }
.stat .n { font-size: 1.8rem; font-weight: 900; color: var(--navy); }
.stat .l { font-size: .75rem; color: var(--ink-faint); }
@media (max-width: 600px) { .stats { grid-template-columns: 1fr 1fr; } }

.orders-list { display: flex; flex-direction: column; gap: .75rem; }
.order-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 1rem;
  border-right: 4px solid var(--line);
}
.order-card.pending  { border-right-color: var(--amber); }
.order-card.done     { border-right-color: #16a34a; }
.order-card.rejected { border-right-color: var(--rose); }

.order-row { display: flex; gap: 1rem; align-items: flex-start; }
.order-thumb {
  width: 70px; flex-shrink: 0;
  aspect-ratio: 9/16; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--page); display: block;
}
.order-thumb-empty {
  width: 70px; flex-shrink: 0;
  aspect-ratio: 9/16; border-radius: 8px;
  border: 1px dashed var(--line); background: var(--page);
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; color: var(--ink-faint); text-align: center;
}
.order-info { flex: 1; min-width: 0; font-size: .85rem; line-height: 1.7; }
.order-ref  { font-weight: 800; font-size: .95rem; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge-pending  { background: var(--amber-bg); color: var(--amber); }
.badge-done     { background: #dcfce7; color: #16a34a; }
.badge-rejected { background: var(--rose-bg); color: var(--rose); }

.order-actions { margin-top: .75rem; display: flex; gap: .4rem; flex-wrap: wrap; padding-top: .75rem; border-top: 1px solid var(--line); }

/* ── فلتر الأدمن ───────────────────────────────────────── */
.filter-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; align-items: center; }
.filter-bar select, .filter-bar input {
  padding: .45rem .8rem; border: 1.5px solid var(--line);
  border-radius: 8px; font-family: var(--font); font-size: .85rem;
  background: #fff; color: var(--ink);
}
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--beige); }

/* ── لوحة الإعدادات ────────────────────────────────────── */
.settings-panel {
  max-width: 520px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 1.5rem;
}

/* ── الـ hidden ────────────────────────────────────────── */
.hidden { display: none !important; }
