/* /admin — settings panel layered on top of booth.css. */

/* booth.css locks html { overflow: hidden } for the camera flow; the page
   that loads admin.css needs the html element to scroll. We tag both
   <html> and <body> with .admin-body, so this selector matches both. */
html.admin-body, body.admin-body {
  overflow: auto !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
body.admin-body {
  display: block;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  /* Leave room for the sticky footer so the save button never tucks under it. */
  padding-bottom: calc(env(safe-area-inset-bottom) + 3.5rem);
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: calc(env(safe-area-inset-top) + 0.85rem) 1rem 0.85rem;
  background: rgba(14,14,15,0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.admin-title { font-size: 1.05rem; font-weight: 700; flex: 1; }

.admin-main {
  max-width: 32rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

/* The gate is a centered card — sized to fit a phone viewport without scroll,
   floats vertically inside the main area on tablet/desktop. */
.admin-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 8rem);
  padding: 1rem 0;
}
.admin-gate__card {
  width: 100%;
  max-width: 22rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 1.1rem;
  padding: 1.6rem 1.4rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}
.admin-gate__title { font-size: 1.25rem; letter-spacing: -0.01em; font-weight: 700; }
.admin-gate__sub { color: var(--muted); font-size: 0.9rem; }
.admin-gate__input {
  appearance: none;
  background: rgba(0,0,0,0.35);
  border: 1.5px solid rgba(255,255,255,0.15);
  color: var(--fg);
  font: inherit;
  font-size: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 0.7rem;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.admin-gate__input:focus {
  border-color: rgba(255,255,255,0.55);
  background: rgba(0,0,0,0.5);
}
.admin-gate__btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.9rem 1.25rem;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease;
  min-height: 44px;
}
.admin-gate__btn:active { transform: scale(0.97); }
.admin-gate .muted, .admin-field .muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.admin-field {
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  border-radius: 0.85rem;
  padding: 1.1rem 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.admin-field legend {
  padding: 0 0.4rem;
  margin-left: -0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.admin-frames {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}
.admin-frame-radio {
  appearance: none;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.10);
  border-radius: 0.6rem;
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
}
.admin-frame-radio .dot {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,0.4);
  flex-shrink: 0;
}
.admin-frame-radio.active {
  border-color: var(--fg);
  background: rgba(255,255,255,0.10);
}
.admin-frame-radio.active .dot {
  background: var(--fg);
  border-color: var(--fg);
}

.admin-frames-toggle {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.admin-frame-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.08);
  border-radius: 0.55rem;
  cursor: pointer;
}
.admin-frame-toggle .name { font-size: 0.95rem; }
.admin-frame-toggle input[type=checkbox] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: #84e0a0;
  cursor: pointer;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}
.admin-actions .primary { flex: 1; }
.admin-status-text {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 6rem;
  text-align: right;
}
.admin-status-text.ok { color: #84e0a0; }
.admin-error {
  color: #ff7c7c;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
@media (prefers-contrast: more) {
  .admin-error { color: #ffb0b0; }
}
@media (min-width: 768px) {
  .admin-main { max-width: 38rem; padding: 2rem 1.5rem 3rem; }
  .admin-gate__card { max-width: 26rem; padding: 2rem 1.75rem 1.75rem; }
  .admin-gate__title { font-size: 1.4rem; }
}

/* Footer — sticky to viewport bottom so links are reachable without scroll. */
.admin-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem calc(env(safe-area-inset-bottom) + 0.6rem);
  background: linear-gradient(to top, rgba(14,14,15,0.95), rgba(14,14,15,0));
  font-size: 0.85rem;
}
.admin-footer__link {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
  transition: color 0.18s ease, background 0.18s ease;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.admin-footer__link:hover, .admin-footer__link:focus-visible {
  color: var(--fg);
  background: rgba(255,255,255,0.06);
}
.admin-footer__dot { color: rgba(247,245,240,0.25); }

/* Hidden-strips section — small thumbnail rows with an unhide button. */
.hidden-strip-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 24rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 0.25rem;
}
.hidden-strip-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.7rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0.6rem;
}
.hidden-strip-row__thumb {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.4rem;
  object-fit: cover;
  background: #222;
}
.hidden-strip-row__id {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hidden-strip-row__show {
  appearance: none;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--fg);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 36px;
}
.hidden-strip-row__show:hover { background: rgba(255,255,255,0.18); }
.hidden-strip-row__show:disabled { opacity: 0.6; cursor: default; }

@media (hover: none) {
  .admin-footer__link:hover { color: var(--muted); background: transparent; }
  .hidden-strip-row__show:hover { background: rgba(255,255,255,0.10); }
}
.admin-gate__input:focus-visible,
.admin-gate__btn:focus-visible,
.admin-footer__link:focus-visible,
.hidden-strip-row__show:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

/* ===== custom frames ===== */

.muted.small { font-size: 0.85rem; }

.custom-frames-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
}
.custom-frame-row {
  display: grid;
  grid-template-columns: 2.25rem 1fr auto auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0.55rem;
  background: rgba(255,255,255,0.03);
}
.cfr-swatch {
  width: 2.25rem; height: 2.25rem;
  border-radius: 0.4rem;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 1rem;
}
.cfr-name { font-weight: 600; }
.cfr-id {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  color: var(--muted);
}
.cfr-layout {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: lowercase;
}
.cfr-delete {
  appearance: none;
  background: rgba(255,90,90,0.12);
  border: 1px solid rgba(255,90,90,0.35);
  color: #ffb4b4;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 34px;
}
.cfr-delete:hover { background: rgba(255,90,90,0.22); }
.cfr-delete:disabled { opacity: 0.6; cursor: default; }

