/* ==========================================================================
   Afripart Sourcing — admin dashboard
   Loaded after style.css; reuses its tokens.
   ========================================================================== */

:root { --side: 262px; }

/* A distinct tint from the pure-white cards, so panels actually read as
   panels instead of white-on-white with a hairline border. */
body.admin { background: #eef0e7; }

/* --- Shell ---------------------------------------------------------------- */
.admin-shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }

/* Explicit placement, not DOM-order auto-placement: .admin-scrim is a third
   child of .admin-shell (fixed-positioned, so out of flow) — without pinning
   these two to their columns, any extra in-flow child would auto-place into
   an implicit 3rd track and shove .admin-main onto a squeezed second row. */
.admin-side { grid-column: 1; }
.admin-main { grid-column: 2; }

.admin-side {
  background: var(--surface); border-right: 1px solid var(--line-2);
  display: flex; flex-direction: column; height: 100vh; overflow-y: auto;
  position: sticky; top: 0;
}
.admin-brand { padding: 22px 22px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 12px; }
.admin-brand img { height: 40px; }
.admin-brand .n { font-family: var(--display); font-size: 1.06rem; letter-spacing: .05em; text-transform: uppercase; line-height: 1.1; }
.admin-brand .s { font-size: .62rem; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }

.admin-nav { padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.admin-nav .group {
  font-size: .66rem; letter-spacing: .24em; text-transform: uppercase; color: var(--faint);
  padding: 18px 12px 8px;
}
.admin-nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  color: var(--muted); font-size: .92rem; transition: all .25s var(--ease); position: relative;
}
.admin-nav a svg { width: 17px; height: 17px; flex: none; opacity: .75; }
.admin-nav a:hover { background: rgba(20, 24, 16, .04); color: var(--text); }
.admin-nav a.active { background: rgba(138, 111, 16, .1); color: var(--gold); }
.admin-nav a.active svg { opacity: 1; }
.admin-nav a.active::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px;
  background: var(--brand-grad); border-radius: 2px;
}
.admin-nav .count {
  margin-left: auto; background: var(--brand-grad); color: #0a0c0a; font-size: .70rem; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px;
}
.admin-nav .count.quiet { background: rgba(20, 24, 16, .08); color: var(--muted); font-weight: 500; }

.admin-side-foot { padding: 16px; border-top: 1px solid var(--line-2); }

/* --- Main ----------------------------------------------------------------- */
.admin-main { min-width: 0; display: flex; flex-direction: column; }
.admin-top {
  position: sticky; top: 0; z-index: 50; background: rgba(255, 255, 255, .92); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line-2); padding: 18px 30px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.admin-top h1 { font-size: 1.5rem; }
.admin-top .sub { font-size: .82rem; color: var(--faint); letter-spacing: .1em; text-transform: uppercase; }
.admin-body { padding: 30px; flex: 1; }
.admin-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.admin-burger {
  display: none; width: 42px; height: 42px; border: 1px solid var(--line-2); border-radius: 10px;
  background: none; cursor: pointer; align-items: center; justify-content: center; flex-direction: column; gap: 4px;
}
.admin-burger i { width: 16px; height: 1px; background: var(--text); display: block; }

