﻿/* ============================================================
   لوحة التحكم — admin panel
   Same brand language as the storefront, tuned for density.
   ============================================================ */

.admin-body {
  background: var(--cream-deep);
  padding-bottom: var(--sp-6);
}

/* --------------------------------------------------- login */

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background: linear-gradient(160deg, var(--saffron) 0%, var(--saffron-deep) 100%);
}

.login-card {
  width: min(100%, 400px);
  background: var(--paper);
  border-radius: var(--radius-xl);
  padding: clamp(1.5rem, 5vw, 2.5rem);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.login-mark {
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--forest);
}

.login-card h1 { font-size: var(--text-md); text-align: center; color: var(--ink-faint); font-weight: 500; }

/* -------------------------------------------------- header */

.admin-header {
  position: sticky;
  top: 0;
  z-index: 80;
  background: var(--forest);
  color: var(--cream);
  box-shadow: var(--shadow);
}

.admin-header__inner {
  max-width: 1320px;
  margin-inline: auto;
  padding: var(--sp-3) var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.admin-header .brand__name { color: var(--saffron-soft); font-size: var(--text-base); }
.admin-header .brand__sub { color: rgba(255, 252, 247, 0.55); }
.admin-header__actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }

.admin-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 0 var(--gutter) 0;
  max-width: 1320px;
  margin-inline: auto;
  scrollbar-width: none;
}

.admin-tabs::-webkit-scrollbar { display: none; }

.admin-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: var(--text-sm);
  color: rgba(255, 250, 240, 0.7);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all 0.18s var(--ease);
}

.admin-tab:hover { color: var(--saffron-soft); }

.admin-tab[aria-selected='true'] {
  color: var(--saffron);
  border-bottom-color: var(--saffron);
}

.tab-badge {
  min-width: 19px;
  height: 19px;
  padding-inline: 5px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--terracotta);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
}


.admin-main {
  max-width: 1320px;
  margin-inline: auto;
  padding: var(--sp-5) var(--gutter);
}

.admin-panel { display: block; }

.admin-grid-2 {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: 1fr;
  margin-top: var(--sp-4);
}

@media (min-width: 980px) {
  .admin-grid-2 { grid-template-columns: 1.35fr 1fr; align-items: start; }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
  margin-bottom: var(--sp-4);
}

/* ---------------------------------------------------- stats */

.stat-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr));
}

.stat {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat::after {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: var(--saffron);
}

.stat--forest::after { background: var(--forest); }
.stat--fresh::after { background: var(--fresh); }
.stat--terracotta::after { background: var(--terracotta); }

.stat__label { font-size: var(--text-xs); color: var(--ink-faint); font-weight: 600; }

.stat__value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--forest);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat__meta { font-size: var(--text-xs); color: var(--ink-soft); }

/* ---------------------------------------------------- chart */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 170px;
  padding-top: var(--sp-3);
}

.chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  height: 100%;
  min-width: 0;
}

.chart__bar {
  width: 100%;
  min-height: 3px;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--saffron) 0%, var(--saffron-deep) 100%);
  transition: height 0.6s var(--ease);
  position: relative;
}

.chart__bar[data-value='0'] { background: var(--line-soft); }
.chart__day { font-size: 0.6rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ top items */

.top-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--sp-3);
  align-items: center;
  padding-block: var(--sp-2);
  border-bottom: 1px dashed var(--line);
}

.top-item:last-child { border-bottom: none; }

.top-item__rank {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--saffron-mist);
  color: var(--saffron-dark);
  font-weight: 800;
  font-size: var(--text-xs);
}

.top-item__name { font-weight: 600; font-size: var(--text-sm); color: var(--forest); }
.top-item__qty { font-weight: 800; color: var(--terracotta); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --------------------------------------------------- orders */

.order-card {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-inline-start: 4px solid var(--saffron);
  border-radius: var(--radius);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-3);
}

.order-card--new { border-inline-start-color: var(--saffron); background: #fffdf6; }
.order-card--confirmed { border-inline-start-color: var(--forest); }
.order-card--preparing { border-inline-start-color: var(--warning); }
.order-card--delivering { border-inline-start-color: var(--fresh); }
.order-card--done { border-inline-start-color: var(--success); opacity: 0.82; }
.order-card--cancelled { border-inline-start-color: var(--danger); opacity: 0.6; }

.order-card__head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  align-items: baseline;
  justify-content: space-between;
}

.order-card__code {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--forest);
  letter-spacing: 0.05em;
  direction: ltr;
}

.order-card__time { font-size: var(--text-xs); color: var(--ink-faint); }

.order-meta {
  display: grid;
  gap: var(--sp-1);
  margin-block: var(--sp-3);
  font-size: var(--text-sm);
}

.order-meta div { display: flex; gap: var(--sp-2); align-items: flex-start; }
.order-meta b { color: var(--ink-faint); font-weight: 600; flex: 0 0 62px; }

