/* ============================================================
   Polymarket Tracker — Carbon Design System v10 (g100 dark)
   Clean IBM design: IBM Plex fonts, standard Carbon components
   ============================================================ */

/* ---- Fonts: IBM Plex Sans + Mono ---- */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ---- Carbon Design Tokens (g100 dark theme) ---- */
:root {
  /* Backgrounds */
  --cds-background: #161616;
  --cds-layer-01: #262626;
  --cds-layer-02: #393939;
  --cds-layer-hover: #353535;
  --cds-layer-active: #525252;
  --cds-field-01: #262626;

  /* Interactive */
  --cds-interactive: #0f62fe;
  --cds-interactive-hover: #0353e9;
  --cds-interactive-active: #002d9c;

  /* Support */
  --cds-support-error: #da1e28;
  --cds-support-success: #24a148;
  --cds-support-warning: #f1c21b;
  --cds-support-info: #0043ce;

  /* Text */
  --cds-text-primary: #f4f4f4;
  --cds-text-secondary: #c6c6c6;
  --cds-text-placeholder: #6f6f6f;
  --cds-text-helper: #8d8d8d;
  --cds-text-on-color: #ffffff;
  --cds-text-inverse: #161616;

  /* Link */
  --cds-link-primary: #78a9ff;
  --cds-link-visited: #be95ff;

  /* Border */
  --cds-border-subtle: #393939;
  --cds-border-strong: #6f6f6f;

  /* Icon */
  --cds-icon-primary: #f4f4f4;
  --cds-icon-secondary: #c6c6c6;

  /* Tag colors */
  --cds-tag-red-bg: rgba(218, 30, 40, 0.2);
  --cds-tag-red-text: #ffb3b8;
  --cds-tag-blue-bg: rgba(15, 98, 254, 0.2);
  --cds-tag-blue-text: #78a9ff;
  --cds-tag-green-bg: rgba(36, 161, 72, 0.2);
  --cds-tag-green-text: #42be65;
  --cds-tag-cyan-bg: rgba(0, 157, 224, 0.2);
  --cds-tag-cyan-text: #33b1ff;
  --cds-tag-warm-gray-bg: rgba(141, 141, 141, 0.2);
  --cds-tag-warm-gray-text: #c6c6c6;

  /* Fonts */
  --cds-font-sans: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  --cds-font-mono: 'IBM Plex Mono', 'Menlo', 'Courier New', monospace;

  /* Spacing scale (Carbon 2px base) */
  --cds-spacing-03: 8px;
  --cds-spacing-04: 12px;
  --cds-spacing-05: 16px;
  --cds-spacing-06: 24px;
  --cds-spacing-07: 32px;
  --cds-spacing-08: 40px;
  --cds-spacing-09: 48px;
}

/* ---- Reset ---- */

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