/* --- Stat cards ----------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 30px; }
.stat {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: 0 3px 14px -6px rgba(20, 24, 16, .14);
  padding: 22px; position: relative; overflow: hidden; transition: border-color .3s var(--ease);
}
.stat:hover { border-color: var(--gold-line); }
.stat::after {
  content: ""; position: absolute; right: -28px; top: -28px; width: 92px; height: 92px; border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 210, 20, .12), transparent 70%);
}
.stat .k { font-size: .68rem; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.stat .k svg { width: 14px; height: 14px; color: var(--gold); }
.stat .v { font-family: var(--display); font-size: 2.3rem; line-height: 1; }
.stat .d { font-size: .80rem; color: var(--muted); margin-top: 8px; }
.stat .d.up { color: #5f7a0a; }

/* --- Panels / cards ------------------------------------------------------- */
.card-panel {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: 0 3px 14px -6px rgba(20, 24, 16, .14); overflow: hidden;
}
.card-panel > header {
  padding: 18px 22px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.card-panel > header h2 { font-size: 1.15rem; }
.card-panel .pad { padding: 22px; }
.cols { display: grid; gap: 20px; }
.cols-2 { grid-template-columns: 1.6fr 1fr; }
.cols-even { grid-template-columns: repeat(2, 1fr); }

/* --- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 640px; }
table.data th {
  text-align: left; padding: 13px 18px; font-size: .68rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--faint); border-bottom: 1px solid var(--line-2); font-weight: 500; white-space: nowrap;
  background: var(--ink-2);
}
table.data td { padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr { transition: background .2s var(--ease); }
table.data tbody tr:hover { background: rgba(20, 24, 16, .025); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .thumb { width: 54px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line-2); }
table.data .strong { color: var(--text); font-weight: 400; }
table.data .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: none;
  display: grid; place-items: center; color: var(--muted); cursor: pointer; transition: all .25s var(--ease);
}
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn:hover { border-color: var(--gold); color: var(--gold); }
.icon-btn.danger:hover { border-color: #ff6e6e; color: #ff6e6e; }

/* --- Status pills --------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 100px;
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; border: 1px solid var(--line-2); color: var(--muted);
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill--new, .pill--pending, .pill--open { color: var(--gold); border-color: var(--gold-line); background: rgba(138, 111, 16, .05); }
.pill--available, .pill--published, .pill--delivered, .pill--called, .pill--fulfilled { color: #5f7a0a; border-color: rgba(95, 122, 10, .35); background: rgba(95, 122, 10, .05); }
.pill--sold, .pill--closed, .pill--cancelled, .pill--missed, .pill--out_of_stock { color: #c23b3b; border-color: rgba(194, 59, 59, .3); background: rgba(194, 59, 59, .05); }
.pill--reserved, .pill--draft, .pill--quoted, .pill--contacted, .pill--in_transit { color: #a8650c; border-color: rgba(168, 101, 12, .3); background: rgba(168, 101, 12, .05); }

/* --- Forms ---------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { margin-bottom: 28px; }
.form-section > h3 {
  font-size: .74rem; letter-spacing: .22em; text-transform: uppercase; color: var(--gold);
  font-family: var(--sans); font-weight: 500; padding-bottom: 12px; margin-bottom: 20px; border-bottom: 1px solid var(--line);
}
.form-actions {
  position: sticky; bottom: 0; background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line-2); padding: 16px 0; margin-top: 26px;
  display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap;
}
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 11px 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 44px; height: 24px; border-radius: 100px; background: var(--raised); border: 1px solid var(--line-2);
  position: relative; transition: all .3s var(--ease); flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: all .3s var(--ease);
}
.switch input:checked + .track { background: var(--brand-grad); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(20px); background: #0a0c0a; }

/* Image picker */
.drop {
  border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 26px; text-align: center;
  color: var(--muted); cursor: pointer; transition: all .3s var(--ease); background: var(--ink-2);
}
.drop:hover { border-color: var(--gold); color: var(--gold); }
.drop svg { width: 26px; height: 26px; margin-bottom: 10px; }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; margin-top: 16px; }
.thumb-item { position: relative; aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb-item img { width: 100%; height: 100%; object-fit: cover; }
.thumb-item .tools { position: absolute; inset: auto 0 0 0; display: flex; gap: 4px; padding: 6px; background: linear-gradient(to top, rgba(0,0,0,.85), transparent); }
.thumb-item .tools button, .thumb-item .tools label {
  flex: 1; font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; padding: 4px;
  border: 1px solid rgba(255,255,255,.2); border-radius: 5px; background: rgba(0,0,0,.5); color: #fff; cursor: pointer;
}
.thumb-item.is-primary { border-color: var(--gold); }
.thumb-item .flag {
  position: absolute; top: 6px; left: 6px; background: var(--brand-grad); color: #0a0c0a;
  font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; padding: 3px 7px; border-radius: 4px; font-weight: 700;
}
.thumb-item .thumb-remove {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.6); color: #fff;
  display: grid; place-items: center; cursor: pointer; font-size: .9rem; line-height: 1; padding: 0;
}
.thumb-item .thumb-remove:hover { background: rgba(200,40,40,.9); border-color: transparent; }

