/* ============================================================
   The Design Factory : Asset Manager — shared design tokens
   ============================================================ */

:root {
  /* Neutral grey scale — the entire UI lives on this. */
  --grey-0: #ffffff;
  --grey-25: #fbfbfb;
  --grey-50: #f6f6f6;
  --grey-100: #eeeeee;
  --grey-150: #e6e6e6;
  --grey-200: #dcdcdc;
  --grey-300: #c6c6c6;
  --grey-400: #a3a3a3;
  --grey-500: #808080;
  --grey-600: #5f5f5f;
  --grey-700: #454545;
  --grey-800: #2b2b2b;
  --grey-900: #161616;
  --ink: #111111;

  --danger: #b3261e;
  --danger-bg: #fbeceb;
  --success: #1b7a3d;
  --success-bg: #eaf6ee;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.10);

  --font: 'Cabinet Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --content-width: 800px;
  --sidebar-width: 268px;

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--grey-900);
  background: var(--grey-25);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.55;
}

img { max-width: 100%; }

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

p { margin: 0; }

button {
  font-family: inherit;
  cursor: pointer;
}

.icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font);
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--ink);
  color: var(--grey-0);
}
.btn-primary:hover { background: var(--grey-800); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border-color: var(--grey-200);
  color: var(--grey-800);
}
.btn-ghost:hover { background: var(--grey-100); border-color: var(--grey-300); }

.btn-subtle {
  background: var(--grey-100);
  color: var(--grey-800);
}
.btn-subtle:hover { background: var(--grey-150); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--grey-600);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--grey-100); color: var(--grey-900); }
.btn-icon.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ---------- Forms ---------- */

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--grey-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field { margin-bottom: 18px; }
.field-row { display: flex; gap: 14px; }
.field-row > .field { flex: 1; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--grey-200);
  background: var(--grey-0);
  font-family: var(--font);
  font-size: 14.5px;
  color: var(--grey-900);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--grey-500);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}
textarea { resize: vertical; min-height: 90px; }

input[type="color"] {
  width: 44px;
  height: 38px;
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--grey-200);
  background: var(--grey-0);
}

/* Custom slider — native range chrome replaced to match the platform's
   own controls (flat track, round ink-coloured thumb, filled progress).
   --range-progress is kept in sync with the current value by admin.js
   (falls back to 0% so the track still renders correctly before JS runs). */
input[type="range"] {
  --range-progress: 0%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 100px;
  background: linear-gradient(to right, var(--ink) var(--range-progress), var(--grey-150) var(--range-progress));
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 100px;
  background: var(--grey-150);
}
input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 100px;
  background: var(--ink);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--grey-0);
  box-shadow: 0 0 0 1px var(--grey-200), 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--grey-0);
  box-shadow: 0 0 0 1px var(--grey-200), 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus-visible::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]:hover::-moz-range-thumb,
input[type="range"]:focus-visible::-moz-range-thumb { transform: scale(1.12); }
input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--grey-150), 0 1px 2px rgba(0, 0, 0, 0.15); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--grey-150), 0 1px 2px rgba(0, 0, 0, 0.15); }

.help-text {
  font-size: 12.5px;
  color: var(--grey-500);
  margin-top: 6px;
  text-transform: none;
  letter-spacing: 0;
}

/* ---------- Cards / surfaces ---------- */

.card {
  background: var(--grey-0);
  border: 1px solid var(--grey-150);
  border-radius: var(--radius-md);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--grey-100);
  color: var(--grey-600);
}
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--grey-100); color: var(--grey-500); }

/* ---------- Toasts ---------- */

