/* ============================================================================
   Admin panel — clean, focused UI. Uses the same design tokens as the
   public template but a simpler, non-decorative layout.
   ========================================================================== */

:root {
  --bg-1: #fdeef2;
  --bg-2: #f7d9e1;
  --plum: #4a1f2e;
  --plum-2: #6b2b3f;
  --rose: #a13b58;
  --gold: #c9a86a;
  --cream: #fbf7f1;
  --ink: #2a1520;
  --muted: #7a5765;
  --line: rgba(74, 31, 46, 0.15);
  --shadow: 0 20px 60px -20px rgba(74, 31, 46, 0.25);
  --shadow-lg: 0 40px 80px -30px rgba(74, 31, 46, 0.35);
  --danger: #b83a4b;
  --success: #2e6b3e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background:
    radial-gradient(circle at 15% 10%, rgba(255,255,255,0.7), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(239,200,210,0.55), transparent 45%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  color: var(--ink);
  font-family: 'Cormorant Garamond', 'Cairo', serif;
}

.admin-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}
.admin-header h1 {
  font-family: 'Playfair Display', serif;
  color: var(--plum);
  font-size: 22px;
  font-weight: 700;
}
.admin-header .who {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--muted);
  font-size: 14px;
  margin-right: 16px;
}
.admin-header .actions { display: flex; align-items: center; gap: 12px; }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card h2 {
  font-family: 'Playfair Display', serif;
  color: var(--plum);
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 8px;
}
.card p { font-family: 'Cormorant Garamond', serif; font-size: 16px; color: var(--muted); line-height: 1.6; margin-bottom: 12px; }
.card code {
  background: var(--bg-1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 13px;
  color: var(--plum);
}

/* ---------- Login gate ---------- */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.gate-card {
  width: 100%;
  max-width: 400px;
  padding: 48px 36px 40px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: gateIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes gateIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}
.gate-logo {
  display: block;
  width: 110px;
  height: 110px;
  margin: 0 auto 20px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.6),
    0 12px 32px -12px rgba(74, 31, 46, 0.35);
}
.gate-sub {
  font-family: 'Playfair Display', serif;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  margin-bottom: 34px;
}
.gate-form { display: flex; flex-direction: column; gap: 14px; }
.gate-form input {
  padding: 16px 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  font-family: 'Cormorant Garamond', 'Cairo', serif;
  font-size: 17px;
  color: var(--ink);
  text-align: center;
  letter-spacing: 0.04em;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.gate-form input::placeholder {
  color: var(--muted);
  font-style: italic;
  letter-spacing: 0;
}
.gate-form input:focus {
  outline: none;
  border-color: var(--rose);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(161, 59, 88, 0.12);
}
.gate-form input.invalid {
  border-color: var(--danger);
  background: #fff5f6;
  animation: shake 0.4s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.gate-submit {
  padding: 15px;
  border-radius: 14px;
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.gate .error {
  min-height: 18px;
  font-size: 13px;
  text-align: center;
  color: var(--danger);
  font-style: italic;
  padding: 0 4px;
}

/* ---------- Form primitives ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; text-align: left; }
.field label {
  font-family: 'Playfair Display', serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field textarea,
.field select {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  font-family: 'Cormorant Garamond', 'Cairo', serif;
  font-size: 16px;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--rose);
  background: #fff;
}
.field .hint {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--muted);
  font-size: 13px;
}
.field .error {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--danger);
  font-size: 13px;
  min-height: 16px;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: 'Playfair Display', 'Cairo', serif;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: 0.08em;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--plum), var(--plum-2));
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(74, 31, 46, 0.5);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  color: var(--plum);
  border: 1.5px solid var(--plum);
}
.btn-outline:hover { background: var(--plum); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-size: 13px;
}
.btn-ghost:hover { color: var(--plum); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #922e3d; }

/* ---------- Setup note (before there's real content) ---------- */
.setup-note {
  border-left: 3px solid var(--gold);
  padding-left: 16px;
  margin: 20px 0;
}
.setup-note ol { margin-left: 20px; }
.setup-note li { margin-bottom: 6px; font-family: 'Cormorant Garamond', serif; font-size: 15px; }

/* ---------- Dashboard shell + topbar ---------- */
.dash-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  animation: dashIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes dashIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0);    }
}
.dash-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}
.dash-brand { display: flex; align-items: center; gap: 12px; }
.dash-brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7), 0 4px 12px -6px rgba(74, 31, 46, 0.3);
}
.dash-brand-name {
  font-family: 'Cairo', 'Playfair Display', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--plum);
  line-height: 1;
}
.dash-brand-latin {
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-inline-start: 4px;
}
.dash-topbar-actions { display: flex; align-items: center; gap: 14px; }
.dash-topbar-actions .who {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--muted);
  font-size: 14px;
}

