/*
 * admin.css — styles for /admin/* pages only.
 * Loaded alongside style.css (which provides design tokens and the public nav).
 */


/* ─── Admin nav ───────────────────────────────────────────────────────────── */

.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.admin-nav-brand {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
}
.admin-nav-brand:hover { color: var(--blue); text-decoration: none; }

.admin-nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.admin-nav-link {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.admin-nav-link:hover,
.admin-nav-link.active {
  background: var(--surface-hi);
  color: var(--text-bright);
  text-decoration: none;
}
.admin-nav-link.active { color: var(--blue); }

.admin-nav-logout { font-family: inherit; }

.logout-form { display: inline; }


/* ─── Page shell ──────────────────────────────────────────────────────────── */

.admin-page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.admin-page-narrow {
  max-width: 600px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-desc {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 20px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
  margin: 24px 0 12px;
}


/* ─── Login page ──────────────────────────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 49px);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
}

.login-title {
  font-size: 18px;
  margin-bottom: 24px;
  text-align: center;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }


/* ─── Dashboard stat cards ────────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}

.stat-card-warn { border-color: #5a3a10; background: #1e160a; }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.link-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: block;
  transition: border-color 0.15s;
}
.link-card:hover { border-color: var(--blue); text-decoration: none; }

.link-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 4px;
}
.link-card-desc { font-size: 12px; color: var(--text-dim); }


/* ─── Filament list ───────────────────────────────────────────────────────── */

.filament-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filament-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

.fil-swatch {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
  outline: 1px solid rgba(255,255,255,0.08);
}

.fil-info {
  flex: 1;
  min-width: 0;
}

.fil-name {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fil-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.fil-notes { font-style: italic; }

.fil-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
}


/* ─── Badges ──────────────────────────────────────────────────────────────── */

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-green { background: #162318; color: var(--green); }
.badge-red   { background: #2a1010; color: var(--red); }


/* ─── Buttons ─────────────────────────────────────────────────────────────── */

.btn-primary {
  display: inline-block;
  padding: 8px 16px;
  background: var(--blue);
  color: #0b1020;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.1s;
  text-decoration: none;
}
.btn-primary:hover { opacity: 0.88; text-decoration: none; color: #0b1020; }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  display: inline-block;
  padding: 8px 14px;
  background: var(--surface-hi);
  color: var(--text);
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}
.btn-ghost:hover { border-color: var(--text-dim); text-decoration: none; color: var(--text-bright); }

.btn-sm {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  background: var(--surface-hi);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn-sm:hover { border-color: var(--text-dim); color: var(--text-bright); text-decoration: none; }
.btn-sm.btn-danger { color: var(--red); }
.btn-sm.btn-danger:hover { border-color: var(--red); background: #2a1010; }


/* ─── Forms ───────────────────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 500px) { .field-row { grid-template-columns: 1fr; } }

.field-checkbox { flex-direction: row; align-items: center; }
.field-checkbox label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hint  { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-dim); }
.required { color: var(--red); }

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-bright);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s;
}
input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue);
}

select { cursor: pointer; }
textarea { resize: vertical; min-height: 60px; }

/* Hex field + live preview */
.hex-row { display: flex; gap: 8px; align-items: center; }
.hex-row input { flex: 1; }
.hex-preview {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  flex-shrink: 0;
  outline: 1px solid rgba(255,255,255,0.08);
  border: 2px solid var(--border);
}

.filament-form { display: flex; flex-direction: column; gap: 16px; }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 4px;
}


/* ─── Range sliders ───────────────────────────────────────────────────────── */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: none;
}


/* ─── Change password (collapsible section on dashboard) ─────────────────── */

.change-password-section {
  margin: 24px 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.change-password-toggle {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none; /* removes the default triangle in some browsers */
  user-select: none;
  transition: color 0.15s;
}
/* Cross-browser: hide the default marker */
.change-password-toggle::-webkit-details-marker { display: none; }

.change-password-toggle::before {
  content: '▶  ';
  font-size: 10px;
  display: inline-block;
  transition: transform 0.15s;
}
details[open] .change-password-toggle::before {
  transform: rotate(90deg);
}

.change-password-toggle:hover { color: var(--text-bright); }

.change-password-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 16px 18px;
  max-width: 360px;
}


/* ─── Material Tuner ──────────────────────────────────────────────────────── */

.tuner-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 700px) {
  .tuner-layout { grid-template-columns: 1fr; }
}

.tuner-canvas-wrap {
  background: radial-gradient(130% 130% at 50% 20%, #21252e 0%, var(--bg) 70%);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
}

#tuner-canvas-host {
  flex: 1;
  position: relative;
}

#tuner-canvas-host canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.tuner-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.tuner-form { display: flex; flex-direction: column; gap: 18px; }

.tuner-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}


/* ─── Model admin grid ────────────────────────────────────────────────────── */

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

.model-admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}
.model-admin-card:hover { border-color: var(--blue); }

.model-admin-card-thumb {
  aspect-ratio: 1;
  background: var(--surface-hi);
  overflow: hidden;
}
.model-admin-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.model-admin-card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.model-admin-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
}

