/**
 * dashboard.css — the site's back-office (galleries, services, homepage images).
 *
 * Tokens come from dashboard/css/tokens.css, loaded BEFORE this file.
 * The component vocabulary (.btn-primary, .btn-outline, .btn-quiet, .card,
 * .pill, .empty, .shell-*) is the portal's — same names, same values, so the
 * two admin surfaces Thomas moves between feel like one product.
 * Reference implementation lives in portal/css/portal.css.
 * See docs/design-system.md.
 *
 * Dashboard-specific components (media pool, curated drag list, service forms,
 * slot cards, preview lightbox) have no portal equivalent and are defined here
 * on top of the shared tokens.
 */

:root {
  /* Denser gutter than the site (64px) or portal (48px) — this is a tool, not
     a page. Kept local on purpose; see the note in tokens.css. */
  --pad-x: clamp(18px, 3vw, 32px);
}

/* ============ RESET & BASE ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* The `hidden` attribute must always win — otherwise a later `display:flex`
   rule (e.g. .preview-overlay) silently overrides the UA `[hidden]{display:none}`
   at equal specificity, leaving the overlay permanently on screen. */
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
img, video { display: block; max-width: 100%; }
::selection { background: var(--terracotta-500); color: var(--cream-50); }

h1, h2, h3 { font-weight: 400; letter-spacing: -0.01em; line-height: 1.14; }

/* ============ TYPE HELPERS ============ */
.eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
}
.muted { color: var(--text-muted); }
.error { color: var(--status-overdue); }
.loading { color: var(--text-muted); font-size: 15px; }

/* ============ BUTTONS (shared vocabulary) ============ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  background: var(--terracotta-500);
  color: var(--cream-50);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.25s var(--ease);
}
.btn-primary:hover { background: var(--terracotta-600); }
.btn-primary:disabled { opacity: 0.55; cursor: default; }
.btn-primary:focus-visible { outline: 2px solid var(--terracotta-600); outline-offset: 2px; }

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-900);
  background: var(--cream-50);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.btn-outline:hover { border-color: var(--ink-900); }
.btn-outline:disabled { opacity: 0.55; cursor: default; }
.btn-outline:focus-visible { outline: 2px solid var(--terracotta-500); outline-offset: 2px; }

.btn-quiet {
  display: inline-block;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.02em;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s var(--ease);
}
.btn-quiet:hover { color: var(--accent); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  color: var(--status-overdue);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.btn-danger:hover { border-color: var(--status-overdue); background: var(--status-overdue-bg); }

.btn-block { width: 100%; justify-content: center; }

/* Unsaved-changes marker on the Save button. */
.btn-dirty { box-shadow: var(--focus-ring); }

/* ============ FORMS ============ */
/* One input recipe for the whole app — replaces the four near-identical
   copies this file used to carry (login / curated / services / crm). */
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
  font-family: inherit;
  font-size: 15px;
  /* Explicit, not inherited: these sit inside <label>s that carry the uppercase
     label recipe (weight 500), which the value text must not pick up. */
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink-900);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--cream-50);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--terracotta-500);
  box-shadow: var(--focus-ring);
}
input:disabled, textarea:disabled, select:disabled,
input[readonly] { background: var(--bg-soft); color: var(--text-muted); }
textarea { resize: vertical; }
input[type="checkbox"] { accent-color: var(--terracotta-500); }
input[type="range"] { accent-color: var(--terracotta-500); }

/* The uppercase label recipe, matching the portal's .settings-field label. */
.field-label,
.service-form label,
.slot-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Inline save/upload feedback (the dashboard has no toast component). */
.save-status, .upload-status { font-size: 13px; color: var(--status-paid); }
.upload-status { color: var(--text-muted); margin: 6px 0 14px; }
.save-status.error, .upload-status.error { color: var(--status-overdue); }

.form-error { color: var(--status-overdue); font-size: 13px; margin-top: 14px; }

/* ============ APP SHELL ============ */
/* Same model as the portal: the viewport is the frame and main is the only
   scroller, so the sidebar (and Log out) stay in reach on a long gallery. */
.dash-app {
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* The chrome is injected into placeholder <div>s by js/sidebar.js. Without
   display:contents the placeholder — not the bar/sidebar — would be the flex
   child, and the sidebar would collapse to the height of its nav instead of
   stretching the full column. */
#shell-root, #sidebar-root { display: contents; }

.shell-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px var(--pad-x);
  border-bottom: 1px solid var(--line);
  background: var(--cream-50);
  flex: none;
}

