/* ============================================================
   cxq-membership -- Design System
   Palette: deep slate bg, gold accent, crisp white type
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&family=Playfair+Display:wght@700;900&display=swap');

:root {
  /* Core palette */
  --bg:          #0d1117;
  --bg-card:     #161b22;
  --bg-card-2:   #1c2330;
  --bg-elevated: #21262d;
  --border:      rgba(255,255,255,0.08);
  --border-accent: rgba(212,175,55,0.3);

  /* Typography */
  --text:        #e6edf3;
  --text-muted:  #7d8590;
  --text-dim:    #484f58;

  /* Accents */
  --gold:        #d4af37;
  --gold-bright: #f0c929;
  --gold-dim:    rgba(212,175,55,0.12);
  --gold-glow:   rgba(212,175,55,0.25);

  --green:       #3fb950;
  --green-dim:   rgba(63,185,80,0.12);
  --red:         #f85149;
  --red-dim:     rgba(248,81,73,0.12);
  --amber:       #e3b341;
  --amber-dim:   rgba(227,179,65,0.12);
  --blue:        #58a6ff;
  --blue-dim:    rgba(88,166,255,0.12);

  /* Fonts */
  --font-body:    'DM Sans', sans-serif;
  --font-display: 'Playfair Display', serif;
  --font-mono:    'DM Mono', monospace;

  /* Spacing */
  --sidebar-w: 220px;
  --radius:    8px;
  --radius-lg: 14px;
}

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

html { -webkit-font-smoothing: antialiased; }

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

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); }

table { border-collapse: collapse; width: 100%; }
th { font-weight: 600; text-align: left; }
input, select, textarea { font-family: var(--font-body); outline: none; background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 8px 12px; font-size: 14px; width: 100%; transition: border-color 0.15s; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
button { cursor: pointer; font-family: var(--font-body); }
pre { font-family: var(--font-mono); white-space: pre-wrap; word-break: break-all; }

/* -- App Shell -- Sidebar Layout ----------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

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

.sidebar-logo .logo-pre {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: block;
  margin-bottom: 2px;
}

.sidebar-logo .logo-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-logo .logo-accent {
  color: var(--gold);
}

.sidebar-nav {
  padding: 16px 0;
  flex: 1;
}

.nav-section {
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 8px 4px;
  display: block;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  position: relative;
}

.nav-link:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.nav-link.active {
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid var(--border-accent);
}

.nav-link .nav-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-link.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.nav-badge.amber { background: var(--amber); color: #1a1a1a; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

.sidebar-footer .user-email {
  display: block;
  color: var(--text-muted);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer a {
  color: var(--text-dim);
  font-size: 12px;
}
.sidebar-footer a:hover { color: var(--text-muted); }

/* Main content area */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 32px 36px;
  max-width: 1200px;
}

/* -- Page Header -------------------------------------------- */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
}

.page-header .page-subtitle {
  color: var(--text-muted);
  font-size: 13.5px;
}

/* -- Stat Cards --------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gold);
  opacity: 0;
  transition: opacity 0.2s;
}

.stat-card:hover { border-color: var(--border-accent); transform: translateY(-1px); }
.stat-card:hover::before { opacity: 1; }

.stat-card.accent-green::before { background: var(--green); opacity: 1; }
.stat-card.accent-amber::before { background: var(--amber); opacity: 1; }
.stat-card.accent-red::before { background: var(--red); opacity: 1; }
.stat-card.accent-blue::before { background: var(--blue); opacity: 1; }
.stat-card.accent-gold::before { background: var(--gold); opacity: 1; }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
  color: var(--text);
  margin-bottom: 8px;
}

.stat-value.text-green { color: var(--green); }
.stat-value.text-amber { color: var(--amber); }
.stat-value.text-red   { color: var(--red); }
.stat-value.text-gold  { color: var(--gold); }

.stat-sub {
  font-size: 12px;
  color: var(--text-dim);
}

/* -- Cards -------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card-action {
  font-size: 12px;
  color: var(--gold);
}

/* -- Action Required Banner --------------------------------- */
.action-banner {
  display: flex;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 28px;
  align-items: center;
  flex-wrap: wrap;
}

.action-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.action-count {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
}

.action-count.amber { color: var(--amber); }
.action-count.red   { color: var(--red); }

.action-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.action-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  margin: 0 8px;
}

