/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0e0e0e;
  --bg-card: #161616;
  --bg-card-hover: #1e1e1e;
  --border: #2a2a2a;
  --accent: #e0e0e0;
  --accent-muted: #888;
  --text: #d4d4d4;
  --text-dim: #666;
  --white: #fff;
  --danger: #c0392b;
  --danger-hover: #a93226;
  --success: #27ae60;
  --success-hover: #219a52;
  --primary: #e0e0e0;
  --primary-hover: #bbb;
  --radius: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo img {
  height: 32px;
  width: auto;
  filter: brightness(0) invert(1);
}

.sidebar-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 20px 20px 8px;
  font-weight: 600;
}

.sidebar-nav {
  list-style: none;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 0.9rem;
  color: var(--accent-muted);
  transition: color 0.15s, background 0.15s;
  border-radius: 0;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--white);
  background: rgba(255,255,255,0.05);
}

.sidebar-nav a .nav-icon { font-size: 0.95rem; width: 18px; text-align: center; }

.sidebar-bottom {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.sidebar-user { margin-bottom: 10px; }
.sidebar-user strong { color: var(--text); display: block; font-size: 0.85rem; }

/* Main content */
.main-content {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
}

.page-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-header-bar h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--white);
  letter-spacing: -0.01em;
}

.page-header-bar .subtitle {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.content-area { padding: 28px 32px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  font-family: var(--font);
  line-height: 1;
  white-space: nowrap;
}

.btn-primary {
  background: var(--white);
  color: #000;
}
.btn-primary:hover { background: #ddd; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: #444; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: var(--success-hover); }

.btn-ghost {
  background: transparent;
  color: var(--accent-muted);
  padding: 6px 10px;
  border: none;
}
.btn-ghost:hover { color: var(--white); background: rgba(255,255,255,0.06); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 7px; border-radius: var(--radius); }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── Stats bar ───────────────────────────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 22px;
  min-width: 150px;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Category Grid ───────────────────────────────────────────────────────── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: default;
}

.category-card:hover {
  border-color: #444;
  box-shadow: var(--shadow);
}

.category-card .card-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #1a1a1a;
  display: block;
}

.category-card .card-thumb-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 2rem;
}

.category-card .card-body {
  padding: 14px 16px;
}

.category-card .card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 8px;
}

.drag-handle {
  cursor: grab;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 3px;
}
.drag-handle:active { cursor: grabbing; }

.category-card .card-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.category-card .card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: rgba(255,255,255,0.07);
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-muted);
  flex-shrink: 0;
}

/* Sortable ghost/chosen */
.sortable-ghost { opacity: 0.3; }
.sortable-chosen { box-shadow: 0 0 0 2px rgba(255,255,255,0.2); }

/* ── Section headings ────────────────────────────────────────────────────── */
.section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 14px;
}

/* ── Image Grid ──────────────────────────────────────────────────────────── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.image-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #1a1a1a;
  cursor: grab;
}
.image-item:active { cursor: grabbing; }

.image-item .img-wrap {
  aspect-ratio: 4/3;
  overflow: hidden;
  background: #1a1a1a;
}

.image-item .img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}

.image-item .img-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}

.image-item:hover .img-overlay { opacity: 1; }

.image-item .img-footer {
  padding: 5px 8px;
  font-size: 0.7rem;
  color: var(--text-dim);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.image-item .img-order {
  font-weight: 700;
  color: var(--accent-muted);
  font-size: 0.65rem;
}

.image-item.is-hero { border-color: rgba(255,255,255,0.3); }
.image-item .hero-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(255,255,255,0.9);
  color: #000;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--white);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color 0.15s;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: #555;
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 5px;
}

/* Image select in form */
.hero-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}

.hero-select-grid .hero-opt {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.hero-select-grid .hero-opt input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.hero-select-grid .hero-opt img {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  display: block;
}

.hero-select-grid .hero-opt.selected {
  border-color: var(--white);
}

/* ── Dropzone ─────────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: #555;
  background: rgba(255,255,255,0.02);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone .drop-icon { font-size: 1.8rem; margin-bottom: 8px; }
.dropzone .drop-text { font-weight: 500; color: var(--text); }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 40px 36px;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.login-logo img {
  height: 36px;
  filter: brightness(0) invert(1);
}

.login-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--white);
  text-align: center;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 28px;
}

.login-error {
  background: rgba(192, 57, 43, 0.15);
  border: 1px solid rgba(192, 57, 43, 0.35);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.83rem;
  color: #e74c3c;
  margin-bottom: 16px;
  display: none;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: var(--shadow);
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.2s ease;
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-info { border-left: 3px solid #3498db; }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
}

.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.text-dim { color: var(--text-dim); }
.text-sm { font-size: 0.82rem; }
.text-white { color: var(--white); }
.font-bold { font-weight: 700; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: rgba(255,255,255,0.07);
  color: var(--accent-muted);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  font-size: 0.9rem;
  color: var(--text);
  gap: 12px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 0.9rem; }

/* Tag inputs for pill preview */
.pill-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pill-preview .pill-item {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.78rem;
  color: var(--accent-muted);
}

.pill-preview .pill-item.current {
  background: var(--white);
  color: #000;
  border-color: var(--white);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.breadcrumb a { color: var(--text-dim); transition: color 0.15s; }
.breadcrumb a:hover { color: var(--white); }
.breadcrumb .sep { color: var(--border); }

/* Two-column layout for edit page */
.edit-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .edit-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .category-grid { grid-template-columns: 1fr 1fr; }
  .image-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

@media (max-width: 500px) {
  .content-area { padding: 16px; }
  .page-header-bar { padding: 16px; }
  .category-grid { grid-template-columns: 1fr; }
}