.model-admin-card-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.model-admin-card-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}


/* ─── STL upload drop zone ────────────────────────────────────────────────── */

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-hi);
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.drop-zone:hover,
.drop-zone.drop-zone-over {
  border-color: var(--blue);
  background: rgba(88, 166, 255, 0.05);
}

.drop-zone-icon {
  width: 36px;
  height: 36px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.drop-zone-prompt {
  font-size: 14px;
  color: var(--text-bright);
  margin: 0 0 4px;
}

.drop-zone-link { color: var(--blue); }

.drop-zone-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
}

.upload-file-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.upload-file-name {
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-file-size {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}

.upload-file-rejected .upload-file-name { color: var(--red); }
.upload-file-rejected .upload-file-size { color: var(--red); }


/* ─── Configure page ──────────────────────────────────────────────────────── */

.configure-layout {
  display: grid;
  grid-template-columns: 1fr 720px;   /* roomy working panel on the right */
  gap: 24px;
  align-items: start;
}
/* Stack earlier so the canvas isn't crushed once the fixed panel dominates. */
@media (max-width: 1100px) {
  .configure-layout { grid-template-columns: 1fr; }
}

/* Left column: 3D preview stacked above the media manager (mirrors the
   public viewer, where the media strip sits under the canvas). */
.configure-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.configure-canvas-wrap {
  background: radial-gradient(130% 130% at 50% 20%, #21252e 0%, var(--bg) 70%);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
}

#configure-canvas-host {
  flex: 1;
  position: relative;
  cursor: pointer;
}

#configure-canvas-host canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.configure-panel {
  display: flex;
  flex-direction: column;
}

/* ── Drag-and-drop media dropzone ── */
.dropzone {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.12s, background 0.12s;
}
.dropzone:hover { border-color: var(--blue); }
.dropzone.is-dragover {
  border-color: var(--blue);
  background: var(--surface-hi);
}
.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;   /* let drag events hit the label, not children */
}
.dropzone-icon { font-size: 22px; color: var(--text-dim); }
.dropzone-text { color: var(--text); font-weight: 600; }
.dropzone-file { color: var(--blue); font-size: 13px; }

/* ── Sticky save bar at the top of the configure panel ── */

.configure-save-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

/* ── Filament name shown next to the "Default filament" label ── */

.fil-selected-name {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}

/* ── Section header with inline action button ── */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* ── Filament swatch picker (inside slot editor cards) ── */

.fil-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.fil-picker-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid transparent;
  outline: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.08s, outline-color 0.1s;
}
.fil-picker-swatch:hover {
  transform: translateY(-1px);
  outline-color: rgba(255,255,255,0.25);
}
.fil-picker-swatch.selected {
  border-color: #fff;
  outline-color: rgba(255,255,255,0.4);
}
.fil-picker-swatch.fil-picker-oos {
  opacity: 0.35;
}

