/* Admin design system — extracted from layouts/admin.html.erb (Phase 1 of
 * docs/design_overhaul_plan.md). Class names are a stable contract used across
 * ~45 admin views; recipes here are the single source of truth.
 *
 * Principles: cards = surface-2 + 1px hairline + r-card, NO rest shadow.
 * Shadows mean "floating" (drawer, skip link). One accent (--brew-amber),
 * used for actions only. Hierarchy from weight + ink-vs-muted, not size. */

body {
  /* Sourced from club theme tokens (color_style + palette_style) with the brew
   * palette as fallback. Defined on body, not :root — club tokens live on <body>.
   * Sidebar is a darkened *tone* of the brand (hue retained, mixed toward
   * near-black) so it reads as subdued chrome and keeps near-white text legible
   * on any brand color. */
  --brew-dark:    color-mix(in srgb, var(--color-primary, #150b02) 35%, #0a0a0a);
  --brew-amber:   var(--color-primary-on-surface, #D97706);
  --brew-copper:  var(--color-primary, #B45309);
  --brew-cream:   var(--surface, #FAF6EF);
  --brew-text:    var(--ink, #1C1410);
  --brew-muted:   var(--muted, #7C6248);
  /* Near-white for sidebar text/icons — the sidebar is always dark, so this is
   * independent of --color-primary-fg (contrast-matched to the full primary,
   * not this darkened tone). */
  --brew-on-dark: rgba(255, 255, 255, 0.92);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Geist Sans', sans-serif;
  background: var(--brew-cream);
  color: var(--brew-text);
  font-size: 15px;
}

/* ── Sidebar ─────────────────────────────────── */

.brew-sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--brew-dark);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid color-mix(in srgb, var(--brew-on-dark) 8%, transparent);
  scrollbar-width: none;
}

.brew-sidebar::-webkit-scrollbar { display: none; }

.sidebar-header { padding: 18px 14px 8px; }

.sidebar-logo-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 3px;
}

.sidebar-logo-mark {
  width: 26px;
  height: 26px;
  background: color-mix(in srgb, var(--brew-on-dark) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--brew-on-dark) 22%, transparent);
  border-radius: var(--r-control, 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-club-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--brew-on-dark);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.sidebar-subtitle {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--brew-on-dark) 64%, transparent);
  font-weight: 600;
  padding-left: 35px;
}

.sidebar-divider {
  height: 1px;
  background: color-mix(in srgb, var(--brew-on-dark) 14%, transparent);
  margin: 8px 0 2px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: 14px;
  transform: translateY(-160%);
  background: var(--surface-2, #FFF7ED);
  color: var(--ink, #92400E);
  border: 1px solid var(--line, rgba(217, 119, 6, 0.35));
  border-radius: var(--r-control, 8px);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  z-index: 50;
  box-shadow: var(--shadow-float);
  transition: transform 0.16s ease;
}

.skip-link:focus { transform: translateY(0); }

/* ── Nav ─────────────────────────────────────── */

.sidebar-nav {
  flex: 1;
  padding: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--brew-on-dark) 60%, transparent);
  padding: 10px 11px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px 7px 13px;
  border-radius: var(--r-control, 8px);
  font-size: 13px;
  font-weight: 400;
  color: color-mix(in srgb, var(--brew-on-dark) 76%, transparent);
  transition: background 0.15s ease, color 0.15s ease;
  text-decoration: none;
  line-height: 1.25;
  position: relative;
  margin: 0 6px;
}

.nav-item:hover {
  background: color-mix(in srgb, var(--brew-on-dark) 8%, transparent);
  color: var(--brew-on-dark);
}

.nav-item:focus-visible {
  outline: 2px solid var(--brew-on-dark);
  outline-offset: 1px;
}

.nav-item.active {
  background: color-mix(in srgb, var(--brew-on-dark) 13%, transparent);
  color: var(--brew-on-dark);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--brew-on-dark);
  border-radius: 0 2px 2px 0;
}

.nav-icon-shell {
  width: 28px;
  height: 28px;
  border-radius: var(--r-control, 8px);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-animated-svg {
  width: 20px;
  height: 20px;
  display: block;
  overflow: visible;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.nav-item:hover .nav-animated-svg,
.nav-item.active .nav-animated-svg { opacity: 1; }

.nav-divider {
  border: none;
  height: 1px;
  background: color-mix(in srgb, var(--brew-on-dark) 12%, transparent);
  margin: 10px 12px;
}

.nav-item-utility {
  color: color-mix(in srgb, var(--brew-on-dark) 62%, transparent);
  font-size: 12.5px;
}

.nav-item-utility:hover {
  color: color-mix(in srgb, var(--brew-on-dark) 90%, transparent);
  background: color-mix(in srgb, var(--brew-on-dark) 4%, transparent);
}

/* ── Main area ───────────────────────────────── */

.brew-main {
  flex: 1;
  min-height: 100vh;
  background: var(--brew-cream);
}

.brew-main-inner {
  padding: 40px 44px;
  max-width: 1080px;
}

/* ── Mobile header ───────────────────────────── */

.mobile-header {
  display: none;
  align-items: center;
  gap: 10px;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--brew-dark);
  border-bottom: 1px solid color-mix(in srgb, var(--brew-on-dark) 13%, transparent);
  padding: 0 14px;
  z-index: 35;
}

.mobile-hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--r-control, 8px);
  color: color-mix(in srgb, var(--brew-on-dark) 76%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.mobile-hamburger:hover { background: color-mix(in srgb, var(--brew-on-dark) 10%, transparent); }

.mobile-club-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--brew-on-dark);
  flex: 1;
}

