/* ==========================================================================
   CubeMarket — Admin panel
   Loaded *after* style.css. It adds only layout and data-density primitives;
   every colour, radius, shadow and font comes from the same tokens as the
   storefront so the admin never reads as a different product.
   ========================================================================== */

.admin-body { background: var(--cm-bg); }

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */
.admin-shell { display: flex; flex-direction: column; min-height: 100vh; }

.admin-sidebar {
  display: flex;
  flex-direction: column;
  flex: none;
  width: 100%;
  background: var(--cm-charcoal);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem var(--gutter);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.admin-login__mark {
  display: block;
  width: 3.25rem;
  margin-inline: auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.admin-login__mark img { width: 100%; height: auto; display: block; }
.admin-sidebar__tag {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--cm-gold);
}

.admin-nav {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-nav::-webkit-scrollbar { display: none; }

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: none;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  transition: background-color var(--t-base), color var(--t-base);
}
.admin-nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.admin-nav a.is-active { background: rgba(200, 168, 107, 0.14); color: var(--cm-gold); }
.admin-nav svg { width: 1.0625rem; height: 1.0625rem; flex: none; }

/* Outstanding work, not decoration — it uses the warning colour so it reads
   as "do something" rather than as a count. */
.admin-nav__badge {
  margin-left: auto;
  min-width: 1.25rem;
  padding: 0 0.375rem;
  border-radius: var(--radius-pill);
  background: var(--cm-warning);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.25rem;
  text-align: center;
}

.admin-sidebar__foot {
  padding: 0.75rem var(--gutter) 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.admin-sidebar__user { display: flex; align-items: center; gap: 0.75rem; }
.admin-avatar {
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem;
  flex: none;
  border-radius: 50%;
  background: rgba(200, 168, 107, 0.18);
  color: var(--cm-gold);
  font-size: 0.8125rem;
  font-weight: 500;
}
.admin-sidebar__user .name { font-size: 0.8125rem; color: #fff; }
.admin-sidebar__user .mail { font-size: 0.6875rem; color: rgba(255, 255, 255, 0.45); }
.admin-signout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.55);
  transition: background-color var(--t-base), color var(--t-base);
}
.admin-signout:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.admin-signout svg { width: 1rem; height: 1rem; }

.admin-main { flex: 1; min-width: 0; padding: 2rem var(--gutter) 3.5rem; }

.admin-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}
.admin-topbar .h3 { font-size: 1.75rem; }
.admin-topbar__actions { display: flex; flex-wrap: wrap; gap: 0.625rem; }

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */
.admin-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(60rem 40rem at 50% -10%, rgba(200, 168, 107, 0.12), transparent 60%),
    var(--cm-bg);
}
.admin-login__card {
  width: 100%;
  max-width: 26rem;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-modal);
  padding: 2.5rem 2rem;
  animation: cm-fade-in 0.7s var(--ease-out) both;
}
.admin-login__card .brand { justify-content: center; font-size: 1.75rem; }
.admin-login__lock {
  display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem;
  margin-inline: auto;
  border-radius: 50%;
  background: var(--cm-sand);
  color: var(--cm-gold);
}
.admin-login__lock svg { width: 1.125rem; height: 1.125rem; }

/* --------------------------------------------------------------------------
   Stat cards
   -------------------------------------------------------------------------- */
.stat-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 1.5rem;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: transform var(--t-slow) var(--ease-out), box-shadow var(--t-slow) var(--ease-out);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-card-hover); }
.stat-card__top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.stat-card__label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--cm-muted); }
.stat-card__icon {
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem;
  border-radius: var(--radius-md);
  background: var(--cm-sand);
  color: var(--cm-gold);
}
.stat-card__icon svg { width: 1.125rem; height: 1.125rem; }
.stat-card__value {
  margin-top: 1rem;
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: -1px;
  line-height: 1.1;
}
.stat-card__foot { margin-top: 0.5rem; font-size: 0.75rem; color: var(--cm-muted); }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap {
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; min-width: 44rem; border-collapse: collapse; }
.table th {
  padding: 0.875rem 1.25rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cm-muted);
  background: var(--cm-bg);
  border-bottom: 1px solid var(--cm-border);
  white-space: nowrap;
}
.table td {
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--cm-border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--t-base); }
.table tbody tr:hover { background: var(--cm-bg); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

.table-thumb {
  width: 3rem; height: 3rem;
  flex: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--cm-border);
  background: var(--cm-sand);
}
.table-thumb img { width: 100%; height: 100%; object-fit: cover; }

.cell-product { display: flex; align-items: center; gap: 0.875rem; min-width: 15rem; }
.cell-product .t { font-weight: 500; }
.cell-product .s { font-size: 0.75rem; color: var(--cm-muted); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8125rem; }

