/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --nav-bg:       #1a1a2e;
  --nav-text:     #e0e0f0;
  --accent:       #4f6ef7;
  --accent-dark:  #3a56d4;
  --bg:           #f4f5f9;
  --surface:      #ffffff;
  --border:       #dde0ea;
  --text:         #1e2130;
  --muted:        #6b7280;
  --success-bg:   #ecfdf5;
  --success-text: #166534;
  --warn-bg:      #fffbeb;
  --warn-text:    #92400e;
  --error-bg:     #fef2f2;
  --error-text:   #991b1b;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: 0 24px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-nav__brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--nav-text);
  letter-spacing: -.01em;
}
.admin-nav__brand:hover { text-decoration: none; opacity: .85; }

.admin-nav__links {
  display: flex;
  align-items: center;
  gap: 20px;
}
.admin-nav__links a {
  color: rgba(255,255,255,.75);
  font-size: 13px;
}
.admin-nav__links a:hover,
.admin-nav__links a.active { color: #fff; text-decoration: none; }

.admin-nav__btn {
  background: var(--accent);
  color: #fff !important;
  padding: 5px 14px;
  border-radius: 6px;
  font-weight: 600;
}
.admin-nav__btn:hover { background: var(--accent-dark); }

.admin-nav__logout { opacity: .6; }
.admin-nav__logout:hover { opacity: 1; }

/* ── Main container ───────────────────────────────────────────────────────── */
.admin-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.admin-main--narrow { max-width: 720px; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 4px 0 6px;
}

.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  display: block;
  margin-bottom: 2px;
}
.breadcrumb:hover { color: var(--accent); }

/* ── Stat row ─────────────────────────────────────────────────────────────── */
.stat-row {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-width: 120px;
  flex: 1;
  box-shadow: var(--shadow);
}
.stat-card--warn    { border-top: 3px solid #f59e0b; }
.stat-card--highlight { border-top: 3px solid var(--accent); }

.stat-card__num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}
.stat-card__label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge--active        { background: #d1fae5; color: #065f46; }
.badge--not_started   { background: #e0e7ff; color: #3730a3; }
.badge--ended         { background: #f3f4f6; color: #374151; }
.badge--limit_reached { background: #fef3c7; color: #92400e; }

/* ── Data table ───────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.data-table th {
  background: #f8f9fb;
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbff; }

.data-table--entries th,
.data-table--entries td {
  white-space: nowrap;
  font-size: 13px;
}

.table-scroll { overflow-x: auto; }

.campaign-name { font-weight: 600; font-size: 14px; }
.campaign-id   { font-size: 12px; color: var(--muted); font-family: monospace; }
.campaign-url  { font-size: 12px; font-family: monospace; color: var(--accent); }
.url-unset     { font-size: 12px; font-style: italic; }

.actions { display: flex; gap: 8px; white-space: nowrap; }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-bar {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  margin-top: 4px;
  width: 80px;
}
.progress-bar__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .3s;
}

/* ── Form sections ────────────────────────────────────────────────────────── */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.section-hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.form-section--optional {
  border-left: 3px solid #f59e0b;
  background: #fffdf5;
}

.optional-feature {
  margin-top: 4px;
}

.checkbox-label--feature {
  align-items: flex-start;
  padding: 12px 16px;
  background: #fff;
}
.checkbox-label--feature input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}
.field-group:last-child { margin-bottom: 0; }

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.field-row:last-child { margin-bottom: 0; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,110,247,.15);
}
textarea { resize: vertical; min-height: 80px; }

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.field-hint code {
  background: #f3f4f6;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}
.field-hint-inline {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.req { color: #dc2626; }

/* ── Checkboxes ───────────────────────────────────────────────────────────── */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  cursor: pointer;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
  transition: border-color .15s;
}
.checkbox-label:hover { border-color: var(--accent); background: #f0f3ff; }
.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--accent); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn--outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn--outline:hover { border-color: var(--accent); color: var(--accent); background: #f0f3ff; }

.btn--sm  { padding: 5px 12px; font-size: 12px; }
.btn--lg  { padding: 11px 24px; font-size: 15px; }
.btn--full { width: 100%; justify-content: center; }

.form-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
}

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
}
.alert--success { background: var(--success-bg); color: var(--success-text); border: 1px solid #a7f3d0; }
.alert--error   { background: var(--error-bg);   color: var(--error-text);   border: 1px solid #fca5a5; }
.alert--warn    { background: var(--warn-bg);     color: var(--warn-text);    border: 1px solid #fcd34d; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state p { margin-bottom: 16px; font-size: 15px; }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--nav-bg);
}

.login-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  font-size: 36px;
  text-align: center;
  margin-bottom: 12px;
}
.login-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}
.login-sub {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
}

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 0 0;
}
.pagination__info { font-size: 13px; color: var(--muted); }

/* ── Workflow ─────────────────────────────────────────────────────────────── */
.workflow-section { border-left: 3px solid var(--accent); }

.workflow-bar {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.workflow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 90px;
  flex-shrink: 0;
}

.workflow-step__dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  transition: background .2s, border-color .2s;
}

.workflow-step--done  .workflow-step__dot { background: var(--accent); border-color: var(--accent); }
.workflow-step--active .workflow-step__dot { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,110,247,.2); }