/* ── Drawer backdrop ─────────────────────────── */

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 0, 0.55);
  z-index: 38;
}
.drawer-backdrop.backdrop-open { display: block; }

/* ── Responsive grid utilities ───────────────── */

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* Cards stretch so paired cards in a row always match heights. */
.admin-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.admin-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Responsive overrides ────────────────────── */

@media (max-width: 768px) {
  body { display: block !important; }

  .mobile-header { display: flex; }

  .brew-sidebar {
    position: fixed;
    top: 0; left: 0;
    z-index: 39;
    transform: translateX(-100%);
    transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100dvh;
    width: 260px;
  }

  .brew-sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: var(--shadow-float); /* the open drawer genuinely floats */
  }

  .brew-main {
    padding-top: 52px;
    min-height: 100dvh;
  }

  .brew-main-inner { padding: 24px 16px 40px; }

  /* Any table not already inside admin-table-wrap gets a scroll container on
   * mobile so the page body never overflows horizontally. */
  .brew-main-inner table:not(.admin-table-wrap table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* Card + brew-card chrome should not clip scrollable content on mobile. */
  .brew-card { overflow: visible; }

  .admin-stat-grid { grid-template-columns: 1fr 1fr; }
  .admin-2col      { grid-template-columns: 1fr; }
  .admin-field-row { grid-template-columns: 1fr; margin-bottom: 0; }
  .admin-field-row > * { margin-bottom: 16px; }

  /* Hide lower-priority columns to keep core info readable. */
  .member-date { display: none !important; }
  .admin-col-hide-mobile { display: none !important; }

  /* Action button groups that sit next to a heading should stack on small
   * screens (the shared/page_header partial already uses flex-wrap). */
  .admin-actions-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .event-row {
    flex-wrap: wrap;
    gap: 6px 12px;
  }
  .event-row > div:first-child { flex-basis: 100%; }
  .event-row .event-badges     { flex-shrink: 0; }
}

@media (max-width: 400px) {
  .admin-stat-grid { grid-template-columns: 1fr; }

  /* Tighten inner padding on very small phones. */
  .brew-main-inner { padding: 16px 12px 32px; }
}

/* ── Flash messages ──────────────────────────── */
/* Self-contained light fills (legible on light or dark canvas). */

.flash-notice,
.flash-alert {
  padding: 11px 16px;
  border-radius: var(--r-control, 8px);
  margin-bottom: 24px;
  font-size: 13px;
}

.flash-notice {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  color: #14532D;
}

.flash-alert {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  color: #78350F;
}

