/* ==========================================================================
   Architex — admin / back-office styles
   Same brand tokens, denser and more utilitarian than the storefront.
   ========================================================================== */

.admin-body { background: var(--warm-gray); }

.admin-shell { display: flex; min-height: 100vh; align-items: stretch; }

/* ---- Sidebar ------------------------------------------------------------ */
.admin-side {
  width: 244px; flex: none; background: var(--ink); color: rgba(255,255,255,0.72);
  padding: var(--sp-5) 0; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; display: flex; flex-direction: column;
}
.admin-side .brand { padding: 0 var(--sp-5) var(--sp-6); }
.admin-side .brand .sub {
  display: block; margin-top: var(--sp-2); font-size: var(--fs-xs);
  letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--gold); font-weight: var(--fw-bold);
}
.admin-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 var(--sp-3); }
.admin-nav a {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 10px var(--sp-4); border-radius: var(--r-md);
  font-size: var(--fs-base); font-weight: var(--fw-medium);
  color: rgba(255,255,255,0.72); transition: all var(--transition);
}
.admin-nav a:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.admin-nav a.active {
  background: var(--gold); color: var(--ink); font-weight: var(--fw-bold);
}
.admin-nav .pill {
  font-size: var(--fs-xs); font-weight: var(--fw-black);
  background: rgba(255,255,255,0.14); color: var(--white);
  padding: 1px 8px; border-radius: var(--r-pill);
}
.admin-nav a.active .pill { background: rgba(0,0,0,0.16); color: var(--ink); }
.admin-nav-group {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-caps);
  color: rgba(255,255,255,0.38); font-weight: var(--fw-bold);
  padding: var(--sp-5) var(--sp-4) var(--sp-2);
}
.admin-side-foot {
  margin-top: auto; padding: var(--sp-5) var(--sp-5) 0; font-size: var(--fs-xs);
  border-top: 1px solid rgba(255,255,255,0.12); color: rgba(255,255,255,0.45);
  display: grid; gap: var(--sp-3);
}
.admin-side-foot a { color: var(--gold); }

/* ---- Main --------------------------------------------------------------- */
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  background: var(--white); border-bottom: 1px solid var(--line);
  padding: var(--sp-4) var(--sp-6);
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
}
.admin-topbar h1 { margin: 0; font-size: var(--fs-lg); }
.admin-topbar .sub { font-size: var(--fs-sm); color: var(--ink-muted); }
.admin-topbar .spacer { margin-left: auto; }
.admin-content { padding: var(--sp-6); flex: 1; }
.admin-menu-btn { display: none; background: none; border: 0; cursor: pointer; padding: 4px; }

/* ---- Stat cards --------------------------------------------------------- */
.stats {
  display: grid; gap: var(--sp-4); margin-bottom: var(--sp-6);
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.stat {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--sp-5); position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -18px; bottom: -26px;
  width: 78px; height: 68px; background: var(--gold); opacity: 0.16;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}
.stat .k {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-caps);
  color: var(--ink-faint); font-weight: var(--fw-bold); margin-bottom: var(--sp-2);
}
.stat .v {
  font-size: var(--fs-xl); font-weight: var(--fw-black);
  letter-spacing: -0.028em; line-height: 1;
}
.stat .d { font-size: var(--fs-sm); color: var(--ink-muted); margin-top: 6px; }
.stat-gold { background: var(--gold); border-color: var(--gold-edge); }
.stat-gold::after { background: var(--ink); opacity: 0.1; }
.stat-ink { background: var(--ink); border-color: var(--ink); }
.stat-ink .k { color: rgba(255,255,255,0.6); }
.stat-ink .v { color: var(--white); }
.stat-ink .d { color: rgba(255,255,255,0.7); }

/* ---- Tables ------------------------------------------------------------- */
.table-wrap {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: auto; -webkit-overflow-scrolling: touch;
}
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--warm-gray); text-align: left; white-space: nowrap;
  padding: 11px var(--sp-4); font-size: var(--fs-xs); font-weight: var(--fw-black);
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-muted);
  border-bottom: 1px solid var(--line);
}
table.data thead th a { color: inherit; }
table.data thead th a:hover { color: var(--ink); text-decoration: underline; }
table.data tbody td {
  padding: 11px var(--sp-4); border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tbody tr:hover { background: var(--gold-tint); }
table.data tbody tr.is-off { opacity: 0.62; }
table.data tbody tr.is-off:hover { opacity: 1; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .nowrap { white-space: nowrap; }
table.data .strong { font-weight: var(--fw-bold); color: var(--ink); }
table.data .id {
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-faint);
}
table.data .thumb-xs {
  width: 42px; height: 34px; border: 1px solid var(--line); border-radius: 4px;
  object-fit: contain; background: var(--white); padding: 2px;
}
table.data td .btn { padding: 5px 13px; font-size: var(--fs-xs); }
.table-foot {
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); color: var(--ink-muted);
  border-top: 1px solid var(--line); background: var(--warm-gray);
  display: flex; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
}

/* ---- Filter bar --------------------------------------------------------- */
.filters {
  display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end;
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-5);
}
.filters .field { min-width: 170px; }
.filters .grow { flex: 1; min-width: 220px; }
.filters .actions { display: flex; gap: var(--sp-2); margin-left: auto; }

