/* ============================================================
   استوديو التوضيب — أنماط مطابقة لهوية فواصل (متغيرات مطابقة
   لقيم tokens.css الافتراضية؛ التطبيق ثابت داخل iframe فلا يرث
   محرك المظهر — القيم هنا نسخة يدوية من الهوية)
   ============================================================ */
:root {
  --primary: #0e7a6d;
  --primary-dark: #0a5d53;
  --primary-soft: #e3f2f0;
  --accent: #c0392b;
  --ink: #1c2320;
  --body: #3d4a45;
  --muted: #7a8681;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --line: #e4e0d7;
  --radius: 14px;
}

* { box-sizing: border-box; }
/* خاصية hidden تغلب أي display من الكلاسات (وإلا أظهرها .row{display:flex}) */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Tahoma, system-ui, sans-serif;
  background: var(--bg);
  color: var(--body);
  font-size: 14px;
  line-height: 1.7;
}

.app {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 16px;
  padding: 16px;
  min-height: 100vh;
  align-items: start;
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
}

/* ─── اللوحة ─── */
.panel { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 16px; }
@media (max-width: 860px) { .panel { position: static; } }

.box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.box h2 { margin: 0 0 6px; font-size: 15px; color: var(--ink); }
.hint { margin: 0 0 10px; font-size: 12px; color: var(--muted); }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }

.field { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 10px; flex: 1; }
.field input, .field select {
  display: block; width: 100%; margin-top: 4px;
  border: 2px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font-size: 14px; font-family: inherit; color: var(--ink);
  background: var(--surface);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid var(--line); border-radius: 10px; cursor: pointer;
  background: var(--surface); color: var(--ink);
  padding: 9px 14px; font-size: 13.5px; font-weight: 700; font-family: inherit;
  transition: 0.15s;
}
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-stop { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-big { width: 100%; padding: 12px; font-size: 15px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ─── قائمة التصاميم ─── */
.designs { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.design {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 7px;
  background: var(--bg);
}
.design .thumb {
  width: 44px; height: 44px; border-radius: 8px; background: #fff;
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.design .thumb svg { max-width: 38px; max-height: 38px; }
.design .meta { min-width: 0; }
.design .name { font-weight: 700; color: var(--ink); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.design .dims { font-size: 11px; color: var(--muted); }
.design .ctrl { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.design .ctrl label { font-size: 10px; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 4px; }
.design .ctrl input { width: 62px; border: 1.5px solid var(--line); border-radius: 7px; padding: 3px 6px; font-size: 12.5px; font-family: inherit; }
.design .remove { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0; font-family: inherit; font-weight: 700; }

.status { margin: 8px 0 0; font-size: 12.5px; font-weight: 700; color: var(--primary-dark); min-height: 20px; }
.status.err { color: var(--accent); }

/* ─── المسرح ─── */
.stage { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; text-align: center;
}
.stat b { display: block; font-size: 22px; color: var(--primary-dark); }
.stat span { font-size: 11.5px; color: var(--muted); font-weight: 700; }

.progress-wrap { background: var(--line); border-radius: 99px; height: 8px; overflow: hidden; }
.progress { height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width 0.2s; }

.empty {
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 60px 24px; text-align: center; color: var(--muted);
}
.empty-icon { font-size: 42px; }
.empty h3 { color: var(--ink); margin: 8px 0 4px; }
.empty p { margin: 0; }

.sheets { display: flex; flex-direction: column; gap: 14px; }
.sheet-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-head b { color: var(--ink); font-size: 13.5px; }
.sheet-head .btn { padding: 5px 10px; font-size: 12px; }
.sheet-view { border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: auto; }
.sheet-view svg { display: block; width: 100%; height: auto; }
/* قطع بلا تعبئة تظهر بلون هادئ، والفتحات بيضاء (نفس اصطلاح المحرك class=hole) */
.sheet-view svg * { fill-opacity: 0.9; }
.sheet-view svg *:not([fill]) { fill: var(--primary-soft); stroke: var(--primary-dark); stroke-width: 0.6; }
.sheet-view svg .hole { fill: #fff !important; }

.dl-all { text-align: center; }
