/* Profile "Admin" tab (public/js/pages/profile/admin/admin.js) */

.admin-dashboard {
  /* Palette in one place. Values follow the Hexxo design system; text reds
     use the darker hover red so small text passes 4.5:1 on tinted fills. */
  --admin-red: #f30c1e;
  --admin-red-text: #b91c1c;
  --admin-red-tint: #fff5f5;
  --admin-red-border: #fecaca;
  --admin-green: #15803d;
  --admin-green-tint: #ecfdf5;
  --admin-amber-text: #92400e;
  --admin-muted-fill: #fafafa;
  --admin-track: #f5f5f5;
  --admin-border: rgba(0, 0, 0, 0.08);
  --admin-text-muted: var(--gray-500);
  --admin-font-display: "Space Grotesk", sans-serif;
  /* The design system's layered card shadow, softened for a dense grid */
  --admin-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.05);
  --admin-shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.06), 0 8px 20px rgba(0, 0, 0, 0.1);

  display: flex;
  flex-direction: column;
  gap: 2.25rem;
  width: 100%;
  min-width: 0;
}

/* Our display rules (flex, inline-flex) would otherwise beat the hidden
   attribute -- including on the dashboard itself, which must stay hidden
   for non-admins who open ?tab=admin. */
.admin-dashboard[hidden],
.admin-dashboard [hidden] {
  display: none;
}

/* ---- Page header ---- */

.admin-dashboard__title {
  margin: 0 0 0.375rem;
  font-family: var(--admin-font-display);
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.admin-dashboard__meta,
.admin-dashboard__empty {
  margin: 0;
  font-size: 0.875rem;
  color: var(--admin-text-muted);
}

.admin-dashboard__meta--stale {
  color: var(--admin-amber-text);
  font-weight: 500;
}

/* Overall "anything to do?" pill under the page title */
.admin-dashboard__status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  margin: 0.75rem 0 0;
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
}

.admin-dashboard__status--ok { background: var(--admin-green-tint); color: var(--admin-green); }
.admin-dashboard__status--alert { background: var(--admin-red-tint); color: var(--admin-red-text); }

/* ---- "Last 30 days" headline band ---- */

/* Near-black like the site nav: reads as a summary banner without competing
   with red, which this page reserves for "needs attention". */
.admin-headline {
  background: var(--black-900, #070707);
  color: var(--white);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  gap: 0.75rem;
}

.admin-headline__title {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72); /* ~10:1 on the band */
}

.admin-headline__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem 1.5rem;
  margin: 0;
}

.admin-headline__item dt {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.72);
}

.admin-headline__item dd {
  margin: 0.25rem 0 0;
  font-family: var(--admin-font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.admin-headline__caption {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.72);
}

/* The light shimmer would glare on black; tone it down */
.admin-headline .skeleton {
  opacity: 0.2;
}

/* ---- Sections ---- */

.admin-dashboard__section {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.admin-dashboard__section-title {
  margin: 0;
  font-family: var(--admin-font-display);
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

/* Tighter than the seller dashboard's 240px tiles so 4 fit per row */
.admin-dashboard .stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0;
}

/* ---- Tiles and panels ---- */

.admin-stat,
.admin-dashboard__panel {
  background: var(--white);
  border: 1px solid var(--admin-border);
  border-radius: 10px;
  box-shadow: var(--admin-shadow);
  padding: 1rem 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}

/* One tile anatomy everywhere: label, then value, then note */
.admin-stat__label {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--admin-text-muted);
}

.admin-stat__value {
  margin: 0;
  font-family: var(--admin-font-display);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.admin-stat__note {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--admin-text-muted);
}

.admin-dashboard__panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}

.admin-dashboard__panel {
  padding: 1.25rem;
  gap: 0.75rem;
}

.admin-dashboard__panel-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.admin-dashboard__panel-footer {
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--admin-border);
  font-size: 0.875rem;
  color: var(--admin-text-muted);
}

.admin-dashboard__panel-link {
  font-weight: 600;
  color: var(--admin-red-text);
  text-decoration: none;
}

.admin-dashboard__panel-link:hover {
  text-decoration: underline;
}

.admin-dashboard__panel.admin-dashboard__error {
  align-items: flex-start;
  border-color: var(--admin-red-border);
  background: var(--admin-red-tint);
}

/* ---- Needs-action tiles ---- */

.admin-action {
  color: inherit;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-action .admin-stat__note {
  margin-top: auto;
  padding-top: 0.25rem;
}

.admin-action--clear {
  background: var(--admin-muted-fill);
  box-shadow: none;
}

.admin-action--clear .admin-stat__value {
  color: var(--admin-green);
}

.admin-action--alert {
  background: var(--admin-red-tint);
  border-color: var(--admin-red-border);
}

.admin-action--alert .admin-stat__value {
  color: var(--admin-red);
}

.admin-action--link .admin-stat__note {
  font-weight: 600;
  color: var(--admin-red-text);
}

.admin-action--link:hover {
  transform: translateY(-2px);
  box-shadow: var(--admin-shadow-hover);
}

.admin-action--link:focus-visible {
  outline: 2px solid var(--admin-red-text);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .admin-action { transition: none; }
  .admin-action--link:hover { transform: none; }
}

/* ---- Loading placeholders ---- */

/* Shaped like a stat tile so nothing jumps when the real numbers arrive.
   Shimmer comes from components/skeleton.css. */
.admin-skeleton {
  display: block;
}

.admin-skeleton--label { width: 55%; height: 0.75rem; }
.admin-skeleton--value { width: 40%; height: 1.75rem; }
.admin-skeleton--note { width: 75%; height: 0.75rem; }
.admin-skeleton--row { width: 100%; height: 1.25rem; }

/* ---- Chart ---- */

/* Chart.js (maintainAspectRatio: false) fills its parent, so the parent needs
   a fixed height and position: relative. */
.admin-dashboard__chart {
  position: relative;
  height: 220px;
}

/* ---- Lists ---- */

.admin-dashboard__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.admin-dashboard__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.admin-dashboard__count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Status badges: profile.css's status backgrounds, with darker text so the
   small label passes 4.5:1 contrast. */
.admin-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: var(--admin-track);
  color: #4a4a4a;
}

.admin-badge--delivered { background: var(--color-status-delivered-bg); color: var(--admin-green); }
.admin-badge--processing { background: var(--color-status-processing-bg); color: #4338ca; }
.admin-badge--shipped { background: var(--color-status-shipped-bg); color: var(--admin-amber-text); }
.admin-badge--pending_authentication { background: #e0e7ff; color: #3730a3; }
.admin-badge--refunded { background: #fee2e2; color: #991b1b; }

.admin-brand {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-brand__track {
  height: 8px;
  background: var(--admin-track);
  border-radius: 999px;
}

/* Same light-to-brand-red ramp as the signups chart, sized to the track
   (background-size) so a short bar shows only the light end. */
.admin-brand__bar {
  height: 100%;
  background: linear-gradient(90deg, #ffa3ab, var(--admin-red));
  background-size: var(--track-width, 100%) 100%;
  border-radius: 999px;
}

/* ---- Tables ---- */

.admin-dashboard__table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--admin-border);
  white-space: nowrap;
}

.admin-table th {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--admin-text-muted);
}

@media (max-width: 480px) {
  /* Two tiles per row on phones instead of one long column */
  .admin-dashboard .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-stat__value {
    font-size: 1.375rem;
  }
}
