/*
 * DRC Rewards — customer portal design system.
 *
 * Visual direction mirrors the internal Nexus UI (deep-navy surfaces +
 * vibrant electric-blue primary) but is a self-contained, customer-facing
 * stylesheet. This is a separate Django project from Nexus, so we mirror the
 * design *tokens* rather than importing Nexus's static files.
 *
 * Theming: all colors are CSS custom properties. The default (:root) theme is
 * DARK. A user toggle flips :root[data-theme="light"] for a light theme. The
 * same token names carry both themes, so every rc- component themes for free.
 *
 * Conventions:
 *   - Every component class is prefixed `rc-` and is token-driven.
 *   - 4px spacing base; radius 4/6/10; type scale 12-24px.
 */

/* ---------- Tokens: dark (default) ---------- */
:root {
  --rc-bg: #0b1220;
  --rc-surface: #111a2e;
  --rc-surface-muted: #172238;
  --rc-surface-strong: #1f2c47;

  --rc-text: #e6ecf5;
  --rc-muted: #94a3b8;
  --rc-subtle: #64748b;

  --rc-border: #1e2a44;
  --rc-border-strong: #2d3a55;

  --rc-primary: #3b82f6;
  --rc-primary-hover: #60a5fa;
  --rc-primary-active: #2563eb;
  --rc-primary-on: #ffffff;
  --rc-primary-soft: rgba(59, 130, 246, 0.14);

  --rc-success: #34d399;
  --rc-success-bg: #0e2a1c;
  --rc-warning: #fbbf24;
  --rc-warning-bg: #2a200a;
  --rc-danger: #f87171;
  --rc-danger-bg: #2a1212;

  --rc-focus-ring: rgba(59, 130, 246, 0.45);

  --rc-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40);
  --rc-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --rc-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.50);

  /* Spacing */
  --rc-space-1: 4px;
  --rc-space-2: 8px;
  --rc-space-3: 12px;
  --rc-space-4: 16px;
  --rc-space-5: 24px;
  --rc-space-6: 32px;
  --rc-space-7: 48px;

  /* Radius */
  --rc-radius-sm: 4px;
  --rc-radius-md: 6px;
  --rc-radius-lg: 10px;
  --rc-radius-pill: 999px;

  /* Type */
  --rc-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rc-fs-xs: 12px;
  --rc-fs-sm: 13px;
  --rc-fs-md: 14px;
  --rc-fs-lg: 16px;
  --rc-fs-xl: 20px;
  --rc-fs-xxl: 24px;
  --rc-fs-display: 30px;
  --rc-lh: 1.5;

  --rc-container: 44rem;
}

/* ---------- Tokens: light (opt-in via toggle) ---------- */
:root[data-theme="light"] {
  --rc-bg: #f1f5f9;
  --rc-surface: #ffffff;
  --rc-surface-muted: #f8fafc;
  --rc-surface-strong: #eef2f7;

  --rc-text: #0f172a;
  --rc-muted: #475569;
  --rc-subtle: #64748b;

  --rc-border: #e2e8f0;
  --rc-border-strong: #cbd5e1;

  --rc-primary: #2563eb;
  --rc-primary-hover: #1d4ed8;
  --rc-primary-active: #1e40af;
  --rc-primary-on: #ffffff;
  --rc-primary-soft: rgba(37, 99, 235, 0.10);

  --rc-success: #059669;
  --rc-success-bg: #dcfce7;
  --rc-warning: #b45309;
  --rc-warning-bg: #fef3c7;
  --rc-danger: #dc2626;
  --rc-danger-bg: #fee2e2;

  --rc-focus-ring: rgba(37, 99, 235, 0.35);

  --rc-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
  --rc-shadow-md: 0 4px 12px rgba(15, 23, 42, 0.10);
  --rc-shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--rc-font);
  font-size: var(--rc-fs-md);
  line-height: var(--rc-lh);
  color: var(--rc-text);
  background-color: var(--rc-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--rc-primary);
  text-decoration: none;
}

a:hover {
  color: var(--rc-primary-hover);
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--rc-focus-ring);
  border-radius: var(--rc-radius-sm);
}

h1, h2, h3 {
  line-height: 1.25;
  font-weight: 650;
  color: var(--rc-text);
}

