/* Admin pages (admin.html, covers.html). Loaded after styles.css and reuses its tokens. */

.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.admin-tabs a {
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--s300);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.admin-tabs a:hover {
  color: #fff;
}

.admin-tabs a[aria-current='page'] {
  background: #fff;
  color: var(--ink);
}

.admin-main {
  position: relative;
  isolation: isolate;
  padding-top: 40px;
  padding-bottom: 96px;
}

.admin-main .aurora {
  position: fixed;
}

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
}

.admin-title {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
}

.admin-sub {
  margin: 6px 0 0;
  color: var(--s400);
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.save-status {
  color: var(--s400);
  font-size: 0.875rem;
}

.save-status.is-dirty {
  color: var(--magenta);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.notice {
  margin: 24px 0 0;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(232, 121, 249, 0.35);
  background: rgba(232, 121, 249, 0.08);
  color: var(--s200);
  font-size: 0.9rem;
}

.notice button {
  margin-left: 8px;
}

.error-list {
  margin: 24px 0 0;
  padding: 14px 16px 14px 36px;
  border-radius: 14px;
  border: 1px solid rgba(251, 113, 133, 0.45);
  background: rgba(251, 113, 133, 0.08);
  color: #fecdd3;
  font-size: 0.9rem;
  line-height: 1.7;
}

.panel {
  border-radius: 20px;
  box-shadow: var(--shadow);
}

/* ---------- edit page ---------- */
.admin-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  align-items: start;
  gap: 20px;
  margin-top: 28px;
}

.tree {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding: 12px;
}

.tree-group + .tree-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.tree-section,
.tree-app,
.tree-add {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--s300);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.tree-section {
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
}

.tree-section:hover,
.tree-app:hover,
.tree-add:hover {
  background: rgba(255, 255, 255, 0.05);
}

.tree-section.is-selected,
.tree-app.is-selected {
  border-color: rgba(45, 212, 191, 0.4);
  background: rgba(45, 212, 191, 0.1);
  color: #fff;
}

.tree-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 16px;
}

.tree-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.tree-star {
  color: var(--aqua);
  font-size: 0.8rem;
}

.tree-add {
  color: var(--s500);
  font-size: 0.85rem;
}

.tree-add-section {
  margin-top: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  justify-content: center;
}

.editor {
  padding: 24px;
}

.editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.editor-head h2 {
  margin: 0;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.editor-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-small {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--s200);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-small:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.btn-small:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-danger {
  border-color: rgba(251, 113, 133, 0.4);
  color: #fda4af;
}

.editor-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
  gap: 28px;
}

.preview-wrap {
  position: sticky;
  top: 100px;
}

.preview-wrap .hint {
  margin: 10px 0 0;
  color: var(--s500);
  font-size: 0.75rem;
  text-align: center;
}

/* the real .cf-card, taken out of the 3D stage */
.cf-card.preview-card {
  position: relative;
  top: auto;
  left: auto;
  width: 100%;
  height: auto;
  aspect-ratio: 280 / 372;
  margin: 0;
  transform: none;
  filter: none;
  cursor: default;
  box-shadow: var(--glow);
}

.preview-card .cf-icon {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  font-size: 27px;
}

.preview-card .cf-title {
  font-size: 1.05rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}

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

.field.span-2 {
  grid-column: 1 / -1;
}

.field-label {
  color: var(--s300);
  font-size: 0.8125rem;
  font-weight: 600;
}

.field-hint {
  color: var(--s500);
  font-size: 0.75rem;
}

.field input[type='text'],
.field input[type='url'],
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(11, 15, 20, 0.6);
  color: #fff;
  font: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.7;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: rgba(45, 212, 191, 0.6);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

.field input:disabled,
.field textarea:disabled,
.field select:disabled {
  opacity: 0.6;
}

.mono {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace !important;
  font-size: 0.875rem !important;
}

.color-pair {
  display: flex;
  gap: 10px;
}

.color-pair input {
  width: 56px;
  height: 42px;
  padding: 3px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(11, 15, 20, 0.6);
  cursor: pointer;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: var(--s200);
  font-size: 0.9rem;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--aqua);
}

.cover-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--aqua);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

/* ---------- covers page ---------- */
#covers {
  margin-top: 40px;
}

.cover-section + .cover-section {
  margin-top: 48px;
}

.cover-section h2 {
  margin: 0;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.4rem;
}

.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 18px;
}

.cover-item {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border-radius: 22px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.cover-item.is-target {
  outline: 2px solid var(--aqua);
  outline-offset: 3px;
}

.cover-item.is-dragover {
  border-color: var(--aqua);
  background: rgba(45, 212, 191, 0.08);
}

.cover-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.upload-btn {
  position: relative;
  overflow: hidden;
}

.upload-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-btn:focus-within {
  outline: 2px solid var(--aqua);
  outline-offset: 3px;
}

.cover-status {
  min-height: 1.2em;
  margin: 0;
  color: var(--s400);
  font-size: 0.75rem;
}

.cover-status[data-kind='error'] {
  color: #fda4af;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  transform: translateX(-50%);
  border-radius: 999px;
  border: 1px solid rgba(45, 212, 191, 0.4);
  background: rgba(14, 20, 27, 0.92);
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 0.9rem;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.toast[data-kind='error'] {
  border-color: rgba(251, 113, 133, 0.5);
}

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .tree {
    position: static;
    max-height: none;
  }
  .editor-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .preview-wrap {
    position: static;
    width: 200px;
    margin: 0 auto;
  }
  /* long form on small screens: keep save reachable */
  .admin-actions {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 60;
    padding: 6px 6px 6px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(14, 20, 27, 0.92);
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
  .save-status:empty {
    display: none;
  }
  .admin-actions:has(.save-status:empty) {
    padding-left: 6px;
  }
  .toast {
    bottom: 84px;
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .editor {
    padding: 18px;
  }
}

@media (max-width: 560px) {
  .admin-page .brand-name {
    display: none;
  }
  .admin-tabs a {
    padding: 6px 11px;
  }
}