/* Brand lockup — two stacked lines, tracking tuned so the sub matches the
   name's width. Same pair as the portal shell bar (0.244em / 0.16em). */
.shell-brand-block { display: flex; flex-direction: column; line-height: 1.15; }
.shell-brand-name {
  font-weight: 600; letter-spacing: 0.244em; font-size: 14px;
  color: var(--ink-900); white-space: nowrap;
}
.shell-brand-sub {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-muted); margin-top: 2px; white-space: nowrap;
}
/* "Dashboard", separated from the wordmark exactly as the portal separates
   the agency name with .shell-company. */
.shell-context {
  color: var(--text-muted); font-size: 13px; letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-left: 20px; border-left: 1px solid var(--line);
}
.shell-spacer { margin-left: auto; }
.shell-bar-actions { display: flex; align-items: center; gap: 10px; }
/* Button labels are short phrases — never let them break mid-label. */
.shell-bar-actions .btn-outline { white-space: nowrap; }

/* Body = sidebar + main */
.dash-body { display: flex; align-items: flex-start; flex: 1; min-height: 0; }
.dash-sidebar {
  flex: none; width: 210px; align-self: stretch;
  border-right: 1px solid var(--line);
  padding: clamp(24px, 4vw, 40px) 18px;
  display: flex; flex-direction: column;
  height: 100%; overflow-y: auto;
}
.dash-main { flex: 1; min-width: 0; height: 100%; overflow-y: auto; }

/* Sidebar nav — left-border accent on the current page, like the portal. */
.shell-nav { display: flex; flex-direction: column; gap: 4px; }
.shell-nav a {
  color: var(--text-body); font-size: 14px; letter-spacing: 0.01em;
  padding: 8px 12px; border-radius: var(--radius);
  border-left: 2px solid transparent;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.shell-nav a:hover { color: var(--ink-900); background: var(--hover-wash); }
.shell-nav a[aria-current="page"] {
  color: var(--accent); border-left-color: var(--accent); background: var(--accent-wash);
}

/* ============ PAGE HEADINGS ============ */
.page-wrap { padding: clamp(28px, 4vw, 44px) var(--pad-x) 64px; max-width: 1300px; margin: 0 auto; }
.page-wrap--narrow { max-width: 760px; }

.page-head {
  display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  margin-bottom: 32px;
}
.page-head h1 { font-size: clamp(26px, 3vw, 36px); }
.page-head .lede { color: var(--text-body); margin-top: 8px; font-size: 15px; }
.page-head-text { flex: 1; min-width: 0; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.back-link {
  display: inline-block; margin-bottom: 10px;
  color: var(--text-muted); font-size: 13px; letter-spacing: 0.02em;
  transition: color 0.2s var(--ease);
}
.back-link:hover { color: var(--accent); }

.section-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; margin-bottom: 14px;
}
.section-head h2 {
  font-size: 13px; font-weight: 500; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-muted);
}

/* ============ SURFACES ============ */
/* One card recipe. This file used to repeat it six times. */
.card,
.pool-section,
.curated-section,
.service-form,
.slot-card,
.login-card {
  background: var(--cream-50);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.empty {
  border: 1px dashed var(--sand-300);
  border-radius: var(--radius);
  padding: 40px 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

/* ============ CHIPS & PILLS ============ */
.pill {
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--text-body);
  background: var(--cream-50);
  transition: color 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.pill:hover { border-color: var(--sand-400); }
.pill.is-active {
  background: var(--ink-900); color: var(--cream-50); border-color: var(--ink-900);
}

/* ============ LOGIN ============ */
.dash-login {
  min-height: 100vh;
  display: flex; flex-direction: column;
  background: var(--grad-beige-soft);
}
.login-topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 16px var(--pad-x);
  border-bottom: 1px solid var(--line);
  background: var(--cream-50);
}
.login-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 420px;
  padding: 44px 40px 40px;
  box-shadow: 0 24px 60px -32px rgba(31, 28, 24, 0.28);
}
.login-card .eyebrow { display: block; margin-bottom: 12px; }
.login-card h1 { font-size: 30px; margin-bottom: 12px; }
.login-intro { font-size: 15px; line-height: 1.5; color: var(--text-body); margin-bottom: 28px; }
.login-card label {
  display: block;
  font-size: 12px; font-weight: 500; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 7px;
}
.login-card input { width: 100%; margin-bottom: 20px; }
.login-card .btn-primary { margin-top: 4px; }