/* ---------- App shell ---------- */
.rc-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.rc-appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rc-space-3);
  min-height: 60px;
  padding: 0 var(--rc-space-5);
  background-color: var(--rc-surface-strong);
  border-bottom: 1px solid var(--rc-border);
}

.rc-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--rc-space-2);
  font-weight: 700;
  font-size: var(--rc-fs-lg);
  letter-spacing: -0.01em;
  color: var(--rc-text);
}

.rc-brand:hover {
  text-decoration: none;
  color: var(--rc-text);
}

.rc-appbar-left {
  display: inline-flex;
  align-items: center;
  gap: var(--rc-space-2);
}

/* ---------- Menu (hamburger disclosure) ---------- */
.rc-menu {
  position: relative;
}

.rc-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  cursor: pointer;
  color: var(--rc-muted);
  background-color: transparent;
  border: 1px solid var(--rc-border-strong);
  border-radius: var(--rc-radius-md);
  list-style: none;
  transition: background-color 120ms ease, color 120ms ease;
}

/* Hide the native disclosure triangle (the hamburger SVG is the marker). */
.rc-menu-toggle::-webkit-details-marker { display: none; }
.rc-menu-toggle::marker { content: ""; }

.rc-menu-toggle:hover,
.rc-menu[open] > .rc-menu-toggle {
  background-color: var(--rc-surface-muted);
  color: var(--rc-text);
}

.rc-menu-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--rc-focus-ring);
}

.rc-menu-panel {
  position: absolute;
  top: calc(100% + var(--rc-space-2));
  left: 0;
  z-index: 30;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  padding: var(--rc-space-2);
  background-color: var(--rc-surface);
  border: 1px solid var(--rc-border-strong);
  border-radius: var(--rc-radius-md);
  box-shadow: var(--rc-shadow-lg);
}

.rc-menu-panel a {
  padding: var(--rc-space-2) var(--rc-space-3);
  color: var(--rc-text);
  border-radius: var(--rc-radius-sm);
  font-size: var(--rc-fs-sm);
  font-weight: 500;
}

.rc-menu-panel a:hover {
  text-decoration: none;
  background-color: var(--rc-surface-muted);
}

.rc-menu-sep {
  height: 0;
  margin: var(--rc-space-2) 0;
  border: 0;
  border-top: 1px solid var(--rc-border);
}

.rc-appbar-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--rc-space-2);
}

/* ---------- Theme toggle ---------- */
.rc-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  cursor: pointer;
  color: var(--rc-muted);
  background-color: transparent;
  border: 1px solid var(--rc-border-strong);
  border-radius: var(--rc-radius-md);
  transition: background-color 120ms ease, color 120ms ease;
}

.rc-theme-toggle:hover {
  background-color: var(--rc-surface-muted);
  color: var(--rc-text);
}

.rc-theme-toggle .rc-icon-sun { display: none; }
.rc-theme-toggle .rc-icon-moon { display: block; }
:root[data-theme="light"] .rc-theme-toggle .rc-icon-sun { display: block; }
:root[data-theme="light"] .rc-theme-toggle .rc-icon-moon { display: none; }

/* ---------- Layout ---------- */
.rc-main {
  flex: 1;
  width: 100%;
  max-width: var(--rc-container);
  margin: 0 auto;
  padding: var(--rc-space-6) var(--rc-space-4) var(--rc-space-7);
}

.rc-page-header {
  margin-bottom: var(--rc-space-5);
}

.rc-page-title {
  margin: 0;
  font-size: var(--rc-fs-display);
  letter-spacing: -0.02em;
}

.rc-page-subtitle {
  margin: var(--rc-space-2) 0 0;
  color: var(--rc-muted);
  font-size: var(--rc-fs-lg);
}

/* ---------- Cards ---------- */
.rc-card {
  background-color: var(--rc-surface);
  border: 1px solid var(--rc-border);
  border-radius: var(--rc-radius-lg);
  box-shadow: var(--rc-shadow-sm);
  padding: var(--rc-space-5);
  margin-bottom: var(--rc-space-5);
}

.rc-card-title {
  margin: 0 0 var(--rc-space-1);
  font-size: var(--rc-fs-xl);
}

.rc-note {
  margin: 0 0 var(--rc-space-4);
  color: var(--rc-muted);
  font-size: var(--rc-fs-sm);
}