.order-items {
  background: var(--cream);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
  font-size: var(--text-sm);
  display: grid;
  gap: 4px;
}

.order-items div { display: flex; justify-content: space-between; gap: var(--sp-3); }

.order-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--line);
}

.order-card__actions select {
  padding: 0.45rem 0.8rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  font-size: var(--text-sm);
  font-weight: 600;
}

.notify-pill {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.2em 0.7em;
  border-radius: var(--radius-pill);
}

.notify-pill--sent { background: var(--success-mist); color: var(--success); }
.notify-pill--failed { background: var(--danger-mist); color: var(--danger); }
.notify-pill--skipped { background: var(--warning-mist); color: var(--warning); }
.notify-pill--pending { background: var(--cream-deep); color: var(--ink-soft); }
.notify-pill--throttled { background: var(--warning-mist); color: var(--warning); }

/* ------------------------------------------------ menu edit */

.admin-category { margin-bottom: var(--sp-5); }

.admin-category__head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.admin-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-2) var(--sp-3);
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: var(--sp-3);
  margin-bottom: var(--sp-2);
}

.admin-item--hidden { opacity: 0.55; background: var(--cream-deep); }
.admin-item__name { font-weight: 600; color: var(--forest); font-size: var(--text-sm); line-height: 1.4; }
.admin-item__unit { font-size: var(--text-xs); color: var(--ink-faint); }
.admin-item__side { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; justify-content: flex-end; }

.price-input {
  width: 92px;
  padding: 0.4rem 0.6rem;
  text-align: center;
  font-weight: 800;
  color: var(--terracotta);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--cream);
  font-size: max(16px, var(--text-sm));
  font-variant-numeric: tabular-nums;
}

.price-input:focus { outline: none; border-color: var(--saffron); box-shadow: 0 0 0 3px rgba(237, 172, 26, 0.22); }
.price-input.is-saved { border-color: var(--success); background: var(--success-mist); }

/* Availability toggle */
.switch { display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch__track {
  width: 44px;
  height: 25px;
  border-radius: var(--radius-pill);
  background: var(--line);
  position: relative;
  transition: background 0.2s var(--ease);
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease);
}

.switch input:checked + .switch__track { background: var(--fresh); }
.switch input:checked + .switch__track::after { transform: translateX(-19px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--fresh); outline-offset: 2px; }

/* -------------------------------------------------- reviews */

.admin-review {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-sm);
}

.admin-review--pending { border-inline-start: 4px solid var(--warning); background: #fffdf6; }

/* ---------------------------------------------------- modal */

.modal { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: var(--gutter); }

.modal__backdrop { position: absolute; inset: 0; background: rgba(35, 25, 11, 0.55); backdrop-filter: blur(3px); }

.modal__panel {
  position: relative;
  width: min(100%, 520px);
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--paper);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.28s var(--ease-bounce);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.modal__head {
  position: sticky;
  top: 0;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
  z-index: 1;
}

.modal__head h2 { font-size: var(--text-md); }
.modal__close { font-size: 1.2rem; color: var(--ink-faint); width: 34px; height: 34px; border-radius: 50%; }
.modal__close:hover { background: var(--cream-deep); color: var(--danger); }
.modal__body { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }

/* ------------------------------------------- gallery editor */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: var(--sp-2);
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--cream-deep);
}

/* Uncropped: the point of a thumbnail here is confirming which image it
   is, and a centre crop of a tall screenshot shows almost nothing. */
.gallery-item img { width: 100%; height: 100%; object-fit: contain; background: var(--cream-deep); }

.gallery-item__remove {
  position: absolute;
  top: 3px;
  inset-inline-end: 3px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(36, 28, 17, 0.7);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1;
}

.gallery-item__remove:hover { background: var(--danger); }

.gallery-add {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  gap: 2px;
  border: 1.5px dashed var(--line);
  border-radius: 8px;
  color: var(--ink-faint);
  font-size: 1.1rem;
  transition: border-color 0.16s var(--ease), color 0.16s var(--ease);
}

.gallery-add span { font-size: 0.62rem; font-weight: 600; }
.gallery-add:hover { border-color: var(--forest); color: var(--forest); }

/* ------------------------------------------- upload feedback */

.up-status {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--cream-deep);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-soft);
}

.up-status__head { display: flex; align-items: center; gap: 8px; }
.up-status__label { flex: 1; min-width: 0; }
.up-status__percent { font-variant-numeric: tabular-nums; color: var(--forest); }

.up-status.is-done { background: var(--success-mist); color: var(--success); }
.up-status.is-error { background: var(--danger-mist); color: var(--danger); }

.up-spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--forest);
  animation: up-spin 0.7s linear infinite;
}

@keyframes up-spin { to { transform: rotate(360deg); } }

/* A finished upload has nothing left to spin about. */
.up-status.is-done .up-spinner {
  border-color: var(--success);
  animation: none;
}

.up-status.is-error .up-spinner {
  border-color: var(--danger);
  animation: none;
}

