:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #5f6b76;
  --line: #e2ddd3;
  --accent: #0f766e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Tajawal", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.site-header { padding: 24px 16px 8px; text-align: center; }
.brand { font-size: 32px; font-weight: 800; color: var(--accent); text-decoration: none; }

.site-footer { text-align: center; padding: 8px 16px 32px; color: var(--muted); font-size: 14px; }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-bottom: 8px; }
.site-footer a { color: var(--muted); }
.site-footer p { margin: 0; }

.doc { max-width: 760px; margin: 16px auto 24px; line-height: 1.9; }
.doc h1 { margin-top: 0; }
.doc h2 { font-size: 19px; margin: 22px 0 6px; color: var(--accent); }
.doc .small { color: var(--muted); font-size: 14px; }
.doc { margin-inline: max(16px, calc((100% - 760px) / 2)); }
.tagline { margin: 4px 0 0; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 20px;
  max-width: 1280px;
  margin: 16px auto 40px;
  padding: 0 16px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.form h1 { margin: 0 0 16px; font-size: 22px; }
.form label { display: block; font-weight: 500; margin-bottom: 14px; font-size: 15px; }
.form input, .form select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pages { margin: 0 0 14px; padding: 12px; border: 1px dashed var(--accent); border-radius: 10px; background: #f3faf8; }
.form .pages-btn {
  display: inline-block; margin: 0; cursor: pointer; font-weight: 700; color: var(--accent);
  background: #fff; border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px;
}
.form .pages input[type="file"] { display: none; }
.pages-hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.pages-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.pages-list:empty { display: none; }
.pages-list figure { position: relative; margin: 0; }
.pages-list img { width: 64px; height: 84px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.pages-list button {
  position: absolute; top: -6px; inset-inline-start: -6px; width: 22px; height: 22px; padding: 0;
  border-radius: 50%; background: #b91c1c; font-size: 13px; line-height: 22px;
}

.themes { border: 0; padding: 0; margin: 0 0 18px; display: flex; gap: 10px; align-items: center; }
.themes legend { font-weight: 500; margin-bottom: 8px; }
.themes label { margin: 0; position: relative; }
.themes input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; }
.swatch { display: block; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }
.themes input:checked + .swatch { border-color: var(--ink); }
.themes input:focus-visible + .swatch { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch.green { background: #0f766e; }
.swatch.blue { background: #1d4ed8; }
.swatch.purple { background: #7c3aed; }
.swatch.orange { background: #c2410c; }
.swatch.red { background: #b91c1c; }
.swatch.pink { background: #be185d; }
.swatch.brown { background: #92400e; }
.swatch.navy { background: #1e3a8a; }
.themes { flex-wrap: wrap; }

/* اختيار شكل المطوية */
.templates { border: 0; padding: 0; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.templates legend { font-weight: 500; margin-bottom: 8px; }
.templates label { margin: 0; position: relative; }
.templates input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.templates span { display: block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 20px; font-size: 14px; background: #fff; }
.templates input:checked + span { border-color: var(--accent); background: #f3faf8; color: var(--accent); font-weight: 700; }
.templates input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

button {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
#submit { width: 100%; font-size: 17px; }

.status { min-height: 1.4em; margin: 10px 0 0; color: var(--muted); }
.status.error { color: #b91c1c; }

.preview-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.preview-bar h2 { margin: 0; font-size: 20px; }
.demo-note { background: #fff7e6; border: 1px solid #f3d9a4; padding: 8px 12px; border-radius: 8px; margin: 0 0 12px; }
.preview { overflow-x: auto; }
.preview .empty { color: var(--muted); text-align: center; padding: 60px 0; }

.result { max-width: 560px; margin: 24px auto; text-align: center; }
.result h1 { font-size: 24px; margin-top: 0; }
.result .small { color: var(--muted); font-size: 14px; }
.btn {
  display: inline-block; text-decoration: none; font-weight: 700;
  background: var(--accent); color: #fff; padding: 12px 22px; border-radius: 10px; margin: 8px 0;
}

/* حفظ رابط المطوية بعد الشراء */
.keep-link { margin-top: 12px; padding: 14px; border-radius: 10px; background: #f3faf8; border: 1px solid var(--line); }
.keep-link p { margin: 0 0 10px; }
.keep-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn.whatsapp { background: #128c4a; margin: 0; }
button.secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }

/* مطويات هذا الجهاز ومعاينته المحفوظة في الصفحة الرئيسية */
.mine { max-width: 1280px; margin: 8px auto 0; padding: 0 16px; }
.mine .panel { padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.mine strong { font-size: 15px; }
.mine a { color: var(--accent); font-weight: 700; text-decoration: none; background: #f3faf8; border: 1px solid var(--line); border-radius: 20px; padding: 6px 12px; font-size: 14px; }

/* عرض المطوية صورتين: الوجه الأمامي والخلفي، كصور المنتج في المتاجر */
.mock { display: grid; gap: 18px; position: relative; }
.mock figure { margin: 0; }
.mock figcaption { font-weight: 700; margin-bottom: 8px; color: var(--ink); }
.mock img {
  display: block; width: 100%; height: auto; aspect-ratio: 297 / 210; background: #f1efe9;
  border-radius: 6px; box-shadow: 0 10px 28px rgba(0, 0, 0, .16), 0 2px 6px rgba(0, 0, 0, .08);
  cursor: zoom-in;
}
.mock.busy img { opacity: .55; transition: opacity .2s; }
.mock-wait { position: absolute; inset: 40% 0 auto; text-align: center; font-weight: 700; color: var(--accent); }
.edit-bar { display: flex; justify-content: center; margin: 16px 0 8px; }
.edit-bar button { font-size: 16px; }
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .85); overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 48px 8px 16px; }
.lightbox img { width: min(1400px, 220vw); max-width: none; height: auto; border-radius: 4px; }
.lightbox button { position: fixed; top: 10px; inset-inline-end: 12px; width: 40px; height: 40px; border-radius: 50%; padding: 0; font-size: 24px; background: #fff; color: #111; }

/* صفحات المطويات الجاهزة لقوقل */
.seo-page { max-width: 1180px; margin: 12px auto 32px; padding: 0 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.seo-page h1 { margin: 0 0 8px; font-size: 26px; line-height: 1.5; }
.seo-page h2 { font-size: 20px; margin: 4px 0 10px; color: var(--accent); }
.seo-hero p { line-height: 1.9; margin: 0 0 10px; }
.seo-facts { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.seo-outline, .seo-list { line-height: 2; margin: 0 0 12px; }
.seo-list a { color: var(--accent); font-weight: 700; text-decoration: none; }
.seo-preview { margin-bottom: 14px; overflow-x: auto; }
.btn.secondary-link { background: #fff; color: var(--accent); border: 1px solid var(--accent); }

.edit-hint { color: var(--muted); margin: 0 0 12px; font-size: 14px; }

/* أدوات التعديل داخل المعاينة */
.preview [contenteditable] { outline: none; border-radius: 2mm; transition: background .15s; }
.preview [contenteditable]:hover { background: rgba(255, 213, 79, .18); }
.preview [contenteditable]:focus { background: rgba(255, 213, 79, .32); }
.preview .cover [contenteditable]:hover, .preview .cover [contenteditable]:focus { background: rgba(255, 255, 255, .18); }
.section { position: relative; }
.rewrite {
  position: absolute; top: 0; inset-inline-end: 0;
  font-size: 9pt; font-weight: 500; padding: 1mm 2.5mm; border-radius: 2mm;
  background: var(--c-soft); color: var(--c); opacity: 0; transition: opacity .15s;
}
.section:hover .rewrite, .rewrite:focus, .rewrite:disabled { opacity: 1; }

/* أماكن محجوزة لما يُكتب بعد الدفع */
.locked { display: flex; flex-direction: column; gap: 2.5mm; padding: 4mm 0; }
.locked .line { display: block; height: 3mm; border-radius: 2mm; background: #eceae4; }
.locked .line.short { width: 60%; }
.locked .lock-note { font-size: 9.5pt; color: var(--c); font-weight: 700; }
.locked .lock-note::before { content: "🔒 "; }

/* مكتبة المطويات الجاهزة */
.ready { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.ready h2 { font-size: 17px; margin: 0 0 4px; }
.ready p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.ready-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ready-list button {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  font-weight: 500; font-size: 14px; padding: 8px 12px; border-radius: 20px;
}
.ready-list button:hover { border-color: var(--accent); color: var(--accent); }

/* صفحة ما بعد الدفع */
.order-layout { max-width: 1280px; margin: 16px auto 40px; padding: 0 16px; display: grid; gap: 16px; }
.order-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.order-bar h1 { margin: 0; font-size: 22px; }
.order-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.order-meta label { font-weight: 500; font-size: 14px; }
.order-meta input { display: block; margin-top: 4px; padding: 8px 10px; font: inherit; border: 1px solid var(--line); border-radius: 8px; }
.order-meta .themes, .order-meta .templates { margin: 0; }
.order-meta [data-pickers] { width: 100%; display: grid; gap: 10px; }

/* العلامة المائية: نص مائل مكرر يغطي الورقة كلها، ولا يمنع الضغط على النصوص تحته */
.watermark {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='420' height='220'><text x='50%' y='50%' text-anchor='middle' font-family='Tajawal, sans-serif' font-size='34' font-weight='800' fill='rgba(120,120,120,0.28)' transform='rotate(-24 210 110)'>نسخة مجانية · مطوياتي</text></svg>");
}

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

/* صفحة الموقع لا تُطبع؛ الطباعة تكون من ملف PDF النظيف بعد الدفع */
.print-block { display: none; }
@media print {
  .site-header, .layout { display: none; }
  .print-block { display: block; text-align: center; font-size: 20pt; margin-top: 40vh; }
}