.workflow-step__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
}
.workflow-step--active .workflow-step__label { color: var(--accent); }
.workflow-step--done   .workflow-step__label { color: var(--text); }

.workflow-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 20px;
  margin-bottom: 18px;
  transition: background .2s;
}
.workflow-connector--done { background: var(--accent); }

.workflow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
}

.btn--warn    { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.btn--warn:hover { background: #d97706; border-color: #d97706; }

.btn--success { background: #059669; color: #fff; border-color: #059669; }
.btn--success:hover { background: #047857; border-color: #047857; }

.btn--launch {
  background: linear-gradient(135deg, #4f6ef7, #7c3aed);
  color: #fff;
  border: none;
  font-size: 15px;
  padding: 10px 24px;
  box-shadow: 0 4px 12px rgba(79,110,247,.35);
}
.btn--launch:hover { opacity: .9; box-shadow: 0 6px 18px rgba(79,110,247,.45); }

/* Workflow badges on dashboard */
.badge--wf-draft             { background: #f3f4f6; color: #6b7280; }
.badge--wf-in_review         { background: #dbeafe; color: #1e40af; }
.badge--wf-changes_requested { background: #fef3c7; color: #92400e; }
.badge--wf-approved          { background: #d1fae5; color: #065f46; }
.badge--wf-launched          { background: #ede9fe; color: #5b21b6; }

/* Preview link */
.preview-link-section,
.review-notes-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 20px;
}

.preview-link-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.preview-link-box {
  display: flex;
  gap: 8px;
  margin: 10px 0 6px;
}

.preview-url-input {
  flex: 1;
  font-family: monospace;
  font-size: 12px;
  background: #f8f9fb;
  color: var(--muted);
  cursor: text;
}

.preview-link-meta {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.copied-msg {
  font-size: 13px;
  color: #059669;
  font-weight: 600;
  margin: 4px 0 0;
}

/* ── File manager ─────────────────────────────────────────────────────────── */
.upload-form  { margin-bottom: 20px; }

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-input  { display: none; }

.file-label {
  cursor: pointer;
  white-space: nowrap;
}

.file-chosen {
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.asset-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

.asset-thumb {
  width: 100%;
  height: 120px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.asset-thumb--pdf { background: #fef2f2; }

.pdf-icon {
  font-size: 28px;
  font-weight: 800;
  color: #dc2626;
  letter-spacing: .05em;
}

.asset-info { padding: 10px 12px; }

.asset-filename {
  font-size: 13px;
  font-weight: 600;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.asset-size { font-size: 12px; margin-bottom: 8px; }

.asset-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  margin-bottom: 8px;
}
.asset-tag--hero  { background: #d1fae5; color: #065f46; }
.asset-tag--rules { background: #dbeafe; color: #1e40af; }

.asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn--danger {
  background: transparent;
  color: #dc2626;
  border-color: #fca5a5;
}
.btn--danger:hover { background: #fef2f2; border-color: #dc2626; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.muted    { color: var(--muted); }
.ml-1     { margin-left: 6px; }
.text-warn{ color: #d97706; font-weight: 600; }

/* Max-entries explicit-choice radio group */
.max-entries-choice { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.max-entries-choice .radio-row { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.max-entries-choice .radio-row input[type="number"] { width: 8rem; }
.max-entries-choice .radio-row input[type="number"]:disabled { opacity: 0.5; background: #f5f5f5; }
.field-error.visible { color: #dc2626; font-size: 0.875rem; margin-top: 0.5rem; }

/* Inline file upload widget (next to filename text inputs) */
.inline-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.25rem; }
.inline-upload input[type="text"] { flex: 1 1 12rem; min-width: 12rem; background: #f9fafb; }
.inline-upload__status { font-size: 0.875rem; color: #6b7280; flex-basis: 100%; }
.inline-upload__status--ok    { color: #059669; }
.inline-upload__status--error { color: #dc2626; }

/* Editor header: workflow pill + actions */
.header-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.wf-pill { background: #f3f4f6; padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.875rem; }

/* Status history list on review page */
.status-history { list-style: none; padding: 0; margin: 0; }
.status-history li { padding: 0.5rem 0; border-bottom: 1px solid #f3f4f6; font-size: 0.9rem; }
.status-history li:last-child { border-bottom: 0; }
.full-width { width: 100%; }

/* Running-status dot in the dashboard actions column */
.run-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
  flex-shrink: 0;
}
.run-dot--on  { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,0.18); }
.run-dot--off { background: #d1d5db; }

/* ── Accessible focus styles (WCAG 2.4.7 / 2.4.11 / 2.4.13 / 1.4.11) ────────
 * Same approach as public/css/style.css. Admin uses a distinct dark blue so
 * focus stays visible against the lighter UI chrome.
 */
:root {
  --a11y-focus-color-outer: #1d4ed8;
  --a11y-focus-color-inner: #ffffff;
  --a11y-focus-outline: 2px;
  --a11y-focus-ring:    4px;
  --a11y-focus-offset:  2px;
  --a11y-sticky-header: 64px;                 /* the admin nav is sticky-feeling */
  scroll-padding-top: var(--a11y-sticky-header);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline:    var(--a11y-focus-outline) solid var(--a11y-focus-color-outer);
  outline-offset: var(--a11y-focus-offset);
  box-shadow: 0 0 0 var(--a11y-focus-ring) var(--a11y-focus-color-inner);
}
.focus-ring:focus-visible {
  outline:    var(--a11y-focus-outline) solid var(--a11y-focus-color-outer);
  outline-offset: var(--a11y-focus-offset);
  box-shadow: 0 0 0 var(--a11y-focus-ring) var(--a11y-focus-color-inner);
}
@media (forced-colors: active) {
  *:focus-visible {
    outline: var(--a11y-focus-outline) solid CanvasText;
    outline-offset: var(--a11y-focus-offset);
    box-shadow: none;
  }
}
:target,
[tabindex="-1"]:focus { scroll-margin-top: var(--a11y-sticky-header); }
@supports not selector(:focus-visible) {
  button:focus,
  a:focus,
  input:focus,
  select:focus,
  textarea:focus,
  [role="button"]:focus,
  [tabindex]:focus {
    outline: var(--a11y-focus-outline) solid var(--a11y-focus-color-outer);
    outline-offset: var(--a11y-focus-offset);
    box-shadow: 0 0 0 var(--a11y-focus-ring) var(--a11y-focus-color-inner);
  }
}

/* Centered variant for the campaign editor header — title, subtitle, and
   badges sit centered on the page with the action buttons beneath. */
.page-header--centered {
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.page-header--centered .header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
