/* لوحة تحكم فيرا — نفس ثيم الموقع حرفياً */
:root {
  --w900: #2A0710;
  --w600: #6B1F35;
  --w500: #8A2C47;
  --g400: #D4AF5E;
  --g500: #C29B40;
  --ivory: #FDFAF7;
  --ink: #2B1B20;
  --muted: #8a7a80;
  --line: #ead9d3;
  --line2: #f2e6e0;
  --card: #ffffff;
  --ok: #2e7d32;
  --danger: #b3261e;
  --warn: #9a6b00;
  --ease: cubic-bezier(.22, .61, .21, 1);
  --sh-card: 0 1px 3px rgba(42, 7, 16, .06), 0 8px 24px rgba(42, 7, 16, .05);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--ivory);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.7;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
a { color: var(--w600); }
h1, h2, h3 { margin: 0; font-weight: 600; color: var(--w900); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }

/* ===== أزرار وحقول ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line);
  background: var(--card); color: var(--w600);
  padding: 10px 18px; border-radius: 999px;
  font-size: 15px; font-weight: 600; line-height: 1.4;
  transition: all .25s var(--ease);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--w600); }
.btn-gold { background: linear-gradient(135deg, var(--g400), var(--g500)); border-color: transparent; color: #fff; }
.btn-gold:hover { filter: brightness(1.05); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: #f0c9c6; }
.btn-danger:hover { border-color: var(--danger); background: #fdf3f2; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 13px; font-size: 13.5px; }
.btn:disabled { opacity: .55; cursor: wait; }

.input, .select, .textarea {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
  transition: border-color .2s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--w600);
  box-shadow: 0 0 0 3px rgba(107, 31, 53, .10);
}
.textarea { min-height: 90px; resize: vertical; }
.field-label { display: block; font-weight: 600; margin: 14px 0 6px; color: var(--w900); }
.field-hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

.error-box {
  background: #fdf3f2; border: 1px solid #f0c9c6; color: var(--danger);
  border-radius: 10px; padding: 10px 14px; margin: 12px 0;
  font-weight: 600; font-size: 14px;
}
.ok-box {
  background: #eef7ee; border: 1px solid #bfe3c0; color: var(--ok);
  border-radius: 10px; padding: 10px 14px; margin: 12px 0;
  font-weight: 600; font-size: 14px;
}

/* ===== صفحة الدخول ===== */
.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(600px 300px at 85% -5%, rgba(212, 175, 94, .16), transparent 60%),
    radial-gradient(500px 300px at 10% 105%, rgba(107, 31, 53, .12), transparent 60%),
    var(--ivory);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line2);
  border-radius: 20px;
  box-shadow: var(--sh-card);
  padding: 36px 28px 28px;
  text-align: center;
}
.login-logo { width: 190px; height: auto; margin-bottom: 8px; }
.login-card h1 { font-size: 26px; }
.login-sub { color: var(--muted); margin: 6px 0 10px; font-size: 14.5px; }
.login-card form { text-align: right; margin-top: 8px; }
.login-note { color: var(--muted); font-size: 13px; margin: 18px 0 0; }

/* ===== هيدر اللوحة ===== */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--w900), var(--w600));
  color: #fff;
  box-shadow: 0 2px 12px rgba(42, 7, 16, .25);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 96px; height: auto; filter: brightness(0) invert(1); }
