/* Fantasy Baseball Season Advisor — Colorblind-Safe Theme (Okabe-Ito) */
/* Supports: protanopia, deuteranopia, tritanopia, achromatopsia */

:root {
  /* Base dark theme */
  --bg:         #0d1117;
  --surface:    #161b22;
  --surface-2:  #1c2333;
  --border:     #30363d;
  --border-hl:  #484f58;

  /* Text */
  --text:       #e6edf3;
  --text-muted: #8b949e;
  --text-dim:   #484f58;

  /* Okabe-Ito accessible palette */
  --primary:    #56B4E9;   /* sky blue */
  --secondary:  #E69F00;   /* warm orange */
  --emphasis:   #D55E00;   /* vermillion (alerts) */
  --accent-1:   #009E73;   /* bluish green */
  --accent-2:   #CC79A7;   /* reddish purple */
  --accent-3:   #F0E442;   /* yellow */
  --accent-4:   #0072B2;   /* deep blue */

  /* Semantic colors — always paired with icons */
  --positive:   #56B4E9;   /* blue + up arrow */
  --negative:   #E69F00;   /* orange + down arrow */
  --neutral:    #8b949e;   /* gray + dot */
  --urgent:     #D55E00;   /* vermillion + warning icon */

  /* Spacing */
  --gap-xs: 4px;
  --gap-sm: 8px;
  --gap-md: 16px;
  --gap-lg: 24px;
  --gap-xl: 32px;

  /* Radius */
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;

  /* Transition */
  --transition: 0.2s ease;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === LAYOUT === */
.page-wrapper {
  display: flex;
  min-height: 100vh;
}
.main-content {
  flex: 1;
  padding: var(--gap-lg);
  padding-top: 72px; /* space for nav */
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.main-with-chat {
  margin-right: 380px; /* space for chat panel */
}

/* === NAV === */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--gap-lg);
  height: 56px;
}
.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  margin-right: var(--gap-xl);
  white-space: nowrap;
}
.nav-links {
  display: flex;
  gap: var(--gap-xs);
}
.nav-link {
  padding: var(--gap-sm) var(--gap-md);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  border: 1px solid transparent;
}
.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}
.nav-link.active {
  color: var(--primary);
  background: rgba(86, 180, 233, 0.1);
  border-color: rgba(86, 180, 233, 0.3);
}
.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
}
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--emphasis);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: -8px;
  margin-top: -10px;
}

/* Auth warning bar */
.auth-warning {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 99;
  background: var(--emphasis);
  color: white;
  padding: var(--gap-sm) var(--gap-lg);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  display: none;
}
.auth-warning.visible { display: block; }
.auth-warning a { color: white; text-decoration: underline; }

/* === CARDS === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap-md);
  transition: var(--transition);
}
.card:hover {
  border-color: var(--border-hl);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--gap-md);
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* === ACTION ITEMS === */
.action-item {
  display: flex;
  align-items: flex-start;
  gap: var(--gap-md);
  padding: var(--gap-md);
  border-radius: var(--radius);
  border-left: 3px solid var(--border);
  margin-bottom: var(--gap-sm);
  background: var(--surface);
}
.action-item.priority-1 { border-left-color: var(--urgent); }
.action-item.priority-2 { border-left-color: var(--secondary); }
.action-item.priority-3 { border-left-color: var(--text-dim); }
.action-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}
.action-content { flex: 1; }
.action-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}
.action-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* === TABLES === */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th {
  text-align: left;
  padding: var(--gap-sm) var(--gap-md);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.data-table td {
  padding: var(--gap-sm) var(--gap-md);
  border-bottom: 1px solid var(--border);
}
/* Alternating rows for accessibility (no color-coding) */
.data-table tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}
.data-table tr:hover td {
  background: rgba(86, 180, 233, 0.05);
}
.data-table .highlight-row td {
  background: rgba(86, 180, 233, 0.08);
  border-left: 2px solid var(--primary);
}

/* Sortable header */
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--primary); }
.data-table th.sort-asc::after { content: ' \u25B2'; font-size: 0.6rem; }
.data-table th.sort-desc::after { content: ' \u25BC'; font-size: 0.6rem; }