.up-bar {
  display: block;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--line-soft);
  overflow: hidden;
}

.up-bar__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--saffron) 0%, var(--forest) 100%);
  transition: width 0.2s var(--ease);
}

/* Shrinking a photo has no measurable percentage, so the bar sweeps to show
   the app is working rather than sitting at a misleading zero. */
.up-bar__fill.is-indeterminate {
  animation: up-sweep 1.1s ease-in-out infinite;
  transition: none;
}

@keyframes up-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* The chosen photo shows immediately while it uploads; dimming it makes
   clear the upload has not finished yet. */
.is-uploading { opacity: 0.55; filter: saturate(0.6); }

@media (prefers-reduced-motion: reduce) {
  .up-spinner { animation: none; }
  .up-bar__fill.is-indeterminate { animation: none; opacity: 0.6; }
}

/* ----------------------------------------------- misc bits */

.setup-steps { display: grid; gap: var(--sp-2); padding-inline-start: 1.2rem; list-style: decimal; font-size: var(--text-sm); color: var(--ink-soft); }
.setup-steps code { background: var(--cream-deep); padding: 0.15em 0.45em; border-radius: 5px; font-size: 0.88em; word-break: break-all; }

.admin-empty { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--ink-faint); }
.admin-empty__emoji { font-size: 2.6rem; margin-bottom: var(--sp-2); }

/* ============================================================
   Pickup appointments, offers, reviews media and accounting
   ============================================================ */

/* ------------------------------------------------ toolbar bits */

.toolbar__pickup {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-soft);
}

.toolbar__pickup input[type='date'] {
  padding: 0.4rem 0.7rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-size: max(16px, var(--text-sm));
}

/* --------------------------------------------- order card bits */

.order-card__invoice {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--terracotta);
  direction: ltr;
}

.order-card__pickup {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--forest-mist);
  color: var(--forest);
  font-size: var(--text-sm);
}

.order-card__pickup span:last-child { color: var(--ink-soft); font-size: var(--text-xs); }

/* --------------------------------------------------- offers */

.admin-offer {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: var(--sp-3);
  align-items: start;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: var(--sp-3);
  margin-bottom: var(--sp-2);
  box-shadow: var(--shadow-sm);
}

@media (min-width: 760px) {
  .admin-offer { grid-template-columns: 88px 1fr auto; align-items: center; }
}

.admin-offer__thumb {
  width: 88px;
  height: 66px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--cream-deep);
}

.admin-offer__body { min-width: 0; }
.admin-offer__title { font-weight: 700; color: var(--forest); font-size: var(--text-sm); line-height: 1.4; }

.admin-offer__side {
  grid-column: 1 / -1;
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
}

@media (min-width: 760px) {
  .admin-offer__side { grid-column: auto; justify-content: flex-end; }
}

/* ------------------------------------------- review media */

.admin-review__photos {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-block: var(--sp-2);
}

.admin-review__photos img {
  width: 92px;
  height: 92px;
  /* Whole screenshot, not a crop of its middle — the owner is checking what
     the customer actually wrote before publishing it. */
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--cream-deep);
}

.admin-review__photos a:hover img { border-color: var(--forest); }

/* --------------------------------------------- dual chart */

.chart--dual { gap: 6px; }

.chart__pair {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 100%;
  height: 100%;
}

.chart__bar--expense { background: linear-gradient(180deg, var(--terracotta-soft) 0%, var(--terracotta) 100%); }
.chart__bar--month { background: linear-gradient(180deg, var(--forest-soft) 0%, var(--forest) 100%); }

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-inline: 8px 3px;
  vertical-align: middle;
}

.legend-dot--sales { background: var(--saffron); }
.legend-dot--expense { background: var(--terracotta); }

.top-item--current .top-item__rank { background: var(--forest); color: var(--saffron-soft); }

/* ---------------------------------------------- expenses */

.expense-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--sp-3);
  align-items: center;
  padding-block: var(--sp-2);
  border-bottom: 1px dashed var(--line);
}

.expense-row:last-child { border-bottom: none; }
.expense-row__amount { color: var(--terracotta); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------ invoice ledger */

/* The table has eight columns; on a phone it scrolls sideways inside its own
   box rather than forcing the whole page to. */
.ledger-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.ledger {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.ledger th {
  text-align: start;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--ink-faint);
  padding: var(--sp-2);
  border-bottom: 1.5px solid var(--line);
  white-space: nowrap;
}

.ledger td {
  padding: var(--sp-2);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.ledger tr:hover td { background: var(--cream); }
.ledger .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger .is-cancelled td { opacity: 0.55; text-decoration: line-through; }
.ledger__code { font-weight: 700; color: var(--forest); direction: ltr; }
.ledger__actions { display: flex; gap: var(--sp-2); flex-wrap: nowrap; }

/* --------------------------------------- multi-select days */

.field select[multiple] {
  min-height: 168px;
  padding: var(--sp-2);
}

.field select[multiple] option {
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
}