/* Card list — the mobile presentation of a table */
.record-list { display: none; flex-direction: column; }
.record-list__item { padding: 1.125rem 1.25rem; border-bottom: 1px solid var(--cm-border); }
.record-list__item:last-child { border-bottom: 0; }
.record-list__row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.625rem; font-size: 0.8125rem; }
.record-list__row .k { color: var(--cm-muted); }

/* --------------------------------------------------------------------------
   Forms (admin)
   -------------------------------------------------------------------------- */
.admin-form-grid { display: grid; gap: 1.5rem; align-items: start; }

.form-section + .form-section { margin-top: 1.5rem; }
.form-section__title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  letter-spacing: -0.2px;
}
.form-section__hint { margin-top: 0.25rem; font-size: 0.8125rem; color: var(--cm-muted); }
.form-section__body { margin-top: 1.5rem; }

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: rgba(245, 245, 242, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--cm-border);
  border-radius: var(--radius-card);
}

/* Existing gallery images, each with a remove toggle */
.gallery-manage {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 0.625rem;
  margin-bottom: 0.875rem;
}
.gallery-manage__item {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--cm-border);
  border-radius: var(--radius-sm);
  background: var(--cm-surface);
  cursor: pointer;
}
.gallery-manage__item img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.gallery-manage__remove {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 3px 0;
  background: rgba(17, 17, 17, 0.78);
  color: #fff;
  font-size: 0.5625rem;
  letter-spacing: 0.04em;
}
.gallery-manage__remove input { width: 0.75rem; height: 0.75rem; accent-color: var(--cm-danger); }
.gallery-manage__tag {
  position: absolute;
  top: 4px; left: 4px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(17, 17, 17, 0.75);
  color: #fff;
  font-size: 0.5rem;
  letter-spacing: 0.04em;
}
/* Ticking the box dims the image, so pending deletions are obvious on save. */
.gallery-manage__item:has(input:checked) { opacity: 0.4; border-color: var(--cm-danger); }
.gallery-manage__item:has(input:checked) .gallery-manage__remove { background: var(--cm-danger); }

/* Per-format upload slots */
.format-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 0.875rem;
}
.format-slot {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  border: 1px solid var(--cm-border);
  border-radius: var(--radius-md);
  background: var(--cm-bg);
  transition: border-color var(--t-base), background-color var(--t-base);
}
.format-slot.is-filled { border-color: rgba(5, 150, 105, 0.35); background: var(--cm-surface); }
.format-slot__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.format-slot__name {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: -0.2px;
}
.format-slot__hint { margin-top: 0.25rem; font-size: 0.6875rem; color: var(--cm-muted); line-height: 1.4; }
.format-slot__file {
  margin-top: 0.625rem;
  font-size: 0.6875rem;
  color: var(--cm-ink);
  word-break: break-all;
  line-height: 1.4;
}
.format-slot .filedrop--slim {
  margin-top: auto;
  padding: 0.75rem 0.625rem;
  gap: 0.125rem;
}
.format-slot .filedrop--slim .filedrop__title { font-size: 0.75rem; }
.format-slot .filedrop--slim .filedrop__name { font-size: 0.625rem; }

.preview-thumb {
  width: 100%;
  max-width: 16rem;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--cm-border);
  background: var(--cm-sand);
}
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Top-selling list */
.rank-list { display: flex; flex-direction: column; }
.rank-list__item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--cm-border);
}
.rank-list__item:last-child { border-bottom: 0; }
.rank-list__n {
  display: grid; place-items: center;
  width: 1.5rem; height: 1.5rem;
  flex: none;
  border-radius: 50%;
  background: var(--cm-sand);
  color: var(--cm-gold);
  font-size: 0.6875rem;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .table-wrap--responsive .table-scroll { display: none; }
  .table-wrap--responsive .record-list { display: flex; }
}

@media (min-width: 768px) {
  .admin-shell { flex-direction: row; }
  .admin-sidebar {
    position: sticky;
    top: 0;
    width: 16rem;
    height: 100vh;
  }
  .admin-nav { flex-direction: column; overflow: visible; flex: 1; padding-block: 1rem; }
  .admin-main { padding: 2.5rem 2rem 4rem; }
}

@media (min-width: 1100px) {
  .admin-form-grid--split { grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr); gap: 1.5rem; }
  .admin-main { padding-inline: 2.5rem; }
  #dash-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); }
}

/* --------------------------------------------------------------------------
   Payment settings
   -------------------------------------------------------------------------- */
/* Vertical rhythm for a page made of stacked setting cards. */
.stack-lg { display: flex; flex-direction: column; gap: 1.5rem; }

/* Checkbox + explanation, sized so the label is the click target. */
.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--cm-border);
  border-radius: var(--radius-md);
  background: var(--cm-bg);
  cursor: pointer;
  line-height: 1.5;
}
.switch-row:hover { border-color: var(--cm-gold); }
.switch-row input { margin-top: 0.1875rem; width: 1rem; height: 1rem; flex: none; accent-color: var(--cm-gold); }