/* AI prompt block */
.ai-prompt-wrap, .custom-frame-upload {
  margin-top: 0.85rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0.55rem;
  background: rgba(255,255,255,0.02);
  padding: 0;
}
.ai-prompt-wrap > summary,
.custom-frame-upload > summary {
  cursor: pointer;
  padding: 0.7rem 0.85rem;
  font-weight: 600;
  user-select: none;
  list-style: none;
}
.ai-prompt-wrap > summary::-webkit-details-marker,
.custom-frame-upload > summary::-webkit-details-marker { display: none; }
.ai-prompt-wrap[open] > summary,
.custom-frame-upload[open] > summary {
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.ai-prompt-wrap > summary::before,
.custom-frame-upload > summary::before {
  content: '▸';
  margin-right: 0.55rem;
  display: inline-block;
  transition: transform 120ms ease;
  color: var(--muted);
}
.ai-prompt-wrap[open] > summary::before,
.custom-frame-upload[open] > summary::before { transform: rotate(90deg); }

.ai-prompt-wrap > p,
.ai-prompt-controls,
.custom-frame-form { padding: 0 0.85rem; }
.ai-prompt-wrap > p { padding-top: 0.6rem; }

.ai-prompt-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 0.5rem 0 0.5rem;
}
.ai-prompt-layout {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.ghost-btn {
  appearance: none;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--fg);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  margin-left: auto;
  min-height: 34px;
}
.ghost-btn:hover { background: rgba(255,255,255,0.16); }
.ghost-btn.ok { background: rgba(80,200,120,0.22); border-color: rgba(80,200,120,0.5); }

.ai-prompt-box {
  margin: 0 0.85rem 0.85rem;
  padding: 0.7rem 0.85rem;
  background: #0a0a0b;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 0.45rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #d6d4cf;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 22rem;
  overflow: auto;
}

/* ---- Custom frame upload form ----------------------------------------- */
.custom-frame-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 0.95rem 1.1rem;
}
.cf-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.cf-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--fg);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.cf-label em {
  font-style: normal;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0;
}
.cf-label code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.75rem;
  background: rgba(255,255,255,0.08);
  padding: 0.05rem 0.35rem;
  border-radius: 0.25rem;
  color: var(--fg);
}

/* Text inputs inside the form pick up .edit-input from booth.css, but we
   add a touch of consistency for height + focus. */
.custom-frame-form .edit-input {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 0.5rem;
  padding: 0.55rem 0.7rem;
  color: var(--fg);
  font-size: 0.9rem;
  width: 100%;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.custom-frame-form .edit-input:focus {
  outline: none;
  border-color: rgba(247,245,240,0.5);
  background: rgba(255,255,255,0.07);
}
.custom-frame-form .edit-input::placeholder { color: rgba(247,245,240,0.32); }

/* Layout choice — segmented pill (matches /board photos|videos toggle) */
.cf-layout-pick {
  display: inline-flex;
  align-self: flex-start;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.cf-layout-pick label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(247,245,240,0.65);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.cf-layout-pick label:hover { color: var(--fg); }
.cf-layout-pick input[type=radio] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.cf-layout-pick label:has(input:checked) {
  background: #f7f5f0;
  color: #0e0e0f;
}

/* Color swatches */
.cf-color-row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.9rem;
}
.cf-color {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--fg);
}
.cf-color input[type=color] {
  width: 2.75rem;
  height: 2.25rem;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 0.5rem;
  background: transparent;
  cursor: pointer;
  padding: 2px;
}
.cf-color input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.cf-color input[type=color]::-webkit-color-swatch {
  border: none;
  border-radius: 0.35rem;
}
.cf-color-hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.76rem;
}

/* File picker — dotted drop-zone-ish wrapper. We can't fully restyle the
   native input cross-browser, but we style the browser-controlled file
   button (::file-selector-button) and the surrounding box. */
.cf-row input[type=file] {
  font-size: 0.82rem;
  color: rgba(247,245,240,0.7);
  background: rgba(255,255,255,0.03);
  border: 1px dashed rgba(255,255,255,0.18);
  border-radius: 0.55rem;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.cf-row input[type=file]:hover {
  border-color: rgba(247,245,240,0.35);
  background: rgba(255,255,255,0.06);
}
.cf-row input[type=file]::file-selector-button {
  appearance: none;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  margin-right: 0.75rem;
  transition: background 0.15s ease;
}
.cf-row input[type=file]::file-selector-button:hover {
  background: rgba(255,255,255,0.18);
}

.cf-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.35rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.cf-actions .primary {
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
}
#cf-upload-status {
  font-size: 0.8rem;
  color: var(--muted);
}
#cf-upload-status.ok { color: #84e0a0; }
#cf-upload-status.err { color: #ff8a8a; }

@media (max-width: 480px) {
  .custom-frame-row {
    grid-template-columns: 2.25rem 1fr auto;
    grid-template-rows: auto auto;
  }
  .cfr-id { grid-column: 2; }
  .cfr-layout { grid-column: 2; }
  .cfr-delete { grid-row: 1 / span 2; grid-column: 3; align-self: center; }
}
