/* ==========================================================================
   Easy3D admin panel — layered on top of assets/style.css's "maker studio"
   tokens (--paper, --ink, --accent, --radius, ...). Only admin.html loads
   this file, so the dark-mode block below is scoped to this page alone
   rather than changing the rest of the (light-only) site.
   ========================================================================== */

body { background: var(--paper); }

.admin-loading {
  padding: 60px 24px; text-align: center; color: var(--ink-soft); font-size: 14px;
}
.admin-loading[hidden] { display: none; }

.admin-main { max-width: 1080px; margin: 0 auto; padding: 28px 24px 64px; }
.admin-main[hidden] { display: none; }

.admin-head { margin-bottom: 22px; }
.admin-head h1 {
  font-family: var(--font-disp); font-weight: 700; font-size: 26px;
  margin: 0 0 4px; letter-spacing: -0.02em;
}
.admin-head .sub { margin: 0; color: var(--ink-soft); font-size: 14px; }

/* ------------------------------------------------------------------- tabs */
.admin-tabs {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 22px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper-2); flex-wrap: wrap;
}
.admin-tab {
  flex: 1 1 auto; min-width: max-content; padding: 9px 14px;
  font-family: var(--font-ui); font-size: 13.5px; font-weight: 600;
  color: var(--ink-soft); cursor: pointer; border: 0;
  border-radius: calc(var(--radius) - 4px); background: transparent;
  transition: background .15s, color .15s;
}
.admin-tab.active { background: var(--accent); color: #fff; }
.admin-tab[hidden] { display: none; }

.admin-panel[hidden] { display: none; }
.admin-panel h2 {
  font-family: var(--font-disp); font-weight: 700; font-size: 20px;
  margin: 0 0 16px; letter-spacing: -0.01em;
}
.admin-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.admin-panel-head h2 { margin: 0; }

.admin-search {
  padding: 10px 14px; font-size: 14px; font-family: var(--font-ui);
  color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); min-width: 220px; transition: border-color .15s;
}
.admin-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

/* ------------------------------------------------------------------ cards */
.admin-card {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.admin-card h3 {
  font-family: var(--font-disp); font-size: 15px; font-weight: 700;
  margin: 0 0 4px; letter-spacing: -0.01em;
}
.admin-card .field-hint { margin-top: 0; margin-bottom: 14px; }
.admin-seo-page { padding-top: 6px; margin-bottom: 8px; border-top: 1px dashed var(--line); }
.admin-seo-page:first-of-type { border-top: none; padding-top: 0; }
.admin-seo-page h4 {
  font-family: var(--font-ui); font-size: 13px; font-weight: 700; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 10px;
}
.admin-card .field { margin-bottom: 12px; }
.admin-card .field-label { margin-bottom: 5px; }
.admin-card textarea {
  width: 100%; min-height: 56px; padding: 10px 12px; font-size: 14px;
  font-family: var(--font-ui); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--paper); resize: vertical;
}

/* --------------------------------------------------------------- add-row */
.admin-add-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.admin-add-row input {
  flex: 1 1 160px; padding: 9px 12px; font-size: 13.5px; font-family: var(--font-ui);
  color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper);
}
.admin-add-row .btn-outline { width: auto; margin-top: 0; padding: 9px 16px; flex: 0 0 auto; }

/* -------------------------------------------------------------- btn-outline (sized down for inline row use) */
.admin-card .btn-outline { width: auto; margin-top: 4px; padding: 9px 18px; }

/* ------------------------------------------------------------------ table */
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--paper-2); }
.admin-table th, .admin-table td {
  padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.admin-table td.wrap { white-space: normal; }
.admin-table th {
  font-family: var(--font-ui); font-size: 12px; font-weight: 700; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .03em; background: var(--paper);
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.admin-table-empty { padding: 28px; text-align: center; color: var(--ink-soft); font-size: 13.5px; }
.admin-inline-input {
  width: 100%; padding: 6px 10px; font-size: 13px; font-family: var(--font-ui);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink);
}
.admin-table td.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; letter-spacing: .02em; }
.admin-coupon-uses { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 12.5px; color: var(--ink-soft); }
.admin-coupon-uses input { width: 64px; flex: none; }

.admin-cell-user { display: flex; flex-direction: column; gap: 2px; }
.admin-cell-user .email { font-weight: 600; color: var(--ink); }
.admin-cell-user .name { color: var(--ink-soft); font-size: 12px; }