#toast-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--grey-900);
  color: var(--grey-0);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.2s ease;
}
.toast.error { background: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Auth screens ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grey-25);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 36px;
  background: var(--grey-0);
  border: 1px solid var(--grey-150);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.auth-logo {
  width: 140px;
  color: var(--ink);
  margin-bottom: 28px;
}
.auth-card h1 {
  font-size: 19px;
  margin-bottom: 6px;
}
.auth-sub {
  font-size: 13.5px;
  color: var(--grey-500);
  margin-bottom: 28px;
}
.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.auth-submit { width: 100%; justify-content: center; margin-top: 6px; }
.auth-footer {
  margin-top: 22px;
  font-size: 12.5px;
  color: var(--grey-400);
  text-align: center;
}

/* ============================================================
   Shell layout — shared by admin page-builder and client portal
   ============================================================ */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--grey-0);
  border-right: 1px solid var(--grey-150);
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  padding: 0 4px;
}
.sidebar-logo { width: 108px; color: var(--ink); }

.sidebar-client {
  font-size: 12px;
  color: var(--grey-500);
  padding: 0 4px 20px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--grey-150);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Live drop-position placeholder while dragging to reorder pages — mirrors
   .block-chrome.dragging in admin.css (see assets/js/reorder.js). */
.nav-item.dragging {
  opacity: 0.4;
  outline: 2px dashed var(--grey-300);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.nav-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--grey-700);
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--grey-50); color: var(--grey-900); }
.nav-link.active {
  background: var(--grey-100);
  color: var(--grey-900);
  font-weight: 600;
}
.nav-drag-handle {
  /* Taken out of flow so it never shifts .nav-link's position — otherwise
     the admin sidebar's page titles sit ~20px further right than the
     client sidebar's (same markup minus this handle), even though the
     handle is invisible until hover. */
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--grey-300);
  cursor: grab;
  opacity: 0;
  transition: opacity 0.15s ease;
  display: flex;
}
.nav-item:hover .nav-drag-handle { opacity: 1; }
.nav-item:hover .js-nav-rename-toggle,
.nav-item:hover .js-nav-delete { opacity: 1 !important; }
.js-nav-rename-form { flex: 1; }
.js-nav-rename-form input { width: 100%; }

.sidebar-footer {
  border-top: 1px solid var(--grey-150);
  padding-top: 16px;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-footer-name {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px 2px;
  color: var(--grey-800);
}
.sidebar-footer-email {
  font-size: 12px;
  padding: 0 12px 8px;
  color: var(--grey-400);
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--grey-600);
}
.sidebar-link:hover { background: var(--grey-50); color: var(--grey-900); }

.main {
  flex: 1;
  min-width: 0;
  padding: 56px 48px 120px;
}

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--grey-150);
  background: var(--grey-0);
  position: sticky;
  top: 0;
  z-index: 20;
}
.mobile-topbar .sidebar-logo { width: 100px; }
.sidebar-backdrop { display: none; }

