/* ===========================
   Keirin Data Portal - Global Styles
   =========================== */

:root {
  /* Color Palette - Modern Dark Theme */
  --bg-primary: #0a0e27;
  --bg-secondary: #151b3d;
  --bg-card: #1a2142;
  --bg-card-hover: #222952;

  --accent-primary: #00d4ff;
  --accent-secondary: #7c3aed;
  --accent-gradient: linear-gradient(135deg, #00d4ff 0%, #7c3aed 100%);

  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --text-muted: #718096;

  --border-color: #2d3748;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  /* Status Colors */
  --status-upcoming: #fbbf24;
  --status-live: #10b981;
  --status-finished: #6b7280;

  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===========================
   Typography
   =========================== */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.5rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 2rem;
  color: var(--text-primary);
}

h3 {
  font-size: 1.5rem;
  color: var(--text-primary);
}

p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* ===========================
   Layout Components
   =========================== */

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.header {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  padding: 2rem 0;
  margin-bottom: 3rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  font-size: 2.5rem;
  filter: drop-shadow(0 0 10px var(--accent-primary));
}

.logo h1 {
  margin: 0;
  font-size: 1.8rem;
}

.header-stats {
  display: flex;
  gap: 2rem;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===========================
   Search & Filter Section
   =========================== */

.search-section {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 3rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.search-box {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-box input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.3s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.2rem;
}

.filter-tabs {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 0.75rem 1.5rem;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-tab:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  transform: translateY(-2px);
}

.filter-tab.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}

/* ===========================
   Venue Grid
   =========================== */

.section-title {
  font-size: 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 2rem;
  background: var(--accent-gradient);
  border-radius: 2px;
}

.venue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.venue-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.venue-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-gradient);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.venue-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.venue-card:hover::before {
  transform: scaleX(1);
}

.venue-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.venue-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.venue-code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
}

.venue-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.venue-stat {
  text-align: center;
}

.venue-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

.venue-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===========================
   Race List (for venue detail pages)
   =========================== */

.race-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.race-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  cursor: pointer;
}

.race-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  transform: translateX(8px);
  box-shadow: var(--shadow-md);
}

.race-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.race-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

.race-status {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.race-status.upcoming {
  background: rgba(251, 191, 36, 0.2);
  color: var(--status-upcoming);
}

.race-status.live {
  background: rgba(16, 185, 129, 0.2);
  color: var(--status-live);
}

.race-status.finished {
  background: rgba(107, 114, 128, 0.2);
  color: var(--status-finished);
}

.race-info {
  display: flex;
  gap: 2rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.race-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 212, 255, 0.4);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ===========================
   Utilities
   =========================== */

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mt-4 {
  margin-top: 2rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.mb-4 {
  margin-bottom: 2rem;
}

/* ===========================
   Responsive Design
   =========================== */

@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .header-content {
    flex-direction: column;
    gap: 1.5rem;
  }

  .header-stats {
    width: 100%;
    justify-content: space-around;
  }

  .venue-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2rem;
  }

  .filter-tabs {
    justify-content: center;
  }
}

/* ===========================
   Animations
   =========================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.venue-card,
.race-card {
  animation: fadeIn 0.5s ease-out;
}

/* Stagger animation for grid items */
/* ===========================
   Table Styles (Entry, Result, Payout)
   =========================== */

.entry-table,
.result-table,
.payout-table {
  width: 100%;
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 1rem;
  text-align: left;
  font-weight: 700;
  border-bottom: 2px solid var(--border-color);
}

td {
  padding: 1rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover {
  background: var(--bg-card-hover);
}

/* ===========================
   Car Number Styles
   =========================== */

.car-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 4px;
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  border: 2px solid rgba(0, 0, 0, 0.1);
}

.car-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  font-weight: 800;
  font-family: var(--font-mono);
  border: 1px solid rgba(0, 0, 0, 0.1);
  margin-right: 0.5rem;
}

.car-1 {
  background: #fff;
  color: #333;
}

.car-2 {
  background: #333;
  color: #fff;
}

.car-3 {
  background: #e53935;
  color: #fff;
}

.car-4 {
  background: #1e88e5;
  color: #fff;
}

.car-5 {
  background: #fdd835;
  color: #333;
}

.car-6 {
  background: #43a047;
  color: #fff;
}

.car-7 {
  background: #fb8c00;
  color: #fff;
}

.car-8 {
  background: #f48fb1;
  color: #fff;
}

.car-9 {
  background: #b39ddb;
  color: #fff;
}

/* ===========================
   Player Info Components
   =========================== */

.player-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.class-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 700;
}

.player-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.style-label {
  font-weight: 600;
}

.score-value {
  font-weight: 800;
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

.gear-value {
  font-family: var(--font-mono);
}

/* ===========================
   Result & Payout Specifics
   =========================== */

.rank-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  font-size: 1.25rem;
  font-weight: 800;
}

.rank-1 {
  background: rgba(255, 215, 0, 0.1);
}

.rank-2 {
  background: rgba(192, 192, 192, 0.1);
}

.rank-3 {
  background: rgba(205, 127, 50, 0.1);
}

.tip-col {
  width: 40px;
  text-align: center;
  color: var(--accent-primary);
  font-weight: bold;
}

.flag-col {
  width: 50px;
  text-align: center;
  color: var(--accent-secondary);
  font-weight: bold;
}

.comment-col {
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.payout-amount {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-primary);
}

/* ===========================
   Venue & Date Grouping Styles
   =========================== */

.day-section {
  margin-bottom: 4rem;
  animation: fadeIn 0.6s ease-out;
}

.day-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.day-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.day-badge {
  padding: 0.25rem 0.75rem;
  background: var(--bg-secondary);
  color: var(--accent-primary);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid var(--accent-primary);
  display: inline-block;
}

.race-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.race-card {
  display: flex;
  flex-direction: column;
}

.race-card .race-header {
  margin-bottom: 0.5rem;
}

.race-card .race-info {
  margin-bottom: 1rem;
  flex-grow: 1;
}


/* Report Styles */
.day-section {
  margin-bottom: 3rem;
  animation: fadeIn 0.6s ease-out;
}

.day-header {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
}

.day-title {
  font-size: 1.4rem;
  margin: 0;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
}

.btn-detail {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background: transparent;
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-detail:hover {
  background: var(--accent-primary);
  color: #fff;
}

/* ===========================
   Dashboard & Report Utilities
   =========================== */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.stat-card-wide {
  grid-column: 1 / -1;
}

.flex-between-baseline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.text-profit {
  color: #4cd964 !important;
}

.text-loss {
  color: #e74c3c !important;
}

.total-roi-text {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text-secondary);
}

.stat-trend-flex {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.roi-unit {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.btn-small {
  padding: 0.2rem 0.6rem !important;
  font-size: 0.75rem !important;
}
/* Generation Date */
.report-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-family: var(--font-mono);
}