body {
  font-family: var(--cds-font-sans);
  font-size: 14px;
  line-height: 1.43;
  background: var(--cds-background);
  color: var(--cds-text-secondary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Typography ---- */

h1, h2, h3 {
  font-family: var(--cds-font-sans);
  font-weight: 600;
  color: var(--cds-text-primary);
  letter-spacing: 0;
}

h1 { font-size: 20px; line-height: 1.4; }
h2 { font-size: 16px; line-height: 1.5; color: var(--cds-text-secondary); }

/* ---- Navigation ---- */

.nav {
  display: flex;
  gap: 2px;
  flex-wrap: nowrap;
  align-items: center;
  overflow: hidden;
}

.nav a {
  color: var(--cds-text-secondary);
  text-decoration: none;
  padding: 8px 16px;
  background: transparent;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
  font-size: 14px;
  font-family: var(--cds-font-sans);
  font-weight: 400;
  white-space: nowrap;
}

.nav a:hover {
  background: var(--cds-layer-hover);
  color: var(--cds-text-primary);
}

.nav a.active {
  color: var(--cds-text-primary);
  border-bottom-color: var(--cds-interactive);
  font-weight: 600;
}

.nav a:focus-visible {
  outline: 2px solid var(--cds-interactive);
  outline-offset: -2px;
}

.nav-separator {
  color: var(--cds-border-subtle);
  margin: 0 4px;
  font-size: 12px;
}

/* Sport selector dropdown */
.sport-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--cds-field-01);
  border: none;
  border-bottom: 1px solid var(--cds-border-strong);
  color: var(--cds-text-primary);
  padding: 8px 32px 8px 16px;
  font-size: 14px;
  font-family: var(--cds-font-sans);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23f4f4f4' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.sport-select:hover,
.sport-select:focus {
  border-bottom-color: var(--cds-interactive);
  outline: none;
}

.sport-select option {
  background: var(--cds-layer-01);
  color: var(--cds-text-primary);
}

/* ---- Tiles (cards) ---- */

.cds-tile {
  background: var(--cds-layer-01);
  padding: var(--cds-spacing-05);
  min-height: 48px;
  transition: background 0.15s;
}

.cds-tile:hover {
  background: var(--cds-layer-hover);
}

/* ---- Data Display ---- */

.data-value {
  font-family: var(--cds-font-mono);
  font-variant-numeric: tabular-nums;
}

.data-label {
  font-family: var(--cds-font-sans);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.32px;
  color: var(--cds-text-helper);
}

/* ---- Tags / Badges ---- */

.cds-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 24px;
  font-size: 12px;
  font-family: var(--cds-font-sans);
  font-weight: 400;
  line-height: 1.34;
}

.cds-tag--red {
  background: var(--cds-tag-red-bg);
  color: var(--cds-tag-red-text);
}

.cds-tag--blue {
  background: var(--cds-tag-blue-bg);
  color: var(--cds-tag-blue-text);
}

.cds-tag--green {
  background: var(--cds-tag-green-bg);
  color: var(--cds-tag-green-text);
}

.cds-tag--cyan {
  background: var(--cds-tag-cyan-bg);
  color: var(--cds-tag-cyan-text);
}

.cds-tag--warm-gray {
  background: var(--cds-tag-warm-gray-bg);
  color: var(--cds-tag-warm-gray-text);
}

/* Legacy badge classes mapped to Carbon tags */
.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--cds-tag-red-bg);
  color: var(--cds-tag-red-text);
  padding: 2px 8px;
  border-radius: 24px;
  font-size: 12px;
  font-family: var(--cds-font-sans);
  font-weight: 500;
}

.badge-score {
  background: var(--cds-tag-blue-bg);
  color: var(--cds-tag-blue-text);
  padding: 2px 8px;
  border-radius: 24px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--cds-font-sans);
}

.badge-period {
  background: var(--cds-tag-cyan-bg);
  color: var(--cds-tag-cyan-text);
  padding: 2px 8px;
  border-radius: 24px;
  font-size: 12px;
  font-family: var(--cds-font-sans);
}

/* ---- Buttons ---- */

.btn-primary {
  background: var(--cds-interactive);
  color: var(--cds-text-on-color);
  border: none;
  padding: 11px 16px;
  font-size: 14px;
  font-family: var(--cds-font-sans);
  font-weight: 400;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  letter-spacing: 0.16px;
}

.btn-primary:hover { background: var(--cds-interactive-hover); }
.btn-primary:active { background: var(--cds-interactive-active); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--cds-link-primary);
  padding: 11px 16px;
  font-size: 14px;
  font-family: var(--cds-font-sans);
  font-weight: 400;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}

.btn-ghost:hover {
  background: var(--cds-layer-hover);
}

.btn-ghost.active {
  background: var(--cds-interactive);
  color: var(--cds-text-on-color);
}

/* ---- Status Indicators ---- */

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online { background: var(--cds-support-success); }
.status-dot.offline { background: var(--cds-support-error); }

/* ---- Direction Colors ---- */

.clr-up { color: var(--cds-support-success) !important; }
.clr-down { color: var(--cds-support-error) !important; }
.clr-neutral { color: var(--cds-text-helper) !important; }
.clr-cyan { color: var(--cds-tag-cyan-text) !important; }
.clr-amber { color: var(--cds-support-warning) !important; }

