/* ── Admin editor UI ── */
:root {
  --red: #c0392b;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e4e2de;
  --bg: #f6f5f2;
  --card: #ffffff;
  --ok: #2e7d46;
}

* { box-sizing: border-box; }

/* `display:flex` on .modal-backdrop was overriding the native [hidden] attribute,
   leaving an empty modal dialog stuck on screen over the login form. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--ink); }

/* ── Login ── */
#login-view:not([hidden]) {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.login-logo { height: 54px; margin-bottom: 8px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }

.login-card label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
}

.login-card button {
  width: 100%;
  margin-top: 6px;
  padding: 11px;
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
}

.login-card button:disabled { opacity: 0.6; cursor: wait; }
.login-error { color: var(--red); font-size: 13px; margin: 12px 0 0; }

.login-return {
  display: block;
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.login-return:hover { border-color: #c9c6c0; background: #fafaf8; }

.editor-header-actions a.btn-ghost {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

/* ── Editor chrome ── */
.editor-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.editor-header-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.editor-header-brand img { height: 34px; }
.editor-header-brand strong { display: block; font-size: 15px; }

.draft-status { display: block; font-size: 12px; color: var(--muted); }
.draft-status.dirty { color: #b07d00; }
.draft-status.saved { color: var(--ok); }

.editor-header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--ink);
}
.btn-ghost:hover { border-color: #c9c6c0; }

.btn-icon {
  padding: 8px 10px;
  font-size: 13px;
  white-space: nowrap;
}
.btn-icon:disabled { opacity: 0.4; cursor: default; }

.btn-publish {
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 18px;
  font-weight: 700;
}
.btn-publish:disabled { opacity: 0.6; cursor: wait; }

.editor-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  overflow-x: auto;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.editor-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 40%);
  min-height: calc(100vh - 100px);
}

.editor-preview {
  position: sticky;
  top: 49px;
  height: calc(100vh - 49px);
  border-left: 1px solid var(--line);
  background: var(--card);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.editor-preview-head button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}

#preview-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.editor-tabs button {
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #edebe7;
  color: var(--muted);
  border-radius: 10px 10px 0 0;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.editor-tabs button.active { background: var(--card); color: var(--ink); }

.editor-main {
  padding: 0 20px 80px;
  overflow-y: auto;
  max-height: calc(100vh - 49px);
}

.page-panel { display: none; }
.page-panel.active { display: block; }

.page-panel-tools {
  display: flex;
  justify-content: flex-end;
  padding: 14px 2px;
}

.btn-preview {
  background: var(--ink);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 14px;
}

/* ── Cards / fields ── */
.group-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 18px;
}

.group-card > h2 {
  margin: 0 0 16px;
  font-size: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.group-card--highlight {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.18);
  animation: cms-highlight-pulse 0.45s ease;
}

@keyframes cms-highlight-pulse {
  0% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.35); }
  100% { box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.18); }
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
}

.field input[type="text"],
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
}

.field textarea { resize: vertical; min-height: 40px; }

.field-hint { font-size: 12px; color: var(--muted); margin: 0 0 14px; }
.field .field-hint { margin: 4px 0 0; }

/* image control */
.image-field { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }

.image-thumb {
  width: 130px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eee;
}

.image-actions { display: flex; flex-direction: column; gap: 8px; }
.image-actions button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
}
.image-actions button:hover { border-color: #c9c6c0; }
.image-note { font-size: 12px; color: var(--muted); }

/* banner tracker */
.banner-tracker-summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: #f0efeb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0 0 12px;
}

.banner-tracker-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 12px;
}

.banner-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafaf8;
  padding: 14px;
}