.rc-empty {
  margin: 0;
  color: var(--rc-muted);
}

/* ---------- Summary (key/value rows) ---------- */
.rc-summary {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rc-summary li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rc-space-4);
  padding: var(--rc-space-3) 0;
  border-bottom: 1px solid var(--rc-border);
}

.rc-summary li:last-child {
  border-bottom: 0;
}

.rc-summary .rc-label {
  color: var(--rc-muted);
}

.rc-summary .rc-value {
  font-weight: 600;
  text-align: right;
}

.rc-summary .rc-value-strong {
  font-size: var(--rc-fs-xl);
  color: var(--rc-primary);
}

/* ---------- Activity list ---------- */
.rc-activity {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rc-activity li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--rc-space-4);
  padding: var(--rc-space-3) 0;
  border-bottom: 1px solid var(--rc-border);
}

.rc-activity li:last-child {
  border-bottom: 0;
}

.rc-activity .rc-activity-main {
  min-width: 0;
}

.rc-activity .rc-when {
  color: var(--rc-subtle);
  font-size: var(--rc-fs-xs);
}

.rc-activity .rc-what {
  color: var(--rc-text);
}

.rc-activity .rc-delta {
  white-space: nowrap;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rc-delta-positive { color: var(--rc-success); }
.rc-delta-negative { color: var(--rc-danger); }

/* ---------- Badge / tier pill ---------- */
.rc-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--rc-space-2);
  font-size: var(--rc-fs-xs);
  font-weight: 600;
  border-radius: var(--rc-radius-pill);
  background-color: var(--rc-primary-soft);
  color: var(--rc-primary);
}

/* ---------- Pager ---------- */
.rc-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rc-space-3);
  margin-top: var(--rc-space-4);
}

/* ---------- Buttons ---------- */
.rc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--rc-space-2);
  padding: var(--rc-space-3) var(--rc-space-5);
  font-family: inherit;
  font-size: var(--rc-fs-md);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  color: var(--rc-text);
  background-color: var(--rc-surface-muted);
  border: 1px solid var(--rc-border-strong);
  border-radius: var(--rc-radius-md);
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
  text-decoration: none;
}

.rc-button:hover {
  background-color: var(--rc-surface-strong);
  text-decoration: none;
  color: var(--rc-text);
}

.rc-button-primary {
  color: var(--rc-primary-on);
  background-color: var(--rc-primary);
  border-color: var(--rc-primary);
}

.rc-button-primary:hover {
  color: var(--rc-primary-on);
  background-color: var(--rc-primary-hover);
  border-color: var(--rc-primary-hover);
}

.rc-button-primary:active {
  background-color: var(--rc-primary-active);
  border-color: var(--rc-primary-active);
}

.rc-button-ghost {
  background-color: transparent;
  border-color: transparent;
  color: var(--rc-muted);
  padding: var(--rc-space-2) var(--rc-space-3);
}

.rc-button-ghost:hover {
  background-color: var(--rc-surface-muted);
  color: var(--rc-text);
}

.rc-button-block {
  width: 100%;
}

.rc-button[disabled],
.rc-button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- Forms ---------- */
/* Works with Django's {{ form.as_p }} (each field wrapped in <p>). */
.rc-form p {
  margin: 0 0 var(--rc-space-4);
}

/* Field labels stack above their input. The switch (.rc-switch) is also a
   <label> but is its own flex component, so it's excluded here — otherwise
   display:block would override its flex layout. */
.rc-form label:not(.rc-switch) {
  display: block;
  margin-bottom: var(--rc-space-1);
  font-size: var(--rc-fs-sm);
  font-weight: 600;
  color: var(--rc-text);
}