/* ----------------------------------------------------------------- badges */
.admin-badge {
  display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 700;
  letter-spacing: .02em; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-tint); color: var(--accent-700);
}
.admin-badge.role-super_admin { background: var(--accent); color: #fff; }
.admin-badge.pro { background: var(--accent); color: #fff; }
.admin-badge.free { background: var(--paper); color: var(--ink-soft); border: 1px solid var(--line); }
.admin-badge.banned { background: #fdecec; color: #a12525; }
.admin-badge.active { background: #e9f7ef; color: #1e7a44; }
.admin-badge.on { background: #e9f7ef; color: #1e7a44; }
.admin-badge.off { background: var(--paper); color: var(--ink-soft); border: 1px solid var(--line); }

/* ------------------------------------------------------------- row actions */
.admin-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-btn-sm {
  font-family: var(--font-ui); font-size: 12px; font-weight: 600;
  color: var(--ink); background: transparent; border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; cursor: pointer; transition: all .15s ease;
  white-space: nowrap;
}
.admin-btn-sm:hover { border-color: var(--accent); color: var(--accent-700); background: var(--accent-tint); }
.admin-btn-sm.danger:hover { border-color: #d1453b; color: #d1453b; background: #fdecec; }
.admin-btn-sm:disabled { opacity: .4; cursor: default; pointer-events: none; }

/* ------------------------------------------------------------- pagination */
.admin-pagination {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: 16px; font-size: 13px; color: var(--ink-soft);
}
.admin-pagination button {
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  color: var(--ink); background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 14px; cursor: pointer;
}
.admin-pagination button:disabled { opacity: .4; cursor: default; }
.admin-pagination button:not(:disabled):hover { border-color: var(--accent); color: var(--accent-700); }

/* --------------------------------------------------------------- switches */
.admin-table input.switch { margin: 0; }

/* ------------------------------------------------------------------ stats */
.admin-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.admin-stat {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.admin-stat-label {
  font-size: 12px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase;
  letter-spacing: .03em; margin: 0 0 6px;
}
.admin-stat-value {
  font-family: var(--font-disp); font-size: 26px; font-weight: 700; color: var(--ink);
  margin: 0; letter-spacing: -0.02em;
}

/* ------------------------------------------------------------------ chart */
/* Dependency-light bar chart: plain divs, heights set inline from data.
   Uses currentColor/CSS variables only, so it stays legible under the
   dark-mode override at the bottom of this file. */
.admin-chart {
  display: flex; align-items: flex-end; gap: 3px; height: 120px;
  padding: 8px 4px 0;
}
.admin-chart-empty { color: var(--ink-soft); font-size: 13px; align-self: center; margin: 0 auto; }
.admin-chart-bar {
  flex: 1 1 0; min-width: 3px; background: var(--accent); border-radius: 3px 3px 0 0;
  position: relative; min-height: 2px;
}
.admin-chart-bar[data-empty="1"] { background: var(--line); }
.admin-chart-bar:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); background: var(--ink); color: var(--paper-2);
  font-size: 11px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; z-index: 5;
}

/* ------------------------------------------------------------ integrations */
.admin-integrations { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.admin-integrations li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.admin-integrations li:last-child { border-bottom: none; }

/* -------------------------------------------------------- confirm modal --
   Reuses .pro-modal-backdrop/.pro-modal from style.css as-is. */
.pro-modal.admin-modal { text-align: start; max-width: 420px; }
.admin-modal-target {
  font-size: 13.5px; font-weight: 600; color: var(--ink); background: var(--paper);
  border-radius: var(--radius); padding: 8px 12px; margin: 0 0 14px;
}
.admin-modal .field { margin-bottom: 14px; }
.admin-modal-actions { display: flex; gap: 10px; }
.admin-modal-actions .btn-primary,
.admin-modal-actions .btn-outline { margin-top: 0; flex: 1; width: auto; }
.admin-modal-actions .btn-primary.danger { background: #d1453b; box-shadow: 0 4px 14px rgba(209,69,59,.28); }
.admin-modal-actions .btn-primary.danger:hover { background: #b93a31; }

/* ------------------------------------------------------- redemptions list */
.admin-redemptions { list-style: none; margin: 0 0 14px; padding: 0; max-height: 320px; overflow-y: auto; }
.admin-redemptions li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.admin-redemptions li:last-child { border-bottom: none; }
.admin-redemptions .who { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-redemptions .when { color: var(--ink-soft); flex: none; }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 640px) {
  .admin-main { padding: 20px 14px 48px; }
  .admin-table th, .admin-table td { padding: 8px 10px; }
  .admin-add-row input { flex: 1 1 100%; }
}

/* -------------------------------------------------------------- dark mode
   Only admin.html loads this stylesheet, so this override is scoped here —
   it does not affect the rest of the (light-only) site. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14121b;
    --paper-2: #1c1a26;
    --ink: #f1eef8;
    --ink-soft: #9791a8;
    --line: #322f3d;
    --accent-tint: #2a2440;
  }
  .admin-search, .admin-add-row input, .admin-card textarea {
    color: var(--ink);
  }
  .admin-badge.free, .admin-badge.off { border-color: var(--line); }
  .admin-chart-bar:hover::after { background: var(--accent-tint); color: var(--ink); }
}