.action-cta {
  margin-left: auto;
  font-size: 12px;
}

/* -- Two-col Grid ------------------------------------------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* -- Data Table --------------------------------------------- */
.data-table {
  width: 100%;
  font-size: 13px;
}

.data-table thead tr {
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 0 12px;
}

.data-table td {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { color: var(--text); }

.event-type {
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--gold);
  display: inline-block;
}

.time-ago { color: var(--text-dim); font-size: 12px; font-family: var(--font-mono); }

/* -- Status Pill -------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
}

.pill-green  { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(63,185,80,0.3); }
.pill-amber  { background: var(--amber-dim);  color: var(--amber);  border: 1px solid rgba(227,179,65,0.3); }
.pill-red    { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(248,81,73,0.3); }
.pill-blue   { background: var(--blue-dim);   color: var(--blue);   border: 1px solid rgba(88,166,255,0.3); }
.pill-gold   { background: var(--gold-dim);   color: var(--gold);   border: 1px solid var(--border-accent); }
.pill-muted  { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }

/* -- Member Portal Specific --------------------------------- */
.portal-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.portal-hero::after {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--gold-dim) 0%, transparent 70%);
  pointer-events: none;
}

.portal-hero .member-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
}

.portal-hero .member-since {
  color: var(--text-muted);
  font-size: 13px;
}

.portal-hero .member-number {
  font-family: var(--font-mono);
  color: var(--gold);
  font-size: 12px;
  margin-top: 12px;
  display: inline-block;
  border: 1px solid var(--border-accent);
  padding: 4px 12px;
  border-radius: 4px;
  background: var(--gold-dim);
}

.dues-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.dues-amount {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 900;
  color: var(--red);
  margin: 8px 0 4px;
}

.dues-amount.paid { color: var(--green); }

/* -- Btn ---------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-gold {
  background: var(--gold);
  color: #0d1117;
  border-color: var(--gold);
}
.btn-gold:hover { background: var(--gold-bright); color: #0d1117; }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--bg-elevated); color: var(--text); border-color: rgba(255,255,255,0.15); }

.btn-ghost {
  background: transparent;
  color: var(--gold);
  border-color: var(--border-accent);
}
.btn-ghost:hover { background: var(--gold-dim); }

/* -- Top Bar (simple, for non-sidebar pages) ---------------- */
.topbar {
  height: 52px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-logo {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.topbar-logo span { color: var(--gold); }

.topbar-links { display: flex; gap: 4px; }

.topbar-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}

.topbar-link:hover { background: var(--bg-elevated); color: var(--text); }
.topbar-link.active { color: var(--gold); background: var(--gold-dim); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.topbar-email { font-size: 12px; color: var(--text-dim); }

/* -- Page wrapper for topbar layout ------------------------ */
.page-wrap { padding: 28px 32px; max-width: 1100px; margin: 0 auto; }

/* -- Superadmin panel overrides ----------------------------- */
.sa-table { width: 100%; font-size: 13px; }
.sa-table th { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); padding: 0 12px 12px; }
.sa-table td { padding: 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.sa-table tr:last-child td { border-bottom: none; }
.sa-table tr:hover td { background: var(--bg-elevated); }
.sa-table td:first-child, .sa-table th:first-child { padding-left: 0; }

/* -- Noise texture overlay ---------------------------------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

/* Keep all content above noise layer */
.app-shell, .topbar, .page-wrap { position: relative; z-index: 1; }

/* -- Animations --------------------------------------------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stat-card { animation: fadeUp 0.35s ease both; }
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.10s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.20s; }

.card { animation: fadeUp 0.4s ease both; animation-delay: 0.25s; }

/* -- Responsive --------------------------------------------- */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; padding: 20px; }
}

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

/* -- Misc Utilities ----------------------------------------- */
.mono   { font-family: var(--font-mono); }
.muted  { color: var(--text-muted); }
.dimmed { color: var(--text-dim); }
.gold   { color: var(--gold); }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-1   { margin-top: 4px; }
.mt-2   { margin-top: 8px; }
.mt-4   { margin-top: 16px; }
.mb-2   { margin-bottom: 8px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.mb-8   { margin-bottom: 32px; }
.ml-auto { margin-left: auto; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.w-full  { width: 100%; }
.overflow-x-auto { overflow-x: auto; }
.space-x-2 > * + * { margin-left: 8px; }