.rc-form input[type="text"],
.rc-form input[type="email"],
.rc-form input[type="password"],
.rc-form input:not([type]),
.rc-input {
  width: 100%;
  padding: var(--rc-space-3);
  font-family: inherit;
  font-size: var(--rc-fs-md);
  color: var(--rc-text);
  background-color: var(--rc-surface-muted);
  border: 1px solid var(--rc-border-strong);
  border-radius: var(--rc-radius-md);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.rc-form input::placeholder {
  color: var(--rc-subtle);
}

.rc-form input:focus-visible {
  border-color: var(--rc-primary);
  box-shadow: 0 0 0 3px var(--rc-focus-ring);
  outline: none;
}

.rc-form .helptext,
.rc-form .helptext * {
  display: block;
  margin-top: var(--rc-space-1);
  color: var(--rc-muted);
  font-size: var(--rc-fs-xs);
  font-weight: 400;
}

.rc-form ul.errorlist {
  list-style: none;
  margin: 0 0 var(--rc-space-2);
  padding: var(--rc-space-2) var(--rc-space-3);
  background-color: var(--rc-danger-bg);
  border-radius: var(--rc-radius-sm);
  color: var(--rc-danger);
  font-size: var(--rc-fs-sm);
}

.rc-form-actions {
  margin-top: var(--rc-space-5);
}

.rc-form-links {
  margin-top: var(--rc-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--rc-space-2);
  font-size: var(--rc-fs-sm);
}

/* ---------- Banner / alert ---------- */
.rc-banner {
  display: flex;
  gap: var(--rc-space-3);
  padding: var(--rc-space-3) var(--rc-space-4);
  margin-bottom: var(--rc-space-4);
  background-color: var(--rc-surface);
  border: 1px solid var(--rc-border);
  border-left: 3px solid var(--rc-primary);
  border-radius: var(--rc-radius-md);
  font-size: var(--rc-fs-sm);
}

.rc-banner-danger {
  border-left-color: var(--rc-danger);
  background-color: var(--rc-danger-bg);
}

.rc-banner-success {
  border-left-color: var(--rc-success);
  background-color: var(--rc-success-bg);
}

/* ---------- Auth / centered single-card layout ---------- */
.rc-auth {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--rc-space-6) var(--rc-space-4);
}

.rc-auth-card {
  width: 100%;
  max-width: 25rem;
  background-color: var(--rc-surface);
  border: 1px solid var(--rc-border);
  border-radius: var(--rc-radius-lg);
  box-shadow: var(--rc-shadow-lg);
  padding: var(--rc-space-6);
}

.rc-auth-title {
  margin: 0 0 var(--rc-space-2);
  font-size: var(--rc-fs-xxl);
  letter-spacing: -0.01em;
}

.rc-auth-lead {
  margin: 0 0 var(--rc-space-5);
  color: var(--rc-muted);
  font-size: var(--rc-fs-md);
}

/* ---------- Status / icon block (confirmation pages) ---------- */
.rc-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: var(--rc-space-4);
  border-radius: var(--rc-radius-pill);
  background-color: var(--rc-primary-soft);
  color: var(--rc-primary);
}

.rc-status-icon-success {
  background-color: var(--rc-success-bg);
  color: var(--rc-success);
}

.rc-status-icon-danger {
  background-color: var(--rc-danger-bg);
  color: var(--rc-danger);
}

/* ---------- Footer ---------- */
.rc-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--rc-space-2);
  padding: var(--rc-space-5) var(--rc-space-4);
  text-align: center;
  color: var(--rc-subtle);
  font-size: var(--rc-fs-xs);
}

/* Legal links sit on one line, each after the first separated from the
   previous by a vertical divider. */
.rc-footer-links {
  display: inline-flex;
  align-items: center;
  gap: var(--rc-space-3);
}

.rc-footer-links a:not(:first-child) {
  padding-left: var(--rc-space-3);
  border-left: 1px solid var(--rc-border-strong);
}

/* ---------- Notification preference switches ---------- */
.rc-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Each notification section is a delineated box; the legend titles it. */
.rc-fieldset {
  margin: 0 0 var(--rc-space-4);
  padding: var(--rc-space-1) var(--rc-space-4) var(--rc-space-2);
  border: 1px solid var(--rc-border-strong);
  border-radius: var(--rc-radius-md);
}

.rc-legend {
  padding: 0 var(--rc-space-2);
  font-size: var(--rc-fs-md);
  font-weight: 700;
  color: var(--rc-text);
}

.rc-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rc-space-4);
  padding: var(--rc-space-3) 0;
  border-bottom: 1px solid var(--rc-border);
}

.rc-toggle-row:last-of-type {
  border-bottom: 0;
}

.rc-toggle-title {
  font-weight: 600;
  color: var(--rc-text);
}

/* The switch: a real checkbox, visually hidden but still the focusable,
   accessible control; the track + thumb spans are the visual toggle. */
