/* ==============================================
   ModelMatrix – Global Styles & Theme
   ============================================== */

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

:root {
  --bg-primary: #0A0C10;
  --bg-surface: #141824;
  --border-color: #1E2433;
  --accent: #00AAFF;
  --accent-gold: #FFD700;
  --text-primary: #F0F3F8;
  --text-secondary: #8B93A7;
  --green-start: #00C853;
  --green-end: #64DD17;
  --blue-start: #00AAFF;
  --blue-end: #00E5FF;
  --orange-start: #FF6D00;
  --orange-end: #FF3D00;
  --modal-bg: #1A1F2E;
  --preloader-bg: #05070A;

  --font-mono: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  cursor: none; /* Custom cursor controlled by JS */
  overflow-x: hidden;
}

/* Revert cursor for touch devices (via class added by cursor.js) */
body.touch-device {
  cursor: auto;
}

/* ---------- PRELOADER ---------- */
.preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--preloader-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.preloader.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader__content {
  text-align: center;
  max-width: 320px;
}

.preloader__glow-ring {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 30px var(--accent);
  animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.preloader__title {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.preloader__subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.preloader__progress-wrap {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.preloader__progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-gold));
  border-radius: 4px;
  transition: width 0.05s linear;
}

.preloader__message {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
  min-height: 1.3em;
}

.preloader__percentage {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

/* ---------- CUSTOM CURSOR ---------- */
.cursor-outer {
  position: fixed;
  width: 24px;
  height: 24px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  background: rgba(0,170,255,0.08);
  transform: translate(-50%, -50%);
  transition: width 0.25s ease, height 0.25s ease, border-color 0.25s ease, background 0.25s ease;
  will-change: transform;
}

.cursor-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  background: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cursor-outer.hover {
  width: 36px;
  height: 36px;
  border-color: var(--accent-gold);
  background: rgba(255, 215, 0, 0.12);
}

/* Hide custom cursor on touch devices */
body.touch-device .cursor-outer,
body.touch-device .cursor-inner {
  display: none;
}

/* ---------- HEADER ---------- */
.header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

.header__inner {
  max-width: 900px;
  margin: 0 auto;
}

.header__logo {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
}

.header__logo-icon {
  font-size: 2.2rem;
  margin-right: 0.3rem;
}

.header__tagline {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-top: 0.3rem;
}

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.3rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-size: 0.9rem;
  background: transparent;
  color: var(--text-primary);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px rgba(0,170,255,0.3);
}
.btn--primary:hover {
  background: #0099e6;
  box-shadow: 0 0 20px rgba(0,170,255,0.6);
}
.btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--ghost {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
}
.btn--ghost:hover {
  background: rgba(255,255,255,0.1);
  border-color: var(--accent);
}

.btn--outline {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.btn--outline:hover {
  background: var(--accent);
  color: #fff;
}

.btn--sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

/* ---------- SECTIONS & GRIDS ---------- */
.section {
  padding: 0 1.5rem 2rem;
  max-width: 1300px;
  margin: 0 auto;
}

.section__title {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  padding-left: 0.3rem;
  color: var(--text-primary);
  border-left: 4px solid var(--accent);
  padding-left: 1rem;
}

.provider-grid,
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
}

/* ---------- PROVIDER CARDS ---------- */
.provider-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.provider-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,170,255,0.15);
}

.provider-card__icon {
  font-size: 2.2rem;
  margin-bottom: 0.3rem;
}

.provider-card__name {
  font-weight: 700;
  font-size: 1.1rem;
}

.provider-card__desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ---------- MODEL CARDS ---------- */
.model-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  transition: border 0.2s;
}
.model-card:hover {
  border-color: var(--accent);
}

.model-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.model-card__name {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.3;
}

