/* admin panel. builds on style.css variables */

.admin-wrap { max-width: 980px; padding-bottom: 80px; }
.panel h1, .auth-card h1, #panel-editor h1, .dash-top h1, .modal h2 { font-family: var(--serif); font-weight: 500; }
.panel h1 { font-size: 26px; margin: 34px 0 6px; }
.panel .sub { margin: 0 0 24px; }

label.field { display: block; margin-bottom: 18px; font-size: 14px; font-weight: 600; color: var(--text-soft); }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  margin-top: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.panel[hidden] { display: none !important; }

/* login & first-run: centered card, fills the page without overflowing */
body.admin-body main { display: flex; flex-direction: column; }
body.admin-body:has(#panel-login:not([hidden]), #panel-setup:not([hidden])) main { padding-bottom: 0; }
#panel-setup, #panel-login {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  padding: 30px 28px 26px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.auth-card h1 { text-align: center; font-size: 26px; margin: 0 0 6px; letter-spacing: 0.03em; }
.auth-card .sub { text-align: center; margin: 0 0 26px; font-size: 13.5px; }
.auth-card form { text-align: left; }
.auth-card label.field { font-size: 14px; font-weight: 600; letter-spacing: 0; color: var(--text-soft); margin-bottom: 10px; }
.auth-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.auth-actions .btn { white-space: nowrap; font-size: 13.5px; }
.auth-card input[type="password"] {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 6px;
  width: 100%;
}
.auth-card input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.auth-card .btn.primary {
  width: 100%;
  background: var(--accent);
  color: #141414;
  border: 1px solid var(--accent);
  font-weight: 600;
}
.auth-card .btn.primary:hover { filter: brightness(1.06); }
.auth-card .btn.ghost { width: 100%; }
.auth-card .err { text-align: left; }

.err { color: var(--danger); font-size: 13.5px; margin: 12px 0 0; min-height: 18px; }
.err:empty { display: none; }

.dash-top { display: flex; align-items: center; justify-content: space-between; margin: 34px 0 20px; }
.dash-top h1 { margin: 0; font-size: 26px; }
.dash-actions { display: flex; gap: 8px; }

.admin-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.admin-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
}
.admin-item img.cover { width: 64px; height: 64px; object-fit: cover; border-radius: 2px; background: #0d0d0d; }
.admin-item .meta { flex: 1; min-width: 0; }
.admin-item .meta .t { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-item .meta .d { font-size: 12.5px; color: var(--muted); }
.admin-item .ops { display: flex; gap: 6px; }

.dropzone {
  margin-top: 6px;
  border: 1.5px dashed var(--border-hover);
  border-radius: 4px;
  padding: 26px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  color: var(--muted);
  font-weight: 400;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

.image-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 12px; }
.pv {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform 150ms ease;
}
.pv:active { cursor: grabbing; }
.pv.drag-source { opacity: 0.35; }
.pv.ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 120;
  margin: 0;
  pointer-events: none;
  cursor: grabbing;
  opacity: 0.92;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  background: var(--card);
  border-radius: 5px;
}
.pv img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 3px; border: 1px solid var(--border); }
.pv-ops { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }
.pv-ops button {
  min-width: 36px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.pv-ops button[data-act="crop"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); font-weight: 600; }