/* --- "+" multi-image uploader --------------------------------------------- */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.slot {
  position: relative; aspect-ratio: 1; border: 2px dashed var(--line-2); border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--ink-2); color: var(--muted); cursor: pointer; overflow: hidden;
  transition: border-color .25s var(--ease), color .25s var(--ease), background .25s var(--ease);
}
.slot:hover { border-color: var(--gold); color: var(--gold); background: rgba(138, 111, 16, .05); }
.slot .plus { font-size: 2rem; line-height: 1; font-weight: 300; }
.slot .cap { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; text-align: center; padding: 0 6px; }
.slot.filled { border-style: solid; border-color: var(--gold-line); cursor: default; }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot [hidden] { display: none !important; }
.slot-remove {
  position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .65); color: #fff; font-size: 1rem; line-height: 1; cursor: pointer; padding: 0;
}
.slot-remove:hover { background: rgba(200, 40, 40, .95); }

/* --- Mini bar chart ------------------------------------------------------- */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 150px; padding-top: 10px; }
.chart .bar { flex: 1; background: var(--brand-grad); border-radius: 3px 3px 0 0; min-height: 3px; opacity: .8; position: relative; transition: opacity .25s var(--ease); }
.chart .bar:hover { opacity: 1; }
.chart .bar span {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 6px;
  background: var(--raised); border: 1px solid var(--line-2); padding: 3px 8px; border-radius: 5px;
  font-size: .70rem; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease);
}
.chart .bar:hover span { opacity: 1; }
.chart-labels { display: flex; gap: 5px; margin-top: 8px; }
.chart-labels span { flex: 1; text-align: center; font-size: .64rem; color: var(--faint); }

/* --- Ranked list ---------------------------------------------------------- */
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: flex; align-items: center; gap: 13px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rank li:last-child { border-bottom: 0; }
.rank .n { font-family: var(--display); font-size: 1.1rem; color: var(--faint); width: 22px; flex: none; }
.rank img { width: 46px; height: 34px; object-fit: cover; border-radius: 6px; flex: none; }
.rank .t { flex: 1; min-width: 0; }
.rank .t b { display: block; font-weight: 400; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .t span { font-size: .78rem; color: var(--faint); }
.rank .v { font-size: .88rem; color: var(--gold); white-space: nowrap; }

/* --- Admin chat ----------------------------------------------------------- */
.admin-chat { display: grid; grid-template-columns: 300px 1fr; min-height: 640px; }
.admin-chat .chat-side { border-right: 1px solid var(--line-2); }

/* --- Login ---------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 20px; position: relative; overflow: hidden; }
.login-wrap::before {
  content: ""; position: absolute; width: 700px; height: 700px; top: -280px; right: -220px;
  background: radial-gradient(circle, rgba(200, 210, 20, .1), transparent 65%); filter: blur(30px);
}
.login-card {
  position: relative; width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 38px; box-shadow: var(--shadow);
}

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 1100px) {
  .cols-2, .cols-even { grid-template-columns: 1fr; }
  .admin-chat { grid-template-columns: 1fr; }
}
/* Always out of grid flow: as a plain, unpositioned div it would otherwise
   land as a third auto-placed item in the 2-column .admin-shell grid and
   push .admin-main onto a squeezed implicit row — only masked below 900px
   because .admin-side becoming fixed there happens to leave .admin-main as
   the sole grid item again. */
.admin-scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 199; opacity: 0;
  pointer-events: none; transition: opacity .3s var(--ease);
}
.admin-scrim.show { opacity: 1; pointer-events: auto; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-main { grid-column: 1; }
  .admin-side {
    position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 200;
    transform: translateX(-100%); transition: transform .4s var(--ease);
  }
  .admin-side.open { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .7); }
  .admin-burger { display: flex; }
  .admin-body { padding: 20px 16px; }
  .admin-top { padding: 14px 16px; }
  .admin-top h1 { font-size: 1.2rem; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-chat .chat-side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 220px; }
}