/* ============ GALLERY PICKER ============ */
/* Rows grouped by the page they feed (Homepage / Services & pricing), so the
   dashboard mirrors the public site's structure. See js/gallery-picker.js. */
.section-block { margin-bottom: 40px; }
.section-block:last-child { margin-bottom: 0; }

.gallery-rows { display: flex; flex-direction: column; gap: 8px; }

.gallery-row {
  display: grid; grid-template-columns: 52px 1fr auto;
  align-items: center; gap: 16px;
  width: 100%; padding: 12px 16px;
  text-align: left; color: inherit;
  background: var(--cream-50);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.gallery-row:hover { border-color: var(--sand-400); background: var(--bg-soft); }
.gallery-row:focus-visible { outline: 2px solid var(--terracotta-500); outline-offset: 2px; }

.grow-thumb {
  width: 52px; height: 52px; object-fit: cover;
  border-radius: var(--radius); background: var(--bg-soft);
}
.grow-thumb--empty { display: block; border: 1px dashed var(--sand-300); }

.grow-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.grow-title {
  font-size: 15px; color: var(--ink-900);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Service number — same tabular treatment as the pricing page's "01". */
.grow-num {
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  letter-spacing: 0.06em; font-variant-numeric: tabular-nums;
  margin-right: 10px;
}
.grow-meta { font-size: 13px; color: var(--text-muted); }

.grow-arrow {
  color: var(--text-muted); font-size: 16px;
  transition: color 0.2s var(--ease), transform 0.2s var(--ease);
}
.gallery-row:hover .grow-arrow { color: var(--accent); transform: translateX(3px); }

/* ============ GALLERY EDITOR ============ */
.editor-layout {
  display: grid; grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.2fr);
  gap: 22px; align-items: start;
}
.pool-section, .curated-section { padding: 20px; }
.pool-filters { display: flex; gap: 6px; }
.pool-filters button { font-size: 12px; padding: 5px 12px; }

/* Media pool */
.pool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.pool-item {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-soft); aspect-ratio: 1;
}
.pool-item img { width: 100%; height: 100%; object-fit: cover; }
.pool-badge {
  position: absolute; top: 5px; left: 5px;
  background: rgba(31, 28, 24, 0.62); color: var(--cream-50);
  font-size: 10px; letter-spacing: 0.06em; padding: 2px 7px; border-radius: var(--radius);
}
.pool-add {
  position: absolute; inset: auto 0 0 0;
  font-size: 12px; letter-spacing: 0.04em;
  background: rgba(31, 28, 24, 0.7); color: var(--cream-50);
  padding: 7px; opacity: 0; transition: opacity 0.2s var(--ease);
}
.pool-item:hover .pool-add, .pool-add:focus-visible { opacity: 1; }

/* Curated list (drag to reorder) */
.curated-list { display: flex; flex-direction: column; gap: 8px; }
.curated-row {
  display: grid; grid-template-columns: auto 60px 1fr auto auto;
  align-items: center; gap: 12px;
  padding: 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--cream-50);
  transition: border-color 0.2s var(--ease), opacity 0.2s var(--ease);
}
.curated-row.dragging { opacity: 0.4; }
.curated-row.drop-target { border-color: var(--accent); box-shadow: var(--focus-ring); }
.curated-row.is-hidden {
  opacity: 0.6;
  background: repeating-linear-gradient(45deg,
    var(--cream-50), var(--cream-50) 8px, var(--cream-100) 8px, var(--cream-100) 16px);
}
.drag-handle { cursor: grab; color: var(--text-muted); font-size: 16px; user-select: none; }
.curated-thumb {
  width: 60px; height: 60px; object-fit: cover;
  border-radius: var(--radius); background: var(--bg-soft);
}
.curated-fields { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.curated-fields input { font-size: 13px; padding: 7px 10px; width: 100%; }
.label-input { color: var(--accent-strong); }
.visible-toggle-wrap {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted); white-space: nowrap;
}
.remove-btn {
  font-size: 12px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--status-overdue);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.remove-btn:hover { border-color: var(--status-overdue); background: var(--status-overdue-bg); }

