:root {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-2: #222633;
  --border: #2d3345;
  --text: #e8eaf0;
  --muted: #9aa3b8;
  --accent: #e84393;
  --accent-2: #fd79a8;
  --success: #00b894;
  --warning: #fdcb6e;
  --danger: #ff7675;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --sidebar-w: 260px;
  --font: 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at top, #2d1b2e 0%, var(--bg) 55%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 2.5rem;
  box-shadow: var(--shadow);
}
.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}
.login-brand h1 {
  font-size: 1.75rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-brand p { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* Shell */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}
.admin-sidebar .brand {
  padding: 1.25rem 1.5rem;
  font-weight: 700;
  font-size: 1.15rem;
  border-bottom: 1px solid var(--border);
  color: var(--accent-2);
}
.admin-nav { flex: 1; overflow-y: auto; padding: 1rem 0.75rem; }
.nav-section { margin-bottom: 1rem; }
.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.5rem 0.75rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 2px;
  transition: all 0.15s;
}
.nav-link:hover, .nav-link.active {
  background: rgba(232, 67, 147, 0.12);
  color: var(--accent-2);
  text-decoration: none;
}
.nav-link.active { font-weight: 600; }

.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
}
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(24, 27, 36, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.admin-topbar h2 { font-size: 1.25rem; font-weight: 600; }
.admin-content { padding: 1.5rem; }

.menu-toggle {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}

/* Cards & stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.stat-card .label,
.stat-card span.label { font-size: 0.8rem; color: var(--muted); display: block; }
.stat-card .value,
.stat-card span.value { font-size: 1.75rem; font-weight: 700; margin-top: 0.25rem; display: block; }
.stat-card { display: block; }
.stat-card.accent { border-color: rgba(232, 67, 147, 0.35); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-body { padding: 1.25rem; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* Table */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
table.data-table th, table.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-weight: 500;
}
.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 67, 147, 0.2);
}
textarea.form-control { min-height: 100px; resize: vertical; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, opacity 0.15s;
}
.btn:hover { opacity: 0.92; text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #c44569); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #1a1a1a; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.btn-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-success { background: rgba(0,184,148,0.2); color: var(--success); }
.badge-warning { background: rgba(253,203,110,0.2); color: var(--warning); }
.badge-danger { background: rgba(255,118,117,0.2); color: var(--danger); }
.badge-muted { background: var(--surface-2); color: var(--muted); }

/* Alerts */
.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-success { background: rgba(0,184,148,0.15); border: 1px solid var(--success); color: var(--success); }
.alert-error { background: rgba(255,118,117,0.15); border: 1px solid var(--danger); color: var(--danger); }

/* Image manager */
.image-manager { margin-top: 0.5rem; }
.image-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  min-height: 60px;
}
.image-item {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: grab;
  background: var(--surface-2);
}
.image-item img { width: 100%; height: 100%; object-fit: cover; }
.image-item .remove-img {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--danger);
  color: #111;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-item .order-badge {
  position: absolute;
  bottom: 4px; left: 4px;
  background: rgba(0,0,0,0.7);
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
}
.image-item.sortable-ghost { opacity: 0.4; }
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); color: var(--accent-2); }
.upload-zone input { display: none; }

/* Banner sort list */
.sortable-banners .banner-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: grab;
  border: 1px solid var(--border);
}
.sortable-banners .banner-row img { width: 80px; height: 48px; object-fit: cover; border-radius: 6px; }
.sort-handle { color: var(--muted); font-size: 1.2rem; }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tab {
  padding: 0.65rem 1rem;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none; border-left: none; border-right: none;
  font-family: inherit;
  font-size: 0.875rem;
}
.tab.active { color: var(--accent-2); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
}
.pagination a { background: var(--surface-2); color: var(--text); }
.pagination .current { background: var(--accent); color: #fff; }

/* Filters bar */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: flex-end;
}
.filters-bar .form-control { max-width: 200px; }

.form-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-2);
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.form-section-title:first-child { margin-top: 0; }
.json-field { font-family: ui-monospace, monospace; font-size: 0.8rem; }
.form-hint { color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; display: block; }

/* Tag chips */
.tag-input-wrap { margin-bottom: 1rem; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; min-height: 28px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: rgba(232, 67, 147, 0.15); color: var(--accent-2);
  padding: 0.25rem 0.55rem; border-radius: 999px; font-size: 0.8rem;
}
.tag-chip button {
  border: none; background: transparent; color: inherit; cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0;
}

/* Repeatable builders */
.builder-wrap { margin: 1rem 0 1.5rem; padding: 1rem; background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border); }
.builder-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.builder-header label { font-weight: 600; margin: 0; }
.builder-list { display: flex; flex-direction: column; gap: 0.75rem; }
.builder-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.85rem; position: relative;
}
.builder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.65rem; }
.builder-grid-wide { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.builder-field { display: flex; flex-direction: column; gap: 0.2rem; }
.builder-field > span { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.builder-remove { margin-top: 0.5rem; }
.builder-field .chk { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; margin-top: 0.35rem; }

.variant-group { margin-bottom: 1rem; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.variant-group-head { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.variant-group-head input { flex: 1; }
.variant-options-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }
.variant-option { padding: 0.65rem; background: var(--surface-2); border-radius: 6px; border: 1px dashed var(--border); }

/* Responsive */
@media (max-width: 1024px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }
  .sidebar-overlay.show { display: block; }
}

@media (max-width: 600px) {
  .admin-content { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  table.data-table { font-size: 0.8rem; }
  table.data-table th, table.data-table td { padding: 0.5rem; }
}