/* ---- Scrollbar ---- */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cds-border-subtle); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cds-border-strong); }

/* ---- ApexCharts Overrides ---- */

.apexcharts-tooltip {
  background: var(--cds-layer-01) !important;
  border: 1px solid var(--cds-border-subtle) !important;
  color: var(--cds-text-secondary) !important;
  font-family: var(--cds-font-mono) !important;
  border-radius: 0 !important;
}

.apexcharts-tooltip-title {
  background: var(--cds-background) !important;
  border-bottom: 1px solid var(--cds-border-subtle) !important;
  font-family: var(--cds-font-sans) !important;
}

.apexcharts-xaxistooltip,
.apexcharts-yaxistooltip {
  background: var(--cds-layer-01) !important;
  border: 1px solid var(--cds-border-subtle) !important;
  color: var(--cds-text-secondary) !important;
}

/* ---- Animations ---- */

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---- Loading Spinner ---- */

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--cds-border-subtle);
  border-top-color: var(--cds-interactive);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Empty State ---- */

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--cds-text-helper);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* ---- Mobile Navigation ---- */

.nav-mobile { display: none; position: relative; }
.nav-betboom {
  padding: 8px 14px !important;
  font-weight: 600 !important;
}

.nav-burger {
  background: var(--cds-layer-02);
  border: 1px solid var(--cds-border-subtle);
  color: var(--cds-text-primary);
  font-size: 22px;
  width: 44px;
  height: 38px;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  border-radius: 6px;
}
.nav-burger:hover { background: var(--cds-layer-hover); }

.nav-mobile-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  max-width: min(320px, 88vw);
  max-height: 65vh;
  overflow-y: auto;
  background: #262626f2;
  backdrop-filter: blur(6px);
  border: 1px solid var(--cds-border-subtle);
  border-radius: 10px;
  z-index: 1000;
  box-shadow: 0 10px 24px rgba(0,0,0,0.45);
}
.nav-mobile.open .nav-mobile-dropdown { display: flex; flex-direction: column; }

.nav-mobile-dropdown a {
  padding: 13px 14px;
  color: var(--cds-text-secondary);
  text-decoration: none;
  font-size: 15px;
  font-family: var(--cds-font-sans);
  border-bottom: 1px solid var(--cds-border-subtle);
  transition: background 0.15s;
}
.nav-mobile-dropdown a:last-child { border-bottom: none; }
.nav-mobile-dropdown a:hover { background: var(--cds-layer-hover); color: var(--cds-text-primary); }
.nav-mobile-dropdown a.active {
  color: var(--cds-text-primary);
  font-weight: 600;
  border-left: 3px solid var(--cds-interactive);
  background: rgba(15,98,254,0.14);
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
  .nav-desktop { display: none; }
  .nav-betboom { display: none !important; }
  .nav-mobile { display: block; }

  /* Mobile dropdown must be able to escape nav bounds */
  .nav { overflow: visible; }

  /* Centered mobile menu (not anchored to the left of the burger) */
  .nav-mobile-dropdown {
    position: fixed;
    left: 50%;
    right: auto;
    top: 120px;
    transform: translateX(-50%);
    width: min(340px, 92vw);
    max-width: 92vw;
  }

  .nav a {
    padding: 6px 12px;
    font-size: 13px;
  }

  .sport-select {
    padding: 6px 28px 6px 12px;
    font-size: 13px;
  }
}

@media (min-width: 901px) {
  .nav-mobile { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- Valve/HLTV Rank Badges ---- */
.rank-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  font-family: 'IBM Plex Mono', monospace;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 4px;
  line-height: 1.4;
}
.rank-badge.valve {
  background: rgba(218, 30, 40, 0.15);
  color: #ff6b6b;
  border: 1px solid rgba(218, 30, 40, 0.3);
}
.rank-badge.hltv {
  background: rgba(15, 98, 254, 0.15);
  color: #6ea8fe;
  border: 1px solid rgba(15, 98, 254, 0.3);
}