/* ============ SERVICES EDITOR ============ */
.services-list { display: flex; flex-direction: column; gap: 20px; }
.service-form { padding: 24px 26px; display: flex; flex-direction: column; gap: 16px; }
.service-form label { display: flex; flex-direction: column; gap: 7px; }
.service-form input, .service-form textarea { font-size: 15px; }
.service-form-row { display: flex; gap: 14px; }
.service-form-row .field-num { width: 90px; }
.service-form-row .grow { flex: 1; }
.service-form-foot { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.service-form-foot .field-price { width: 170px; }
.es-divider {
  margin-top: 4px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--text-muted);
}
/* The "(short tag under the price)" asides inside labels must not inherit the
   uppercase label treatment. */
.service-form label .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ============ HOMEPAGE EDITOR ============ */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.slot-card { overflow: hidden; }
.slot-preview { aspect-ratio: 4 / 3; background: var(--bg-soft); }
.slot-preview img { width: 100%; height: 100%; object-fit: cover; }
.slot-foot { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

.scrim-section { margin-top: 44px; max-width: 640px; }
.scrim-preview {
  position: relative; aspect-ratio: 16 / 7;
  border-radius: var(--radius); overflow: hidden; margin: 14px 0;
  background: url("https://res.cloudinary.com/dzug5s7sk/image/upload/f_auto,q_auto,c_limit,w_800/thomasprimard.com/hero-day") center/cover;
}
.scrim-layer { position: absolute; inset: 0; background: rgba(20, 17, 14, 0); pointer-events: none; }
.scrim-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.scrim-controls input[type="range"] { flex: 1; min-width: 160px; }

/* ============ PREVIEW OVERLAY + LIGHTBOX ============ */
/* Deliberately dark: these show photography full-bleed, so the cream shell
   would fight the images. The portal has no equivalent to align to. */
.preview-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 18, 15, 0.94);
  display: flex; flex-direction: column;
}
.preview-close {
  align-self: flex-end; margin: 18px;
  color: var(--cream-50); border: 1px solid rgba(250, 247, 242, 0.45);
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; letter-spacing: 0.04em;
  transition: background 0.2s var(--ease);
}
.preview-close:hover { background: rgba(250, 247, 242, 0.12); }
.preview-strip { display: flex; gap: 14px; overflow-x: auto; padding: 24px; align-items: center; flex: 1; }
.preview-cell { position: relative; flex-shrink: 0; }
.preview-cell img { height: 260px; width: auto; border-radius: var(--radius); cursor: pointer; object-fit: cover; }
.preview-cell figcaption {
  position: absolute; bottom: 8px; left: 8px;
  background: rgba(31, 28, 24, 0.65); color: var(--cream-50);
  font-size: 11px; padding: 3px 9px; border-radius: var(--radius);
}
.preview-play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  color: var(--cream-50); font-size: 2rem; pointer-events: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
.preview-lightbox {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(12, 11, 9, 0.97);
  display: flex; align-items: center; justify-content: center;
}
.preview-lightbox .lb-stage img,
.preview-lightbox .lb-stage video { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); }
.preview-lightbox .lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  color: var(--cream-50); font-size: 3rem; padding: 0 1rem; opacity: 0.7;
  transition: opacity 0.2s var(--ease);
}
.preview-lightbox .lb-nav:hover { opacity: 1; }
.preview-lightbox .lb-prev { left: 8px; }
.preview-lightbox .lb-next { right: 8px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 820px) {
  .editor-layout { grid-template-columns: 1fr; }
  .curated-row { grid-template-columns: auto 48px 1fr; grid-template-areas: "h t f" ". . v" ". . r"; }
  .page-head { align-items: flex-start; }
}

@media (max-width: 720px) {
  /* Too short to justify an app shell — let the whole page scroll normally. */
  .dash-app { height: auto; min-height: 100vh; overflow: visible; }
  .dash-body { flex-direction: column; min-height: 0; }
  .dash-main { height: auto; overflow-y: visible; }
  .dash-sidebar {
    width: auto; height: auto; overflow-y: visible;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 10px var(--pad-x);
    flex-direction: row; align-items: center; flex-wrap: wrap;
  }
  .shell-nav { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .shell-nav a { border-left: none; }
  .shell-nav a[aria-current="page"] { background: rgba(181, 113, 76, 0.10); }
  .shell-context { display: none; }
  /* Let the bar fall onto a second line rather than squeezing the buttons. */
  .shell-bar { gap: 12px 14px; flex-wrap: wrap; padding: 14px var(--pad-x); }
  .shell-spacer { display: none; }
  .shell-bar-actions { margin-left: auto; }
}