/* Optional "what to do next" link rendered inside a flash-notice. */
.flash-next-step {
  display: inline-block;
  margin-left: 10px;
  font-weight: 600;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.flash-next-step:hover { opacity: 0.75; }

/* ── Cards ───────────────────────────────────── */
/* One recipe. brew-card is the base; stat-card / insight-card are the same
 * surface with their own padding. No rest shadow, no hover lift. */

.brew-card,
.stat-card,
.insight-card {
  background: var(--surface-2, #FFFFFF);
  border: 1px solid var(--line, rgba(180, 140, 80, 0.12));
  border-radius: var(--r-card, 12px);
}

.stat-card { padding: 20px; }

.insight-card { padding: 20px; }

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-control, 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.stat-number {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--brew-text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-number.warn { color: var(--brew-amber); }

.stat-label {
  font-size: 13px;
  color: var(--brew-muted);
  font-weight: 500;
  margin-top: 6px;
}

.stat-action {
  font-size: 12px;
  color: var(--brew-amber);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 10px;
  transition: color 0.12s;
}

.stat-action:hover { color: var(--brew-copper); }

/* ── Section headings ────────────────────────── */

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--brew-text);
}

/* ── Warning banner ──────────────────────────── */

.warning-banner {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--r-control, 8px);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.warning-banner p { font-size: 13px; color: #78350F; margin: 0; }
.warning-banner a { font-size: 12.5px; color: #92400E; font-weight: 500; text-decoration: underline; white-space: nowrap; }
.warning-banner a:hover { color: #78350F; }

/* ── Rows (members, events, activity) ────────── */

.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line, rgba(180, 140, 80, 0.08));
}

.member-row:last-child { border-bottom: none; }

.avatar-ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary, #D97706);
  color: var(--color-primary-fg, #1C0F06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line, rgba(180, 140, 80, 0.08));
}

.event-row:last-child { border-bottom: none; }

.event-row-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  margin: 0 -10px;
  border-radius: var(--r-control, 8px);
  border-bottom: 1px solid var(--line, rgba(180, 140, 80, 0.08));
  text-decoration: none;
  transition: background 0.12s;
}
.event-row-link:last-child { border-bottom: none; }
.event-row-link:hover { background: color-mix(in srgb, var(--color-primary, #D97706) 5%, transparent); }
.event-row-chevron {
  color: var(--brew-muted);
  flex-shrink: 0;
  transition: color 0.12s ease;
}
.event-row-link:hover .event-row-chevron { color: var(--brew-amber); }

.activity-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 8px;
  margin: 0 -8px;
  border-radius: var(--r-control, 8px);
  border-bottom: 1px solid var(--line, rgba(180, 140, 80, 0.07));
  text-decoration: none;
  transition: background 0.12s;
}
.activity-row:last-child { border-bottom: none; }
.activity-row:hover { background: color-mix(in srgb, var(--color-primary, #D97706) 4%, transparent); }
.activity-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r-control, 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.activity-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--brew-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-time {
  font-size: 11px;
  color: var(--brew-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Pills & badges ──────────────────────────── */

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

/* Self-contained tint pairs — legible on light or dark canvas. */
.pill-published { background: #F0FDF4; color: #15803D; }
.pill-draft     { background: #F3F4F6; color: #374151; }
.pill-canceled  { background: #FEF2F2; color: #B91C1C; }

.type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--color-primary-tint, rgba(217, 119, 6, 0.1));
  color: var(--color-primary-on-tint, #B45309);
  flex-shrink: 0;
}

/* ── Insight title (card eyebrow) ────────────── */

.insight-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brew-muted);
  margin-bottom: 16px;
}

.health-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--line, rgba(180, 140, 80, 0.12));
  overflow: hidden;
  margin-top: 8px;
}
.health-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #16A34A;
  transition: width 0.6s ease;
}

/* ── Quick actions bar ───────────────────────── */

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}
.quick-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2, #ffffff);
  color: var(--brew-text);
  border: 1px solid var(--line, rgba(180, 140, 80, 0.2));
  padding: 9px 14px;
  border-radius: var(--r-control, 8px);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.12s;
}
.quick-action:hover {
  border-color: var(--color-primary-border, rgba(217, 119, 6, 0.45));
}
.quick-action svg { color: var(--brew-amber); flex-shrink: 0; }

/* ── Empty state ─────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--brew-muted);
  font-size: 13px;
}

.empty-state svg {
  width: 32px;
  height: 32px;
  margin: 0 auto 10px;
  opacity: 0.35;
}

/* ── Brew select / inputs ────────────────────── */

.brew-select {
  background: var(--surface-2, #ffffff);
  border: 1px solid var(--line, rgba(180, 140, 80, 0.22));
  border-radius: var(--r-control, 8px);
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--brew-text);
  outline: none;
  transition: border-color 0.12s;
  width: 100%;
  min-height: 38px;
}

.brew-select:focus {
  border-color: var(--ink, #1C1410);
}
