﻿/* ============================================================
   لوحة التحكم — admin panel
   Same brand language as the storefront, tuned for density.
   ============================================================ */

.admin-body {
  /* Cards use --surface, which is lighter than --sea; putting the body on
     --sea-2 would sink them below the page and invert the elevation. */
  background: var(--sea);
  padding-bottom: var(--sp-6);
}

/* --------------------------------------------------- login */

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background: linear-gradient(160deg, var(--sea) 0%, var(--tide-deep) 100%);
}

.login-card {
  width: min(100%, 400px);
  background: var(--surface);
  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(--tide);
}

.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;
  /* A near-black bar, so the amber tab states and light labels below all
     keep the contrast they were designed with. */
  background: var(--abyss);
  color: var(--ink);
  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(--amber); font-size: var(--text-base); }
.admin-header .brand__sub { color: rgba(234, 243, 251, 0.5); }
.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(234, 243, 251, 0.62);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all 0.18s var(--ease);
}

.admin-tab:hover { color: var(--amber-soft); }

.admin-tab[aria-selected='true'] {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

.tab-badge {
  min-width: 19px;
  height: 19px;
  padding-inline: 5px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--amber);
  color: var(--abyss);
  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(--surface);
  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(--amber);
}

.stat--tide::after { background: var(--tide); }
.stat--lagoon::after { background: var(--lagoon); }
.stat--amber::after { background: var(--amber-bright); }

.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(--tide);
  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(--amber) 0%, var(--amber-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(--amber-mist);
  color: var(--amber-bright);
  font-weight: 800;
  font-size: var(--text-xs);
}

.top-item__name { font-weight: 600; font-size: var(--text-sm); color: var(--tide); }
.top-item__qty { font-weight: 800; color: var(--amber-bright); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --------------------------------------------------- orders */

.order-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-inline-start: 4px solid var(--amber);
  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(--amber); background: var(--amber-mist); }
.order-card--confirmed { border-inline-start-color: var(--tide); }
.order-card--preparing { border-inline-start-color: var(--warning); }
.order-card--delivering { border-inline-start-color: var(--lagoon); }
.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(--tide);
  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(--sea);
  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(--surface);
  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(--sea-2); 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(--surface);
  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(--sea-2); }
.admin-item__name { font-weight: 600; color: var(--tide); 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(--amber-bright);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--sea);
  font-size: max(16px, var(--text-sm));
  font-variant-numeric: tabular-nums;
}

.price-input:focus { outline: none; border-color: var(--amber); 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(--lagoon); }
.switch input:checked + .switch__track::after { transform: translateX(-19px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--lagoon); outline-offset: 2px; }

/* -------------------------------------------------- reviews */

.admin-review {
  background: var(--surface);
  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: var(--warning-mist); }

/* ---------------------------------------------------- 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(--surface);
  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(--surface);
  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(--sea-2); 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(--sea-2);
}

.gallery-item img { width: 100%; height: 100%; object-fit: cover; }

.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(3, 9, 16, 0.78);
  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(--tide); color: var(--tide); }

/* ----------------------------------------------- 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(--sea-2); 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); }