.rc-switch {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--rc-space-2);
  cursor: pointer;
}

.rc-switch input {
  position: absolute;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.rc-switch-track {
  display: inline-block;
  width: 48px;
  height: 28px;
  flex: none;
  background-color: var(--rc-surface-strong);
  border: 1px solid var(--rc-border-strong);
  border-radius: var(--rc-radius-pill);
  transition: background-color 140ms ease, border-color 140ms ease;
}

.rc-switch-thumb {
  display: block;
  width: 22px;
  height: 22px;
  margin: 2px;
  background-color: var(--rc-text);
  border-radius: 50%;
  box-shadow: var(--rc-shadow-sm);
  transition: transform 140ms ease, background-color 140ms ease;
}

.rc-switch input:checked ~ .rc-switch-track {
  background-color: var(--rc-primary);
  border-color: var(--rc-primary);
}

.rc-switch input:checked ~ .rc-switch-track .rc-switch-thumb {
  transform: translateX(20px);
  background-color: var(--rc-primary-on);
}

.rc-switch input:focus-visible ~ .rc-switch-track {
  box-shadow: 0 0 0 3px var(--rc-focus-ring);
}

/* ON / OFF text, sitting just left of the track (it precedes the track in
   the markup) and reading as part of the switch. The state box is a grid
   whose single cell holds both words stacked; grid centering aligns them
   vertically against the track and right-justifies them toward it. The two
   words cross-fade + slide as the toggle flips. */
.rc-switch-state {
  order: -1;
  display: grid;
  align-items: center;
  justify-items: end;
  flex: none;
  min-width: 2.1em;
  font-size: var(--rc-fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  -webkit-user-select: none;
  user-select: none;
}

/* Both words occupy the same grid cell so they overlap; the slide is a
   small vertical offset layered on top of the grid placement. */
.rc-switch-on,
.rc-switch-off {
  grid-area: 1 / 1;
  transition: opacity 160ms ease, transform 160ms ease;
}

.rc-switch-on {
  color: var(--rc-primary);
  opacity: 0;
  transform: translateY(-0.35em);
}

.rc-switch-off {
  color: var(--rc-subtle);
  opacity: 1;
  transform: translateY(0);
}

.rc-switch input:checked ~ .rc-switch-state .rc-switch-on {
  opacity: 1;
  transform: translateY(0);
}

.rc-switch input:checked ~ .rc-switch-state .rc-switch-off {
  opacity: 0;
  transform: translateY(0.35em);
}

/* ---------- SMS opt-in disclosures ---------- */
.rc-consent {
  margin-top: var(--rc-space-5);
  padding: var(--rc-space-4);
  background-color: var(--rc-surface-muted);
  border: 1px solid var(--rc-border);
  border-radius: var(--rc-radius-md);
}

.rc-consent-title {
  margin: 0 0 var(--rc-space-2);
  font-size: var(--rc-fs-md);
  font-weight: 700;
}

.rc-consent-list {
  margin: 0;
  padding-left: var(--rc-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--rc-space-2);
  color: var(--rc-muted);
  font-size: var(--rc-fs-sm);
}

/* ---------- Messages ---------- */
.rc-messages {
  list-style: none;
  margin: 0 0 var(--rc-space-4);
  padding: 0;
}

.rc-message {
  padding: var(--rc-space-3) var(--rc-space-4);
  border-radius: var(--rc-radius-md);
  font-size: var(--rc-fs-sm);
}

.rc-message.success {
  background-color: var(--rc-success-bg);
  color: var(--rc-success);
}

/* ---------- Primary action buttons + sign-out row ---------- */
.rc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--rc-space-3);
  margin-bottom: var(--rc-space-5);
}

.rc-signout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--rc-space-3);
  margin-top: var(--rc-space-5);
}

.rc-signed-in {
  margin: 0;
  color: var(--rc-muted);
  font-size: var(--rc-fs-sm);
}

/* ---------- Responsive ---------- */
@media (max-width: 32rem) {
  .rc-appbar {
    padding: 0 var(--rc-space-4);
  }
  .rc-main {
    padding: var(--rc-space-5) var(--rc-space-3) var(--rc-space-6);
  }
  .rc-page-title {
    font-size: var(--rc-fs-xxl);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