/* Hero: title + subtitle + new-btn */
.dash-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.dash-title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  color: var(--plum);
  font-size: clamp(32px, 6vw, 44px);
  line-height: 1.1;
  margin-bottom: 6px;
}
.dash-subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--muted);
  font-size: 17px;
}
.dash-new-btn {
  padding: 14px 26px;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.dash-new-btn span { font-size: 18px; line-height: 0; margin-top: 2px; }

/* Card grid */
.dash-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.dash-row {
  position: relative;
  padding: 22px 22px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 14px 40px -18px rgba(74, 31, 46, 0.28);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
}
.dash-row::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--rose), var(--gold));
}
.dash-row:hover { transform: translateY(-3px); box-shadow: 0 22px 48px -18px rgba(74, 31, 46, 0.38); }
.dash-row-main { margin-bottom: 16px; }
.dash-name {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  color: var(--plum);
  font-size: 22px;
  line-height: 1.2;
  margin-bottom: 4px;
  word-break: break-word;
}
.dash-slug {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.1em;
}
.dash-slug code {
  background: transparent;
  padding: 0;
  color: var(--muted);
  font-family: 'SF Mono', 'Consolas', monospace;
}
.dash-row-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px dashed rgba(74, 31, 46, 0.14);
}
.dash-row-actions .btn {
  padding: 6px 12px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: none;
}

/* ---------- Editor form sections ---------- */
.section-block {
  padding: 24px 0;
  border-top: 1px solid var(--line);
  margin-top: 24px;
}
.section-block:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.section-block > h2 {
  font-family: 'Playfair Display', serif;
  color: var(--plum);
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 12px;
}
.section-block > p.hint { margin-bottom: 12px; }
details.section-block {
  border-top: 1px solid var(--line);
  padding: 16px 0;
  margin-top: 24px;
}
details.section-block summary {
  font-family: 'Playfair Display', serif;
  color: var(--plum);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  padding: 6px 0;
  list-style: none;
}
details.section-block summary::before {
  content: "▸ ";
  color: var(--gold);
  transition: transform 0.2s ease;
  display: inline-block;
}
details[open].section-block summary::before { content: "▾ "; }
details.section-block > .field:first-of-type { margin-top: 16px; }

/* ---------- Quiz builder rows ---------- */
.q-row {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.q-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.q-num {
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.q-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.q-option-row { display: flex; align-items: center; gap: 8px; }
.q-option-row input[type="radio"] { flex-shrink: 0; accent-color: var(--rose); width: 18px; height: 18px; }
.q-option-row input[type="text"] { flex: 1; padding: 8px 12px; font-size: 15px; }
.q-opt-remove {
  padding: 4px 10px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

/* ---------- Memory rows ---------- */
.mem-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.mem-thumb {
  width: 80px; height: 80px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--bg-2), #efc8d2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mem-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mem-thumb-placeholder {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  color: var(--plum);
  font-size: 14px;
}
.mem-fields { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.mem-fields .field { margin-bottom: 0; }
.mem-remove {
  padding: 4px 10px;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  align-self: flex-start;
}

/* ---------- Video ---------- */
.video-existing {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  gap: 10px;
}

/* ---------- Publish progress ---------- */
.progress { margin-top: 20px; }
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-1);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--rose), var(--plum));
  width: 0%;
  transition: width 0.3s ease;
}
.progress-text {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
  text-align: center;
}

/* ---------- Small: invalid state on inputs ---------- */
.field input.invalid,
.field textarea.invalid {
  border-color: var(--danger) !important;
  background: #fff5f6;
}

/* ---------- Delete button — subtle until hovered ---------- */
.dash-delete { color: var(--danger); }
.dash-delete:hover { background: var(--danger); color: #fff; }
.dash-delete:disabled { opacity: 0.5; cursor: wait; }

/* ---------- Screen visibility toggle ---------- */
.screen[hidden]  { display: none !important; }
/* The gate and admin-app also override display via class rules, so we
   need !important to make `hidden` win when JS toggles it. */
.gate[hidden]    { display: none !important; }
#admin-app[hidden] { display: none !important; }

/* ---------- Success link ---------- */
#success-link { color: var(--rose); text-decoration: none; }
#success-link:hover { text-decoration: underline; }

/* ---------- Header actions responsive ---------- */
@media (max-width: 640px) {
  .admin-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .admin-header .actions { flex-wrap: wrap; }
  .dash-row { flex-direction: column; align-items: stretch; }
  .dash-row-actions { justify-content: flex-end; }
}