.model-card__check {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.model-card__check input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.bar-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bar__label {
  width: 80px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bar__track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  width: 0%;
  border-radius: 10px;
  transition: width 0.4s ease;
}

.bar__fill--intelligence {
  background: linear-gradient(90deg, var(--green-start), var(--green-end));
}
.bar__fill--speed {
  background: linear-gradient(90deg, var(--blue-start), var(--blue-end));
}
.bar__fill--cost {
  background: linear-gradient(90deg, var(--orange-start), var(--orange-end));
}

.bar__value {
  font-size: 0.7rem;
  font-weight: 700;
  width: 28px;
  text-align: left;
  color: var(--text-primary);
}

.model-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.btn--try {
  font-size: 0.75rem;
  padding: 0.3rem 0.8rem;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 4px;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.btn--try:hover {
  background: var(--accent);
  color: #fff;
}

/* ---------- COMPARE BAR ---------- */
.compare-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--bg-surface);
  border-top: 2px solid var(--accent);
  padding: 0.8rem 1.5rem;
  z-index: 500;
  display: flex;
  justify-content: center;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}

.compare-bar__inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 1200px;
  width: 100%;
}

.compare-bar__label {
  font-weight: 700;
  color: var(--accent-gold);
}

.compare-bar__chips {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip {
  background: var(--border-color);
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chip__remove {
  cursor: pointer;
  color: var(--accent);
  font-weight: bold;
}

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--modal-bg);
  border-radius: 16px;
  width: 90%;
  max-width: 1000px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(0,170,255,0.3);
  padding: 1.8rem;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal__title {
  font-size: 1.4rem;
  color: var(--accent);
}

.modal__close {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.modal__body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.modal-model-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem;
}

.modal-model-card h3 {
  font-size: 1rem;
  margin-bottom: 0.8rem;
}

.modal-model-card p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0.3rem 0;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}
.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  .provider-grid,
  .model-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .header__logo { font-size: 2rem; }
  .compare-bar__inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 500px) {
  .provider-grid,
  .model-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== THEME TOGGLE ========== */
.header__top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.3rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, border-color 0.3s;
}
.theme-toggle:hover {
  background: var(--border-color);
  border-color: var(--accent);
}

/* ========== LIGHT THEME (body.light-mode) ========== */
body.light-mode {
  --bg-primary: #F5F7FA;
  --bg-surface: #FFFFFF;
  --border-color: #D0D7DE;
  --text-primary: #1A1A2E;
  --text-secondary: #4B5563;
  --preloader-bg: #E8ECF1;
  --modal-bg: #FFFFFF;
  
  /* Keep accents */
  --accent: #0077CC;
  --accent-gold: #D4A017;
  
  /* Bars unchanged (can also adapt if needed) */
}

body.light-mode .preloader {
  background: var(--preloader-bg);
}
body.light-mode .preloader__title {
  color: var(--accent);
}
body.light-mode .preloader__subtitle,
body.light-mode .preloader__message {
  color: var(--text-secondary);
}

body.light-mode .header {
  border-bottom-color: var(--border-color);
}

body.light-mode .provider-card,
body.light-mode .model-card {
  background: var(--bg-surface);
  border-color: var(--border-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
body.light-mode .provider-card:hover,
body.light-mode .model-card:hover {
  border-color: var(--accent);
}

body.light-mode .compare-bar {
  background: var(--bg-surface);
  border-top-color: var(--accent);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
}

body.light-mode .modal-overlay {
  background: rgba(0,0,0,0.5);
}
body.light-mode .modal {
  background: var(--bg-surface);
  box-shadow: 0 0 30px rgba(0,119,204,0.2);
}

body.light-mode .bar__track {
  background: rgba(0,0,0,0.06);
}

body.light-mode .btn--ghost {
  background: rgba(0,0,0,0.03);
  border-color: var(--border-color);
  color: var(--text-primary);
}
body.light-mode .btn--ghost:hover {
  background: rgba(0,0,0,0.06);
}

body.light-mode .chip {
  background: #E5E7EB;
  color: var(--text-primary);
}

body.light-mode .theme-toggle {
  border-color: var(--border-color);
  color: var(--text-primary);
}
body.light-mode .theme-toggle:hover {
  background: var(--border-color);
}

/* Cursor adapts */
body.light-mode .cursor-outer {
  border-color: var(--accent);
  background: rgba(0,119,204,0.1);
}
body.light-mode .cursor-outer.hover {
  border-color: var(--accent-gold);
  background: rgba(212, 160, 23, 0.15);
}
body.light-mode .cursor-inner {
  background: #111;
}