/* ============================================================================
   FNF Mobile — CMS (admin) styles.
   Loaded AFTER styles.css, so it inherits all design tokens (--ink, --clay,
   --surface, --line, shadows, radii) and reuses storefront components
   (.btn, .card, .input, .label, .badge). This file only adds the admin shell:
   the navy left sidebar + content layout + tables + form rows.
   ============================================================================ */

:root { --admin-side-w: 252px; }

* { box-sizing: border-box; }

body.admin {
  margin: 0;
  background: #EEF3FA;
  font-family: 'Manrope', -apple-system, system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ── Shell ───────────────────────────────────────────────────────────────── */
.admin-shell { min-height: 100vh; }

.admin-side {
  position: fixed; inset: 0 auto 0 0;
  width: var(--admin-side-w);
  background: linear-gradient(185deg, #0B1E40 0%, #0A1A38 55%, #081326 100%);
  color: #E7EEF8;
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  overflow-y: auto;
  z-index: 40;
}
.admin-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 18px;
}
.admin-brand img { height: 64px; width: auto; }   /* white logo (fnf-logo-white.png), no "CMS" label */
.admin-brand .sub { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #7E93B6; font-weight: 700; }

.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav .grp {
  font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: #5E739A; padding: 16px 12px 6px;
}
.admin-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 11px;
  color: #C3D1E6; text-decoration: none; font-size: 13.5px; font-weight: 600;
  transition: background 120ms ease, color 120ms ease;
}
.admin-nav a svg { flex: 0 0 auto; opacity: .85; }
.admin-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-nav a.active { background: var(--clay); color: #fff; box-shadow: 0 6px 16px -6px rgba(10,102,194,.8); }
.admin-nav a.active svg { opacity: 1; }
.admin-nav .badge-count {
  margin-left: auto; background: var(--rose); color: #fff;
  font-size: 10px; font-weight: 800; padding: 1px 7px; border-radius: 999px;
}

.admin-side-foot { margin-top: auto; padding: 14px 10px 4px; font-size: 11px; color: #5E739A; }
.admin-side-foot a { color: #9FB2D2; }

/* ── Main column ─────────────────────────────────────────────────────────── */
.admin-main { margin-left: var(--admin-side-w); min-height: 100vh; display: flex; flex-direction: column; }
.admin-topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px; background: rgba(238,243,250,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.admin-topbar h1 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.admin-topbar .crumb { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.admin-topbar .spacer { flex: 1; }
.admin-user { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; }
.admin-user .av {
  width: 34px; height: 34px; border-radius: 999px; background: var(--clay); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
}
.admin-content { padding: 24px 28px 60px; }

/* Hamburger (mobile) */
.admin-burger { display: none; background: none; border: none; cursor: pointer; color: var(--ink); }

/* ── Page header (title + actions) ───────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .ph-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.page-head .ph-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.page-head .spacer { flex: 1; }

/* ── KPI cards ───────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px 18px 16px; box-shadow: var(--shadow-sm); }
.kpi .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 12px; }
.kpi .k-val { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.kpi .k-lab { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; }

/* ── Cards / sections ────────────────────────────────────────────────────── */
.panel { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { font-size: 15px; font-weight: 800; margin: 0; }
.panel-body { padding: 18px 20px; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
/* Grid items default to min-width:auto, so a wide table in a track (Recent Orders, Top products,
   order Items, etc.) refuses to shrink and blows the 2-col grid past the viewport in the ~900-1300px
   band. Letting the tracks shrink to 0 keeps the page width in check; the tables then scroll inside
   their own .tbl-wrap instead of pushing the layout sideways. */
.grid-2 > * { min-width: 0; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* min-width keeps a readable table on narrow screens: below it the table scrolls INSIDE its
   .tbl-wrap instead of cramming columns (which was wrapping the product name onto 3 lines).
   On wider containers width:100% wins, so this is a no-op on desktop. */
table.tbl { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; padding: 11px 14px; font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background 100ms ease; }
table.tbl tbody tr:hover { background: var(--surface); }
/* Thumbnails — sized everywhere they appear (tables AND flex lists like the dashboard),
   flex:none so an oversized source image can't stretch/blow out its container. */
.thumb { flex: none; width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--surface-sunk); border: 1px solid var(--line); }
.tbl .muted { color: var(--muted); }
.row-actions { display: inline-flex; gap: 6px; white-space: nowrap; }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: currentColor; opacity: .9; }
.pill-sage { background: var(--sage-tint); color: var(--sage); }
.pill-ink  { background: var(--surface-sunk); color: var(--ink-2); }
.pill-rose { background: #FBE8E8; color: var(--rose); }
.pill-gold { background: #FBF1DC; color: #9B6E14; }
.pill-clay { background: var(--clay-tint); color: var(--clay-deep); }
.pill-azure  { background: #E1F4FC; color: #0679A8; }
.pill-violet { background: #EDE9FE; color: #6D28D9; }
.pill-slate  { background: #E9EDF3; color: #475569; }
.pill-teal   { background: #D5F0EC; color: #0F766E; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.col-2 { grid-column: 1 / -1; }
.field > label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.input, select.input, textarea.input { height: 44px; border-radius: 11px; font-size: 14px; }
select.input { background: var(--surface-2); cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235A6B88' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; line-height: 1.5; resize: vertical; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--clay); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }

/* image upload preview */
.up { display: flex; align-items: center; gap: 14px; }
.up .preview { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; background: var(--surface-sunk); border: 1px solid var(--line); }

/* repeatable child rows (product editor) */
.rows { display: flex; flex-direction: column; gap: 10px; }
.rrow { display: grid; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.rrow .input { height: 38px; }
/* Column-header row above a repeatable grid — same gap + horizontal padding as .rrow so labels line up over the fields. */
.rrow-head { display: grid; gap: 8px; align-items: end; padding: 0 11px 2px; margin-bottom: 2px; }
.rrow-head span { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.rrow.deleting { opacity: .4; }
.btn-del-row { background: none; border: none; color: var(--rose); cursor: pointer; padding: 6px; border-radius: 8px; }
.btn-del-row:hover { background: #FBE8E8; }

/* Searchable tag picker — type to filter live; a selection becomes a removable tag. */
.combo { position: relative; }
.combo-box { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-height: 44px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.combo-box:focus-within { border-color: var(--ink); }
.combo-input { flex: 1; min-width: 100px; border: none; background: none; outline: none; font-family: inherit; font-size: 14px; color: var(--ink); padding: 6px 4px; }
.combo-input::placeholder { color: var(--muted); }
.combo-input[hidden] { display: none; }
.combo-tag { display: inline-flex; align-items: center; gap: 8px; background: var(--clay-tint); color: var(--clay); font-weight: 600; font-size: 13px; padding: 6px 6px 6px 12px; border-radius: 999px; }
.combo-tag[hidden] { display: none; }
.combo-tag button { border: none; background: none; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 3px; border-radius: 999px; }
.combo-tag button:hover { color: var(--rose); }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); padding: 6px; }
.combo-list[hidden] { display: none; }
.combo-opt { display: block; width: 100%; text-align: left; padding: 9px 12px; border: none; background: none; border-radius: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.combo-opt[hidden] { display: none; }   /* was overridden by .combo-opt display:block — this makes filtering actually hide */
.combo-opt:hover, .combo-opt.active { background: var(--surface-sunk); }
.combo-empty { padding: 10px 12px; font-size: 13px; color: var(--muted); }
.combo-empty[hidden] { display: none; }

/* ── Flash messages ──────────────────────────────────────────────────────── */
.flash { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 600; margin-bottom: 18px; }
.flash-ok   { background: var(--sage-tint); color: var(--sage); border: 1px solid var(--sage-soft); }
.flash-err  { background: #FBE8E8; color: var(--rose); border: 1px solid #F1C9C9; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(185deg, #0B1E40, #081326); padding: 20px; }
.login-card { width: 100%; max-width: 388px; background: var(--surface-2); border-radius: 22px; padding: 34px 32px; box-shadow: var(--shadow-lg); }
.login-card .lg-brand { text-align: center; margin-bottom: 22px; }
.login-card .lg-brand img { height: 44px; }

/* empty state */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ic { opacity: .4; margin-bottom: 10px; }

/* pagination */
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 16px; }
.pager a, .pager span { padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 700; text-decoration: none; color: var(--ink-2); border: 1px solid var(--line); }
.pager .cur { background: var(--clay); color: #fff; border-color: var(--clay); }
.pager .dis { opacity: .4; pointer-events: none; }

/* filter bar */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .input, .toolbar select.input { height: 40px; width: auto; }
.toolbar .grow { flex: 1; min-width: 180px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .admin-side { transform: translateX(-100%); transition: transform 200ms ease; box-shadow: var(--shadow-lg); }
  body.nav-open .admin-side { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-burger { display: inline-flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  /* Repeatable field rows (variants, colours, gallery, nav, order tracking) set their
     column widths inline per grid, so they can't collapse through a normal rule. On small
     screens force one field per line and drop the column-header strip — each field is
     labelled by its own placeholder / inline text. Fixes horizontal overflow on phones. */
  .rrow { grid-template-columns: 1fr !important; }
  .rrow-head { display: none !important; }
  .rrow .btn-del-row { justify-self: start; }
  .rrow [type="color"] { max-width: 120px; }
  /* Let crowded panel headers (e.g. the nav group rename form) wrap instead of overflowing. */
  .panel-head { flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 16px; }
}