/* ── Slot editor ── */

.slot-editor-card {
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
}

.slot-editor-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.slot-bodies-preview {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.body-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: default;
}

.body-tag-empty {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}

/* Body color dot — matches configure_viewer.js PALETTE order */
.body-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
}

.body-color-0 { background: #f4a020; }
.body-color-1 { background: #2f6df0; }
.body-color-2 { background: #3fb950; }
.body-color-3 { background: #9e84e8; }
.body-color-4 { background: #e05454; }
.body-color-5 { background: #58a6ff; }
.body-color-6 { background: #d89a3a; }
.body-color-7 { background: #9ea0a3; }

/* ── Body assignment list ── */

.body-assignment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.body-assign-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.body-assign-row:hover { background: var(--surface-hi); }
.body-assign-row.body-row-active {
  background: var(--surface-hi);
  border-color: var(--blue);
}

.body-assign-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-bright);
  font-family: monospace;
}

.body-slot-select {
  width: auto;
  min-width: 130px;
  flex-shrink: 0;
}

/* ─── About-page editor ────────────────────────────────────────────────────── */
.about-edit-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}
.about-edit-textarea {
  width: 100%;
  min-height: 60vh;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
}
.about-edit-aside {
  position: sticky;
  top: 16px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.shortcode-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.shortcode-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}
.shortcode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.shortcode-token {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--blue);
  word-break: break-all;
}
.shortcode-desc {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

@media (max-width: 860px) {
  .about-edit-layout { grid-template-columns: 1fr; }
  .about-edit-aside { position: static; }
}

/* ─── Drag-to-reorder ──────────────────────────────────────────────────────── */
.drag-handle {
  cursor: grab;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  user-select: none;
  flex: 0 0 auto;
  padding: 2px 4px;
  border-radius: 5px;
  touch-action: none;
}
.drag-handle:hover { color: var(--text-bright); background: var(--surface-hi); }
.drag-handle:active { cursor: grabbing; }

/* Overlay handle for the model cards (corner badge over the thumbnail). */
.model-admin-card.sortable-item { position: relative; }
.drag-handle-overlay {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  background: rgba(8, 9, 11, 0.6);
  color: #fff;
}
.drag-handle-overlay:hover { background: rgba(8, 9, 11, 0.85); color: #fff; }

.sortable-item.dragging { opacity: 0.4; }

.reorder-status { color: var(--green); font-size: 12px; margin-left: 4px; }

/* Media caption inline editor (configure page). */
.media-admin-item .media-admin-meta {
  flex-direction: column;
  align-items: stretch;
}
.media-admin-meta-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.media-caption-form {
  display: flex;
  gap: 6px;
  align-items: center;
}
.media-caption-input {
  flex: 1;
  min-width: 0;
}

/* ─── Bambu preset loader (add-filament page) ─────────────────────────────── */
.preset-loader {
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}
.preset-loader > summary {
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  list-style: none;          /* hide default disclosure marker — we add our own */
}
.preset-loader > summary::-webkit-details-marker { display: none; }
.preset-loader-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
}
.preset-loader-title::before {
  content: '▸';
  display: inline-block;
  margin-right: 7px;
  color: var(--text-dim);
  transition: transform 0.12s ease;
}
.preset-loader[open] .preset-loader-title::before { transform: rotate(90deg); }
.preset-loader-body { margin-top: 14px; }
.preset-search {
  width: 100%;
  margin-bottom: 10px;
}
.preset-results {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
}
.preset-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}
.preset-item:hover { border-color: var(--blue); background: var(--surface-hi); }
.preset-swatch {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  outline: 1px solid rgba(255, 255, 255, 0.12);
}
.preset-item-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.preset-item-name {
  font-size: 13px;
  color: var(--text-bright);
  font-weight: 600;
}
.preset-item-meta {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: capitalize;
}