@media (max-width: 880px) {
  body { overflow-x: hidden; }
  .mobile-topbar { display: flex; }
  .shell { flex-direction: column; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 40;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 15, 0.35);
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
  .main { padding: 28px 20px 90px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .block-pair-group.cols-2 { grid-template-columns: 1fr; }
}

.page-header {
  max-width: var(--content-width);
  margin: 0 auto 36px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
}
.page-header h1 { font-size: 26px; }

.column {
  max-width: var(--content-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.empty-state {
  max-width: var(--content-width);
  margin: 80px auto;
  text-align: center;
  color: var(--grey-400);
}
.empty-state .icon { width: 32px; height: 32px; margin-bottom: 14px; color: var(--grey-300); }
.empty-state p { font-size: 14px; }

/* ============================================================
   Block content — identical markup/classes for admin + client.
   Admin-only edit chrome is layered on separately (admin.css).
   ============================================================ */

.block-content-heading {
  padding-top: 20px;
}
.block-content-heading h2 {
  font-size: 28px;
  line-height: 1.25;
}
.block-content-heading.size-sm h2 { font-size: 19px; }
.block-content-heading.size-lg h2 { font-size: 36px; }

.block-content-body p {
  font-size: 15px;
  color: var(--grey-700);
  white-space: pre-wrap;
}

/* Spacer block — purely vertical space, admin sees it via the generic
   hover chrome (dashed outline + toolbar), no special-cased content. */
.block-content-spacer {
  width: 100%;
}

/* Divider block */
.block-content-divider {
  width: 100%;
}
.block-content-divider hr {
  margin: 0;
  border: none;
  width: 100%;
}

/* Media card — shared by Logo and File blocks: a big preview image (or a
   generic icon when there's none) with a name and download chip(s) below.
   Object-fit is set inline per-instance (cover/contain), not hardcoded here. */
.block-pair-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
.block-pair-group.cols-2 {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 720px) {
  .block-pair-group.cols-2 { grid-template-columns: 1fr; }
}

.media-card {
  border: 1px solid var(--grey-150);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--grey-0);
}
.media-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.media-preview img {
  max-width: 100%;
  max-height: 100%;
}
.media-preview img.fit-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-preview img.fit-contain {
  object-fit: contain;
}
.media-meta {
  padding: 16px 18px;
  border-top: 1px solid var(--grey-150);
}
.media-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--grey-900);
  margin-bottom: 10px;
}
.media-formats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.format-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 100px;
  border: 1px solid var(--grey-200);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--grey-700);
  background: var(--grey-0);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.format-chip:hover { border-color: var(--grey-400); background: var(--grey-50); }
.format-chip .ext { color: var(--grey-400); font-weight: 500; text-transform: uppercase; }

/* Colour block */
.colour-grid {
  display: grid;
  /* auto-fit (not auto-fill): with fewer swatches than fit per row,
     auto-fill reserves empty invisible tracks sized by minmax's 1fr,
     so existing swatches only take their share of a fuller row instead
     of stretching — auto-fit collapses the empty tracks so the real
     swatches expand to fill the container regardless of count. */
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.colour-swatch {
  border: 1px solid var(--grey-150);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--grey-0);
  position: relative;
}
.colour-fill {
  height: 96px;
  width: 100%;
  position: relative;
  cursor: pointer;
}
.colour-copy-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.colour-fill:hover .colour-copy-hint { opacity: 1; }
.colour-info {
  padding: 12px 14px;
  font-size: 12px;
  color: var(--grey-600);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.colour-info .label {
  font-size: 13px;
  font-weight: 700;
  color: var(--grey-900);
  margin-bottom: 4px;
}
.colour-info .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.colour-info .row .k { color: var(--grey-400); flex-shrink: 0; }
.colour-info .row .v { flex: 1; text-align: right; }
.copy-row {
  margin: 0 -6px;
  padding: 3px 6px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.copy-row:hover { background: var(--grey-50); }
.copy-row-icon {
  color: var(--grey-300);
  opacity: 0.65;
  flex-shrink: 0;
  transition: opacity 0.12s ease, color 0.12s ease;
}
.copy-row:hover .copy-row-icon { opacity: 1; color: var(--grey-600); }
.pantone-note {
  font-size: 10.5px;
  color: var(--grey-400);
  margin-top: 4px;
  line-height: 1.4;
}

/* File block. The optional group label sits close to its rows (small,
   fixed gap — it reads as this block's own label, not a page heading),
   while the rows/cards themselves keep the larger, consistent row gap
   that also matches the horizontal gap between paired columns. */
.block-content-file {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.file-block-rows {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid var(--grey-150);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--grey-150);
}
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--grey-0);
}
.file-row .file-icon { color: var(--grey-400); }
.file-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--grey-150);
  background: var(--grey-50);
}
.file-row .file-name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--grey-900);
}
.file-row .file-size {
  font-size: 12px;
  color: var(--grey-400);
}
.file-row .download-btn { color: var(--grey-500); }
.file-row .download-btn:hover { color: var(--grey-900); }
.file-block-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--grey-900);
}