/* === INDICATORS (never color alone) === */
.indicator-positive { color: var(--positive); }
.indicator-positive::before { content: '\u25B2 '; font-size: 0.7rem; }
.indicator-negative { color: var(--negative); }
.indicator-negative::before { content: '\u25BC '; font-size: 0.7rem; }
.indicator-neutral { color: var(--neutral); }
.indicator-neutral::before { content: '\u25CF '; font-size: 0.5rem; }

/* === TAGS / BADGES === */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.tag-position { color: var(--primary); }
.tag-injury {
  color: var(--emphasis);
  border-color: var(--emphasis);
  background: rgba(213, 94, 0, 0.1);
}
.tag-fa {
  color: var(--accent-1);
  border-color: var(--accent-1);
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: var(--gap-sm) var(--gap-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.btn-primary {
  background: var(--primary);
  color: var(--bg);
  border-color: var(--primary);
  font-weight: 600;
}
.btn-primary:hover {
  background: #7ec8ee;
  color: var(--bg);
}
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* === TABS === */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--gap-md);
}
.tab {
  padding: var(--gap-sm) var(--gap-md);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* === KPI CARDS === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--gap-md);
  margin-bottom: var(--gap-lg);
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap-md);
  text-align: center;
}
.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}
.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

/* === CHAT PANEL === */
.chat-panel {
  position: fixed;
  top: 56px;
  right: 0;
  width: 370px;
  bottom: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
}
.chat-header {
  padding: var(--gap-md);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--gap-md);
}
.chat-msg {
  margin-bottom: var(--gap-md);
  font-size: 0.85rem;
}
.chat-msg.user {
  text-align: right;
}
.chat-msg.user .chat-bubble {
  background: rgba(86, 180, 233, 0.15);
  border: 1px solid rgba(86, 180, 233, 0.3);
  display: inline-block;
  text-align: left;
}
.chat-msg.ai .chat-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.chat-bubble {
  padding: var(--gap-sm) var(--gap-md);
  border-radius: var(--radius);
  max-width: 95%;
  line-height: 1.5;
}
.chat-bubble strong {
  color: var(--primary);
}
.chat-input-area {
  padding: var(--gap-md);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--gap-sm);
}
.chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--gap-sm) var(--gap-md);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}
.chat-input:focus {
  border-color: var(--primary);
}
.chat-send {
  background: var(--primary);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--gap-sm) var(--gap-md);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}
.chat-send:hover { background: #7ec8ee; }
.chat-toggle {
  display: none;
  position: fixed;
  bottom: var(--gap-lg);
  right: var(--gap-lg);
  z-index: 60;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--bg);
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

/* === FILTERS === */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
  align-items: center;
}
.filter-bar select, .filter-bar input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--gap-sm) var(--gap-md);
  color: var(--text);
  font-size: 0.85rem;
}
.filter-bar select:focus, .filter-bar input:focus {
  border-color: var(--primary);
  outline: none;
}

/* === SECTION HEADERS === */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--gap-md);
  padding-bottom: var(--gap-sm);
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
}

/* === GRID LAYOUTS === */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-md); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--gap-md); }

/* === COMPARISON === */
.comparison {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--gap-md);
  align-items: center;
}
.comparison-vs {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* === LOADING === */
.loading {
  text-align: center;
  padding: var(--gap-xl);
  color: var(--text-muted);
}
.loading::after {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: var(--gap-sm);
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === MODAL (for ESPN cookie paste-in) === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--gap-xl);
  max-width: 500px;
  width: 90%;
}
.modal h2 { margin-bottom: var(--gap-md); }
.modal label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--gap-xs);
  margin-top: var(--gap-md);
}
.modal input[type="text"], .modal textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--gap-sm);
  color: var(--text);
  font-size: 0.85rem;
  font-family: monospace;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--gap-sm);
  margin-top: var(--gap-lg);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .main-with-chat { margin-right: 0; }
  .chat-panel { display: none; }
  .chat-panel.mobile-open {
    display: flex;
    width: 100%;
    top: 56px;
  }
  .chat-toggle { display: block; }
  .nav-brand { font-size: 0.9rem; margin-right: var(--gap-md); }
  .nav-link { padding: var(--gap-sm); font-size: 0.8rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .comparison { grid-template-columns: 1fr; }
  .comparison-vs { text-align: center; }
  .main-content { padding: var(--gap-md); padding-top: 68px; }
}

@media (max-width: 480px) {
  .nav-links { gap: 0; }
  .nav-link { padding: 6px; font-size: 0.75rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