.pv-ops button:hover:not(:disabled) { filter: brightness(1.15); }
.pv.removed img { opacity: 0.4; border-color: var(--danger); }
.pv.removed .pv-label { background: rgba(224, 108, 108, 0.9); }
.pv.cropped .pv-label { background: var(--accent); color: #141414; }
.pv-label { position: absolute; top: 10px; left: 10px; font-size: 11px; color: #fff; background: rgba(0,0,0,.6); padding: 2px 7px; border-radius: 4px; }
.crop-badge { border: 1px solid var(--border); border-radius: 3px; padding: 0 5px; }

.crop-dialog .dialog-actions { margin-top: 16px; }
.crop-dialog .err { margin-bottom: 0; }
.crop-dialog .err:empty { display: none; }

/* square crop picker */
.crop-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 20px;
}
.crop-backdrop[hidden] { display: none; }
.crop-dialog {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 22px;
  max-width: min(720px, 94vw);
  width: 100%;
}
.crop-dialog h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; margin: 0 0 4px; }
.crop-sub { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.crop-stage {
  position: relative;
  display: block;
  width: fit-content;
  margin: 0 auto;
  max-width: 100%;
  line-height: 0;
  user-select: none;
  touch-action: none;
  background: #000;
  /* clip the selection's dimming shadow to the image, not the dialog */
  overflow: hidden;
}
.crop-stage img { display: block; max-width: 100%; max-height: 60vh; width: auto; height: auto; }
.crop-sel {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  cursor: move;
}
.crop-sel::after {
  content: "1:1";
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 11px;
  line-height: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  padding: 3px 6px;
  border-radius: 3px;
  pointer-events: none;
}
.crop-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #000;
  cursor: nwse-resize;
}

#panel-editor {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 26px 28px;
  margin-top: 30px;
}
#panel-editor h1 { margin: 0 0 20px; font-size: 22px; }

.editor-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: -4px 0 22px; }
.editor-tabs .tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.04em;
  padding: 8px 16px 10px;
  margin-bottom: -1px;
  cursor: pointer;
}
.editor-tabs .tab:hover { color: var(--text); }
.editor-tabs .tab.active { color: var(--text); border-bottom-color: var(--accent); }
#editor-comments h1 { margin-bottom: 14px; }

.settings-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 22px 26px;
  margin-bottom: 16px;
}
.settings-section h2 { font-family: var(--serif); font-weight: 500; font-size: 17px; margin: 0 0 4px; }
.settings-section .section-desc { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.settings-tabs { margin: 0 0 24px; flex-wrap: wrap; }
.settings-tabs .tab { white-space: nowrap; }
.logo-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  background: var(--thumb);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
}
.logo-frame img { max-height: 90px; width: auto; display: block; }
.logo-status { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }
.logo-dropzone { margin-top: 16px; }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
#accent-input { width: 64px; height: 38px; padding: 3px; border: 1px solid var(--border); border-radius: 2px; background: var(--bg-soft); cursor: pointer; }
#theme-select {
  margin-top: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
}
#theme-select:focus { outline: none; border-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; margin-top: 6px; }
.motd-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.category-rows { display: grid; gap: 10px; margin-top: 6px; }
.category-row { display: flex; gap: 8px; align-items: stretch; }
.category-row input[type="text"] { flex: 1; }
.category-row .btn {
  height: auto;
  min-height: 42px; /* match the input height */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}
