/* ============================================
   RINX PAC - Theme System (Priority Fixed)
   ============================================ */

:root {
  --color-primary: #c8102e;
  --color-primary-hover: #9f0f24;
  --color-primary-light: #D9586D;

  --bg-base: #0f0f0f;
  --bg-surface: #1a1a1a;
  --bg-elevated: #111111;

  --border-default: #2f2f2f;
  --border-accent: #c8102e;

  --text-primary: #ffffff;
  --text-secondary: #a1a1a8;
  --text-muted: #6b7280;
}

/* Theme Definitions */
body[data-theme="dark-cool"] {
  --bg-base: #0A0A0A;
  --bg-surface: #1A1A1C;
  --bg-elevated: #111113;
  --border-default: #2C2C30;
  --text-primary: #F5F5F7;
  --text-secondary: #A1A1A8;
  --text-muted: #6B7280;
}

body[data-theme="dark-warm"] {
  --bg-base: #14100B;
  --bg-surface: #211B15;
  --bg-elevated: #1A1611;
  --border-default: #36302A;
  --text-primary: #F8F2E8;
  --text-secondary: #C5B8A8;
  --text-muted: #7A6F5F;
}

body[data-theme="light"] {
  --bg-base: #F9F8F5;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F5F4F0;
  --border-default: #E5E3DB;
  --text-primary: #11110F;
  --text-secondary: #55534B;
  --text-muted: #7A766A;
}

/* ============================================
   Global Application
   ============================================ */
body {
  background-color: var(--bg-base) !important;
  color: var(--text-primary) !important;
}

/* Semantic Classes */
.bg-base       { background-color: var(--bg-base) !important; }
.bg-surface    { background-color: var(--bg-surface) !important; }
.bg-elevated   { background-color: var(--bg-elevated) !important; }

.border-default { border-color: var(--border-default) !important; }
.border-accent  { border-color: var(--border-accent) !important; }

.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }

/* ============================================
   Primary Brand Color (Highest Priority)
   ============================================ */

/* Force brand color - higher specificity than .text-white */
.text-primary-brand,
span.text-primary-brand,
h1 .text-primary-brand,
h2 .text-primary-brand {
  color: var(--color-primary) !important;
}

/* Primary background buttons */
.bg-primary {
  background-color: var(--color-primary) !important;
  color: white !important;
}

/* Ensure primary buttons stay white text even after theme changes */
.bg-primary,
.bg-primary:hover {
  color: white !important;
}

/* Hover states */
.hover\:bg-\[\#9f0f24\]:hover,
.hover\:bg-\[\#D9586D\]:hover {
  background-color: var(--color-primary-hover) !important;
}

/* ============================================
   Protective Overrides
   ============================================ */

/* Prevent .text-white from overriding brand text */
.text-white:not(.text-primary-brand) {
  color: var(--text-primary) !important;
}

/* Background overrides */
.bg-\[\#0f0f0f\],
.bg-\[\#1a1a1a\] {
  background-color: var(--bg-surface) !important;
}

.border-\[\#2f2f2f\] {
  border-color: var(--border-default) !important;
}

/* Text color fallbacks */
.text-gray-400,
.text-gray-300 {
  color: var(--text-secondary) !important;
}

.text-gray-500 {
  color: var(--text-muted) !important;
}

/* Modal & Card protection */
#endorse-modal,
#filter-modal,
#candidate-modal,
.endorse-card {
  background-color: var(--bg-surface) !important;
  border-color: var(--border-accent) !important;
}