.banner-card--live { border-color: #9ccc9a; background: #f4fbf4; }
.banner-card--upcoming { border-color: #e0c57a; background: #fffbf0; }
.banner-card--ended,
.banner-card--off,
.banner-card--empty { opacity: 0.92; }

.banner-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.banner-card-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.banner-card-title strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.banner-status {
  display: inline-block;
  width: fit-content;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e8e6e1;
  color: var(--muted);
}

.banner-status--live { background: #2e7d46; color: #fff; }
.banner-status--upcoming { background: #b07d00; color: #fff; }
.banner-status--ended { background: #d8d5cf; color: #555; }
.banner-status--off { background: #c0392b; color: #fff; }
.banner-status--empty { background: #e8e6e1; color: #666; }

.banner-window {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
}

.banner-enabled {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
}

.banner-enabled input { width: auto; margin: 0; }

.banner-schedule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin-bottom: 4px;
}

.banner-schedule-grid .field { margin-bottom: 0; }
.banner-schedule-grid input[type="date"],
.banner-schedule-grid input[type="time"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
}

/* in-store spotlight departments */
.spotlight-tracker-summary {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: #f0efeb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0;
}

.spotlight-tracker-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.spotlight-tracker-toolbar button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.spotlight-tracker-toolbar button:hover { color: var(--ink); border-color: #c9c6c0; }

.spotlight-tracker-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 12px;
}

.spotlight-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafaf8;
  padding: 14px;
}

.spotlight-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.spotlight-card-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.spotlight-chevron {
  flex-shrink: 0;
  width: 14px;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.spotlight-chevron::before { content: "▸"; }

.spotlight-card.is-open .spotlight-chevron { transform: rotate(90deg); }

.spotlight-card-body {
  display: none;
  padding-top: 12px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.spotlight-card.is-open .spotlight-card-body { display: block; }

.spotlight-card-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.spotlight-card-title strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.spotlight-photo-count {
  display: inline-block;
  width: fit-content;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e8e6e1;
  color: var(--muted);
}

.spotlight-card-fields .field:last-child { margin-bottom: 0; }

.spotlight-photos-label {
  margin: 14px 0 8px;
  font-size: 13px;
  font-weight: 600;
}

.spotlight-photos {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spotlight-photo-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.spotlight-photo-thumb {
  width: 88px;
  height: 66px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #eee;
  flex-shrink: 0;
}

.spotlight-photo-thumb:not([src]),
.spotlight-photo-thumb[src=""] {
  opacity: 0.35;
}

.spotlight-photo-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.spotlight-photo-actions button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  width: fit-content;
}

.spotlight-photo-actions button:disabled { opacity: 0.4; cursor: default; }

.spotlight-add-photo { margin-top: 8px; }

@media (max-width: 700px) {
  .banner-schedule-grid { grid-template-columns: 1fr; }
}

/* list controls */
.list-rows { display: flex; flex-direction: column; gap: 8px; }

.list-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: #fafaf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.list-row-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.list-row-fields input, .list-row-fields textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
}

.list-row-buttons { display: flex; flex-direction: column; gap: 4px; }
.list-row-buttons button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  width: 30px;
  height: 26px;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
}
.list-row-buttons button:hover:not(:disabled) { color: var(--ink); border-color: #c9c6c0; }
.list-row-buttons button:disabled { opacity: 0.35; cursor: default; }
.list-row-buttons .row-remove { color: var(--red); }

.list-add {
  margin-top: 8px;
  border: 1px dashed #c9c6c0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.list-add:hover { color: var(--ink); border-color: var(--muted); }

/* section order */
.order-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fafaf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.order-row strong { flex: 1; font-size: 14px; }

/* toast + modal */
.toast:not([hidden]) {
  display: block;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 60;
  max-width: min(560px, 90vw);
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.toast.error { background: var(--red); }
.toast.success { background: var(--ok); }

.modal-backdrop:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--card);
  border-radius: 14px;
  padding: 26px 28px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.3);
}
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal-actions button { border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 14px; }
.modal-actions .modal-secondary { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.modal-actions .modal-primary { background: var(--red); border: 0; color: #fff; }

@media (max-width: 960px) {
  .editor-body {
    grid-template-columns: 1fr;
  }
  .editor-preview {
    position: relative;
    top: 0;
    height: 420px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .editor-main {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .editor-header { flex-wrap: wrap; }
  .editor-header-actions { width: 100%; }
  .editor-header-actions button { flex: 1; }
  .group-card { padding: 16px; }
  .image-field { flex-direction: column; }
}
