/* =========================================================
   Menna Store — Admin dashboard
   ========================================================= */
:root {
  --bg: #fff4f8;
  --paper: #ffffff;
  --ink: #2b1022;
  --ink-2: #4a2a3d;
  --muted: #8f6a7e;
  --line: #f3d6e3;
  --accent: #ff3d8b;
  --accent-2: #ffe1ec;
  --soft: #ffc9de;
  --ok: #1fa463;
  --danger: #e5383b;
  --radius: 18px;
  --shadow: 0 12px 32px -14px rgba(160, 20, 90, .28);
  --font: "Cairo", system-ui, sans-serif;
  --display: "Archivo Black", "Cairo", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.6; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- Shared ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; direction: ltr; }
.logo__mark {
  width: 40px; height: 40px; border-radius: 12px; background: var(--ink); color: var(--accent);
  display: grid; place-items: center; font-family: var(--display); font-size: 22px; transform: rotate(-6deg);
}
.logo__text { font-family: var(--display); font-size: 21px; line-height: 1; }
.logo__text em { font-style: normal; color: var(--accent); margin-left: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 999px; font-weight: 800; white-space: nowrap;
  transition: transform .15s, background .15s, opacity .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 6px 0 -2px var(--ink); }
.btn--dark { background: var(--ink); color: #fff; }
.btn--ghost { border: 2px solid var(--line); background: var(--paper); padding: 8px 16px; }
.btn--ghost:hover { border-color: var(--ink); }
.btn--block { width: 100%; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; transition: background .15s; }
.icon-btn:hover { background: var(--accent-2); }
.icon-btn--danger:hover { background: #ffe0e0; color: var(--danger); }

.input {
  width: 100%; background: var(--bg); border: 2px solid transparent; border-radius: 12px;
  padding: 10px 14px; outline: 0; font-weight: 600; transition: border-color .15s;
}
.input:focus { border-color: var(--accent); background: #fff; }
textarea.input { resize: vertical; }
.input--color { padding: 4px; height: 46px; cursor: pointer; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 14px; }
label small, .field__label small, h2 small { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline .input { flex: 1; min-width: 160px; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 20% 20%, var(--soft), transparent 40%), radial-gradient(circle at 80% 80%, #e9d5ff, transparent 40%), var(--bg);
}
.login__card {
  width: min(400px, 100%); background: var(--paper); border-radius: 26px; padding: 32px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px;
}
.login__card h1 { margin: 10px 0 0; font-size: 28px; font-weight: 900; }
.login__card p { margin: -8px 0 6px; color: var(--muted); font-weight: 600; }
.login__error { color: var(--danger); font-weight: 800; font-size: 14px; min-height: 1em; }
.login__back { text-align: center; color: var(--muted); font-weight: 700; font-size: 14px; }

/* ---------- Layout ---------- */
.dash { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; background: var(--ink); color: #f4dce8;
  padding: 24px 16px; display: flex; flex-direction: column; gap: 28px;
}
.side .logo__text { color: #fff; }
.side .logo__mark { background: var(--accent); color: var(--ink); }
.side__nav { display: flex; flex-direction: column; gap: 6px; }
.side__nav button {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
  font-weight: 800; text-align: start; transition: background .15s;
}
.side__nav button:hover { background: rgba(255, 255, 255, .07); }
.side__nav button.is-active { background: var(--accent); color: #fff; }
.side__foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.side__foot a, .side__foot button { padding: 10px 14px; border-radius: 12px; text-align: start; opacity: .8; }
.side__foot a:hover, .side__foot button:hover { opacity: 1; background: rgba(255, 255, 255, .07); }

.main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.main__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.main__head h1 { margin: 0; font-size: 30px; font-weight: 900; line-height: 1.2; }
.main__head p { margin: 2px 0 0; color: var(--muted); font-weight: 600; }

.filters { display: grid; grid-template-columns: 1fr 200px 160px; gap: 10px; margin-bottom: 16px; }
.filters .input { background: var(--paper); border-color: var(--line); }

/* ---------- Product list ---------- */
.plist { display: flex; flex-direction: column; gap: 10px; container-type: inline-size; }
.prow {
  display: grid; grid-template-columns: 64px minmax(160px, 1fr) 120px 110px 140px auto; gap: 16px; align-items: center;
  background: var(--paper); border-radius: var(--radius); padding: 10px 14px;
  border: 2px solid transparent; transition: border-color .15s;
}
.prow:hover { border-color: var(--line); }
.prow.is-out { background: #fdf6f9; }
.prow.is-out .prow__img { filter: grayscale(1); opacity: .6; }
.prow__img { width: 64px; aspect-ratio: 4 / 5; border-radius: 12px; overflow: hidden; background: var(--accent-2); }
.prow__img img { width: 100%; height: 100%; object-fit: cover; }
.prow__name { font-weight: 800; line-height: 1.4; }
.prow__meta { color: var(--muted); font-size: 13px; font-weight: 700; display: flex; gap: 10px; flex-wrap: wrap; }
.prow__meta .code { direction: ltr; }
.prow__price b { font-weight: 900; }
.prow__price s { display: block; color: var(--muted); font-size: 13px; }
.prow__actions { display: flex; gap: 4px; }
.tag-star { color: var(--accent); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); font-weight: 700; background: var(--paper); border-radius: var(--radius); }

/* switch */
.switch { flex-direction: row; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 14px; }
.switch input { display: none; }
.switch .track {
  position: relative; width: 46px; height: 26px; border-radius: 999px; background: #e6cfd9; flex-shrink: 0; transition: background .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(-20px); }
.stock-label { font-size: 13px; font-weight: 800; }

/* ---------- Categories ---------- */
.clist { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.ccard { background: var(--paper); border-radius: var(--radius); overflow: hidden; border-top: 6px solid var(--c); }
.ccard__img { aspect-ratio: 16 / 10; background: var(--c); }
.ccard__img img { width: 100%; height: 100%; object-fit: cover; }
.ccard__body { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ccard__body h3 { margin: 0; font-size: 18px; font-weight: 900; }
.ccard__body p { margin: 0; color: var(--muted); font-size: 13px; font-weight: 700; }

/* ---------- Panels ---------- */
.panel { background: var(--paper); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 14px; }
.panel h2 { margin: 6px 0 0; font-size: 18px; font-weight: 900; }
.panel__actions { display: flex; justify-content: flex-end; }
.hero-imgs { display: grid; grid-template-columns: repeat(2, 160px); gap: 12px; }

/* ---------- Image editor ---------- */
.imgs { display: flex; gap: 10px; flex-wrap: wrap; }
.img-tile {
  position: relative; width: 108px; aspect-ratio: 4 / 5; border-radius: 14px; overflow: hidden; background: var(--accent-2);
  border: 3px solid transparent;
}
.img-tile.is-main { border-color: var(--accent); }
.img-tile img { width: 100%; height: 100%; object-fit: cover; }
.img-tile__main { position: absolute; top: 6px; right: 6px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 999px; }
.img-tile__tools { position: absolute; inset-inline: 4px; bottom: 4px; display: flex; justify-content: space-between; }
.img-tile__tools button {
  width: 28px; height: 28px; border-radius: 50%; background: rgba(255, 255, 255, .92); font-size: 13px; font-weight: 900;
  display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
.img-tile__tools button:hover { background: #fff; color: var(--accent); }
.img-add {
  width: 108px; aspect-ratio: 4 / 5; border-radius: 14px; border: 2px dashed var(--soft); background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px;
  color: var(--accent); font-weight: 800; font-size: 13px; text-align: center; transition: border-color .15s;
}
.img-add:hover { border-color: var(--accent); }
.img-add b { font-size: 26px; line-height: 1; }
.img-add--url { color: var(--muted); }
.img-add.is-loading { pointer-events: none; opacity: .6; }
.imgs--single .img-tile, .imgs--single .img-add, .hero-imgs .img-tile, .hero-imgs .img-add { width: 100%; max-width: 160px; }
.imgs--single .img-tile, .imgs--single .img-add { aspect-ratio: 16 / 10; max-width: 220px; }

/* ---------- Sizes & colors editor ---------- */
.field { display: flex; flex-direction: column; gap: 10px; }
.field__label { font-weight: 800; font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.sizes-edit { display: flex; gap: 8px; flex-wrap: wrap; min-height: 10px; }
.size-chip {
  display: inline-flex; align-items: center; gap: 2px; border-radius: 12px; background: var(--ink); color: #fff;
  font-weight: 800; overflow: hidden;
}
.size-chip button { padding: 7px 12px; }
.size-chip button.x { padding: 7px 10px; opacity: .6; border-inline-start: 1px solid rgba(255, 255, 255, .2); }
.size-chip button.x:hover { opacity: 1; background: var(--danger); }
.size-chip.is-out { background: #f1e3ea; color: var(--muted); }
.size-chip.is-out button:first-child { text-decoration: line-through; }
.size-chip.is-out button.x { border-color: rgba(0, 0, 0, .1); }
.colors-edit { display: flex; flex-direction: column; gap: 8px; }
.color-row { display: grid; grid-template-columns: 56px 1fr 38px; gap: 8px; align-items: center; }
.color-row .input--color { height: 42px; }

.toggles { display: flex; gap: 24px; flex-wrap: wrap; padding: 6px 0; }
.form-error { color: var(--danger); font-weight: 800; font-size: 14px; }
.form-error:empty { display: none; }

/* ---------- Modal ---------- */
.modal { border: 0; padding: 0; background: transparent; width: min(820px, 100% - 24px); max-height: calc(100vh - 24px); }
.modal--sm { width: min(480px, 100% - 24px); }
.modal::backdrop { background: rgba(43, 16, 34, .55); backdrop-filter: blur(3px); }
.modal[open] { animation: pop .25s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.modal__box { background: var(--paper); border-radius: 24px; display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.modal__head, .modal__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 22px; }
.modal__head { border-bottom: 1px solid var(--line); }
.modal__head h2 { margin: 0; font-size: 21px; font-weight: 900; }
.modal__foot { border-top: 1px solid var(--line); justify-content: flex-end; }
.modal__body { padding: 18px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 200; bottom: 22px; left: 50%; transform: translate(-50%, calc(100% + 40px));
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px; font-weight: 800;
  box-shadow: var(--shadow); transition: transform .35s cubic-bezier(.2, 1.3, .4, 1); max-width: calc(100% - 32px);
}
.toast.is-show { transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); }

/* ---------- Responsive ---------- */
@container (max-width: 760px) {
  .prow { grid-template-columns: 56px 1fr auto; grid-template-areas: "img info actions" "img price stock"; row-gap: 6px; }
  .prow__img { grid-area: img; width: 56px; }
  .prow__info { grid-area: info; }
  .prow__price { grid-area: price; display: flex; gap: 8px; align-items: baseline; }
  .prow__cat { display: none; }
  .prow__stock { grid-area: stock; justify-self: end; }
  .prow__actions { grid-area: actions; }
}
@media (max-width: 820px) {
  .dash { grid-template-columns: 1fr; }
  .side { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; gap: 10px; overflow-x: auto; }
  .side .logo { display: none; }
  .side__nav { flex-direction: row; }
  .side__nav button { padding: 8px 12px; white-space: nowrap; }
  .side__foot { flex-direction: row; margin: 0 auto 0 0; }
  .side__foot a, .side__foot button { white-space: nowrap; padding: 8px 10px; font-size: 13px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters #pSearch { grid-column: 1 / -1; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .main__head h1 { font-size: 24px; }
}
@media (max-width: 520px) {
  .img-tile, .img-add { width: calc(33.33% - 7px); }
  .hero-imgs { grid-template-columns: 1fr 1fr; }
  .modal__body { padding: 16px; }
}