.brand strong { display: block; font-size: 17px; line-height: 1.3; color: #fff; }
.brand small { display: block; font-size: 12px; color: rgba(255, 255, 255, .75); }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.header-actions .btn { border-color: rgba(255, 255, 255, .35); color: #fff; background: transparent; padding: 8px 14px; font-size: 13.5px; }
.header-actions .btn:hover { border-color: #fff; }
.header-actions .btn-gold { background: linear-gradient(135deg, var(--g400), var(--g500)); border-color: transparent; }

.publish-status {
  margin: 12px 16px 0; padding: 10px 14px; border-radius: 10px;
  font-weight: 600; font-size: 14px;
}
.publish-status.ok { background: #eef7ee; color: var(--ok); border: 1px solid #bfe3c0; }
.publish-status.err { background: #fdf3f2; color: var(--danger); border: 1px solid #f0c9c6; }

/* ===== جسم اللوحة ===== */
.app-body { max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; }
.app-nav {
  display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 4px;
  scrollbar-width: none;
}
.app-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); border-radius: 999px; padding: 9px 16px;
  font-size: 14.5px; font-weight: 600; transition: all .25s var(--ease);
}
.nav-btn:hover { border-color: var(--w600); color: var(--w600); }
.nav-btn.on { background: var(--w600); border-color: var(--w600); color: #fff; }
.nav-btn .cnt {
  display: inline-block; min-width: 20px; padding: 0 5px; margin-inline-start: 5px;
  border-radius: 999px; background: rgba(107, 31, 53, .10); color: var(--w600);
  font-size: 12px; line-height: 20px; text-align: center;
}
.nav-btn.on .cnt { background: rgba(255, 255, 255, .25); color: #fff; }

.app-main { padding-top: 14px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2 { font-size: 22px; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.back-link { background: none; border: none; color: var(--w600); font-weight: 700; font-size: 15px; padding: 4px 0; }

.card {
  background: var(--card); border: 1px solid var(--line2);
  border-radius: var(--radius); box-shadow: var(--sh-card);
  padding: 16px; margin-bottom: 14px;
}
.card h3 { font-size: 17px; margin-bottom: 4px; }
.card .muted { color: var(--muted); font-size: 13.5px; }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line2); border-radius: var(--radius); padding: 16px; box-shadow: var(--sh-card); }
.stat b { display: block; font-size: 30px; line-height: 1.1; color: var(--w600); }
.stat span { color: var(--muted); font-size: 13.5px; }

.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.cat-card {
  background: var(--card); border: 1px solid var(--line2); border-radius: var(--radius);
  overflow: hidden; text-align: right; padding: 0; box-shadow: var(--sh-card);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.cat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(42, 7, 16, .12); }
.cat-card img { width: 100%; height: 110px; object-fit: cover; display: block; background: var(--line2); }
.cat-card .cat-body { padding: 12px 14px; }
.cat-card h3 { font-size: 16px; }
.cat-card p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.cat-card .cat-count { display: inline-block; margin-top: 8px; font-size: 12.5px; font-weight: 700; color: var(--w600); background: rgba(107, 31, 53, .08); border-radius: 999px; padding: 2px 10px; }

.row-list { display: flex; flex-direction: column; gap: 10px; }
.row-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line2); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--sh-card);
}
.row-item .thumb { width: 56px; height: 70px; object-fit: cover; border-radius: 8px; background: var(--line2); flex: 0 0 auto; }
.row-item .thumb-dot { width: 56px; height: 70px; border-radius: 8px; background: var(--line2); flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--w600); font-weight: 700; }
.row-item .info { flex: 1; min-width: 0; }
.row-item .info b { display: block; font-size: 15.5px; color: var(--w900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .info span { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .price { font-weight: 700; color: var(--w600); white-space: nowrap; }
.row-item .price.none { color: var(--warn); font-weight: 600; font-size: 13.5px; }
.row-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.color-dots { display: inline-flex; gap: 4px; vertical-align: middle; }
.color-dots i { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .15); display: inline-block; }

/* سويتش */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 46px; height: 26px; border-radius: 999px; background: #cfc4c8;
  transition: background .25s var(--ease); position: relative; flex: 0 0 auto;
}
.switch .track::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, .3); transition: transform .25s var(--ease);
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(-20px); }
.switch .sw-label { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.switch input:checked ~ .sw-label { color: var(--ok); }

/* معارض الصور */
.media-slots { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.media-slot { border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.media-slot img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; background: var(--line2); }
.media-slot .slot-name { font-weight: 700; margin: 8px 0 2px; }
.media-slot .slot-state { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.media-slot .slot-actions { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery figure { margin: 0; position: relative; }
.gallery img { width: 100%; aspect-ratio: 4/5; object-fit: cover; border-radius: 8px; display: block; background: var(--line2); }
.gallery .del {
  position: absolute; top: 4px; inset-inline-end: 4px;
  width: 26px; height: 26px; border-radius: 50%; border: none;
  background: rgba(42, 7, 16, .75); color: #fff; font-size: 16px; line-height: 1;
}
.gallery .is-display { outline: 3px solid var(--g500); outline-offset: -3px; }
.gallery .display-badge {
  position: absolute; bottom: 6px; inset-inline-start: 6px;
  background: var(--g500); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 2px 8px;
}
.gallery .set-display {
  position: absolute; bottom: 6px; inset-inline-end: 6px;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--line);
  border-radius: 999px; font-size: 11px; padding: 2px 8px; font-weight: 700; color: var(--w600);
}

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 7px 14px; font-size: 13.5px; font-weight: 600;
}
.chip.on { background: var(--w600); color: #fff; border-color: var(--w600); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .full { grid-column: 1 / -1; }
.color-edit-row { display: grid; grid-template-columns: 1fr 90px 64px 30px; gap: 8px; align-items: center; margin-bottom: 8px; }
.color-edit-row input { padding: 8px 10px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line2); text-align: right; }
.tbl th { color: var(--muted); font-size: 13px; }
.tbl input { width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty b { display: block; color: var(--w900); font-size: 16px; margin-bottom: 4px; }

/* ورقة منبثقة */.sheet-layer { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(42, 7, 16, .45); }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh;
  overflow-y: auto; background: var(--ivory); border-radius: 20px 20px 0 0;
  padding: 18px 18px 28px; box-shadow: 0 -8px 40px rgba(42, 7, 16, .25);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.sheet-head h2 { font-size: 19px; }
.sheet-x { border: none; background: var(--line2); width: 34px; height: 34px; border-radius: 50%; font-size: 20px; line-height: 1; color: var(--w900); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--w900); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 600; font-size: 14.5px; z-index: 200; box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
  max-width: calc(100vw - 32px); text-align: center;
}

@media (max-width: 899px) {
  /* صفوف القوائم: الأزرار تنزل سطراً كاملاً تحت المعلومات بدل فيض أفقي */
  .row-item { flex-wrap: wrap; }
  .row-item .row-actions { flex: 1 1 100%; justify-content: flex-start; padding-inline-start: 68px; margin-top: 2px; flex-wrap: wrap; min-width: 0; }
  .row-actions { flex-wrap: wrap; }
  .header-actions .btn { padding: 8px 11px; font-size: 13px; }
  .brand img { width: 72px; }
  .brand small { display: none; }
}

@media (min-width: 900px) {
  .app-body { display: flex; gap: 20px; padding-top: 18px; }
  .app-nav {
    flex: 0 0 210px; flex-direction: column; overflow: visible; padding: 0;
    position: sticky; top: 86px; align-self: flex-start;
  }
  .nav-btn { text-align: right; }
  .app-main { flex: 1; min-width: 0; padding-top: 0; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .cat-grid { grid-template-columns: repeat(4, 1fr); }
  .cat-card img { height: 130px; }
  .media-slots { grid-template-columns: repeat(4, 1fr); }
  .gallery { grid-template-columns: repeat(5, 1fr); }
  .sheet-layer { align-items: center; }
  .sheet { border-radius: 20px; }
}