.category-row .btn:disabled { opacity: 0.35; cursor: default; }
.motd-custom { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.motd-custom[hidden] { display: none; }
.motd-custom input[type="number"] { width: 110px; margin-top: 0; }
.motd-countdown { margin: 8px 0 0; font-size: 13px; color: var(--accent); font-variant-numeric: tabular-nums; }
.admin-comment { border-bottom: 1px solid var(--border); padding: 10px 0; display: flex; gap: 14px; align-items: flex-start; }
.admin-comment .ac-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.admin-comment .ac-meta { font-size: 12.5px; color: var(--muted); }
.admin-comment .ac-text { font-size: 14px; color: var(--text-soft); white-space: pre-line; }
.admin-comment .ac-reply { border-left: 2px solid var(--border); padding: 4px 0 4px 12px; margin-top: 8px; }
.admin-comment .ac-reply-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.admin-comment .ac-reply .ac-text { font-size: 13px; }
.admin-comment .ac-ops { display: flex; gap: 6px; flex-shrink: 0; margin-top: 2px; }
.admin-comment .btn { flex-shrink: 0; margin-top: 2px; }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.dialog-backdrop[hidden] { display: none; }
.dialog {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px 26px;
  width: min(380px, 92vw);
}
.dialog h2 { font-family: var(--serif); font-weight: 500; font-size: 18px; margin: 0 0 8px; }
.dialog-text { margin: 0 0 20px; font-size: 14px; color: var(--text-soft); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
body.dialog-open { overflow: hidden; }

#toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 200; }
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 11px 16px;
  border-radius: 4px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: fadein 0.2s ease;
}
.toast.err { border-left-color: var(--danger); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 560px) {
  .dash-top { flex-direction: column; align-items: flex-start; gap: 12px; }
  .theme-grid { grid-template-columns: 1fr; }
  .admin-item { flex-wrap: wrap; }
  .admin-item .cover { width: 48px; height: 48px; }
  .admin-item .btn.small { padding: 5px 9px; }
  .admin-item .ops { margin-left: auto; }
  .logo-row { flex-direction: column; align-items: flex-start; }
  .settings-section, #panel-editor { padding: 18px 16px; }
  .editor-tabs .tab { padding: 8px 12px; }
  .form-actions { flex-wrap: wrap; }
  #toasts { left: 14px; right: 14px; }
  input[type="text"], input[type="password"], textarea, select { font-size: 16px; }
}

/* ================= layout & polish pass ================= */

/* inputs: uniform height, softer corners, accent focus ring */
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  border-radius: 6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus, input[type="color"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* buttons: consistent height and corners in the admin */
.btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; }
.btn.small { min-height: 30px; border-radius: 5px; }
.btn:focus-visible, .tab:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* settings panes: softer cards, better rhythm */
.settings-section { border-radius: 10px; padding: 24px 26px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.settings-section h2 { letter-spacing: 0.02em; }
.settings-section .section-desc { margin: 0 0 22px; }
label.field { margin-bottom: 20px; }

/* tabs: roomier, active tab tinted */
.settings-tabs { gap: 4px; margin: 0 0 26px; }
.settings-tabs .tab { padding: 10px 14px; border-radius: 6px 6px 0 0; }
.settings-tabs .tab.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* motd preset chips */
.motd-presets .btn { border-radius: 999px; }

/* appearance: accent swatch fills its cell */
.theme-grid { gap: 20px; }
#accent-input { width: 100%; height: 42px; padding: 4px; border-radius: 6px; }

/* dashboard rows: hover feedback */
.admin-item { border-radius: 8px; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.admin-item:hover { border-color: var(--border-hover); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }

/* editor + comment cards */
#panel-editor { border-radius: 10px; }
.category-row .btn { border-radius: 6px; }

/* dashboard search bar */
.admin-search { position: relative; max-width: 420px; }
.admin-search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.admin-search input {
  width: 100%;
  margin-top: 0;
  padding: 10px 14px 10px 36px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.admin-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.admin-search input::placeholder { color: var(--muted); }

/* the hidden attribute must always win over element display rules */
[hidden] { display: none !important; }

/* passkey list */
.passkey-status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.passkey-list { display: grid; gap: 8px; margin-bottom: 12px; }
.passkey-row { display: flex; gap: 8px; align-items: center; }
.passkey-main { flex: 1; display: grid; gap: 2px; }
.passkey-name-text { font-weight: 600; font-size: 14px; color: var(--text-soft); }
.passkey-meta { margin: 0; font-size: 11.5px; color: var(--muted); }


/* backups list */
.backup-list { display: grid; gap: 8px; }
.backup-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.backup-main { flex: 1; display: grid; gap: 2px; min-width: 0; }
.backup-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backup-meta { margin: 0; font-size: 11.5px; color: var(--muted); }
.backup-ops { display: flex; gap: 6px; }

/* backup status row */
.backup-status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

/* post list drag reorder */
.admin-item { cursor: grab; user-select: none; }
.admin-item.drag-source { opacity: 0.4; }
.row-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  z-index: 120;
  pointer-events: none;
  opacity: 0.92;
  cursor: grabbing;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  background: var(--card);
  border-radius: 8px;
  transform-origin: 0 0;
}

/* status badges */
.badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.badge.draft { background: rgba(224, 108, 108, 0.15); color: var(--danger); border: 1px solid #4a2a2a; }
.badge.premiere { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }

/* selects: custom chevron with breathing room from the right edge */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}