/* ---- Forms -------------------------------------------------------------- */
.form-section {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--sp-5) var(--sp-6); margin-bottom: var(--sp-5);
}
.form-section > h3 {
  font-size: var(--fs-md); margin: 0 0 var(--sp-2);
  padding-bottom: var(--sp-3); border-bottom: 1px solid var(--line);
}
.form-section > .hint {
  font-size: var(--fs-sm); color: var(--ink-muted); margin: 0 0 var(--sp-5);
}
.fields {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.fields .span-2 { grid-column: span 2; }
.fields .span-all { grid-column: 1 / -1; }
.field .help { font-size: var(--fs-xs); color: var(--ink-faint); }
.checkline { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-base); }
.checkline input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--ink); }

.sticky-actions {
  position: sticky; bottom: 0; z-index: 30;
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5);
  display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center;
  box-shadow: var(--shadow-md);
}
.sticky-actions .spacer { margin-left: auto; }

/* ---- Spec key/value editor ---------------------------------------------- */
.kv-row {
  display: grid; grid-template-columns: 230px 1fr 40px;
  gap: var(--sp-3); align-items: start; margin-bottom: var(--sp-3);
}
.kv-row textarea { min-height: 44px; }
.kv-del {
  border: 1.5px solid var(--line-strong); background: var(--white);
  border-radius: var(--r-md); height: 44px; cursor: pointer;
  color: var(--ink-muted); font-size: var(--fs-md); line-height: 1;
}
.kv-del:hover { border-color: var(--danger); color: var(--danger); }

/* ---- Image manager ------------------------------------------------------ */
.img-manager { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.img-tile {
  width: 150px; border: 1.5px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; background: var(--white); position: relative;
}
.img-tile.primary { border-color: var(--gold-edge); box-shadow: 0 0 0 2px var(--gold-tint); }
.img-tile .frame {
  height: 108px; display: flex; align-items: center; justify-content: center;
  background: var(--warm-gray);
}
.img-tile .frame img { max-height: 100%; max-width: 100%; object-fit: contain; }
.img-tile .tools {
  display: flex; gap: 4px; padding: 6px; border-top: 1px solid var(--line);
  font-size: var(--fs-xs); justify-content: space-between; align-items: center;
}
.img-tile .tools button {
  border: 0; background: none; cursor: pointer; color: var(--ink-muted);
  font-size: var(--fs-xs); font-weight: var(--fw-semi); padding: 2px 4px;
}
.img-tile .tools button:hover { color: var(--ink); text-decoration: underline; }
.img-tile .tools .is-primary { color: var(--warn); font-weight: var(--fw-bold); }

/* ---- Data-quality checklist -------------------------------------------- */
.dq-group { margin-bottom: var(--sp-6); }
.dq-group > header {
  display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.dq-group > header h3 { margin: 0; font-size: var(--fs-md); }
.dq-item {
  display: grid; grid-template-columns: 26px 1fr auto; gap: var(--sp-4);
  align-items: start; padding: var(--sp-4) var(--sp-5);
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-md); margin-bottom: var(--sp-3);
}
.dq-item.done { background: var(--warm-gray); opacity: 0.72; }
.dq-item.done .dq-title { text-decoration: line-through; color: var(--ink-muted); }
.dq-check {
  width: 22px; height: 22px; margin-top: 1px; padding: 0; cursor: pointer;
  border: 2px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--white); color: var(--ink);
  font-size: 13px; font-weight: var(--fw-black); line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.dq-check:hover { border-color: var(--ink); }
.dq-check.is-done { background: var(--gold); border-color: var(--gold-edge); }
.dq-title { font-weight: var(--fw-bold); font-size: var(--fs-base); margin-bottom: 3px; }
.dq-detail { font-size: var(--fs-sm); color: var(--ink-muted); line-height: 1.55; }
.dq-side { display: grid; gap: 6px; justify-items: end; }
.progress {
  height: 8px; border-radius: var(--r-pill); background: var(--warm-gray-2);
  overflow: hidden; margin: var(--sp-3) 0 var(--sp-5);
}
.progress > span { display: block; height: 100%; background: var(--gold); }

/* ---- Order detail ------------------------------------------------------- */
.admin-split {
  display: grid; gap: var(--sp-5);
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.9fr);
  align-items: start;
}
.mini-list { list-style: none; margin: 0; padding: 0; font-size: var(--fs-sm); }
.mini-list li {
  display: flex; justify-content: space-between; gap: var(--sp-4);
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.mini-list li:last-child { border-bottom: 0; }
.mini-list .k { color: var(--ink-muted); }
.mini-list .v { font-weight: var(--fw-semi); text-align: right; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: var(--sp-5); background: var(--warm-gray); position: relative; overflow: hidden;
}
.login-wrap::after {
  content: ""; position: absolute; right: -8%; bottom: -30%;
  width: 40vw; height: 110%; background: var(--gold); opacity: 0.4;
  clip-path: polygon(50% 8%, 100% 100%, 0% 100%);
}
.login-card {
  position: relative; z-index: 2; width: 100%; max-width: 400px;
  background: var(--white); border-radius: var(--r-xl);
  padding: var(--sp-7); box-shadow: var(--shadow-lg);
}

@media (max-width: 1020px) {
  .admin-split { grid-template-columns: 1fr; }
  .fields .span-2 { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-side {
    width: 100%; height: auto; position: static; display: none; padding-bottom: var(--sp-5);
  }
  .admin-side.open { display: flex; }
  .admin-menu-btn { display: inline-flex; }
  .admin-content { padding: var(--sp-4); }
  .admin-topbar { padding: var(--sp-3) var(--sp-4); }
  .kv-row { grid-template-columns: 1fr; }
  .kv-del { width: 90px; }
}
