/* ===== CasaCourses 2.0 Race Detail Page ===== */
/* Matches programme page aesthetic: dark theme, cards, accent color */

/* ===== Layout ===== */
.cc-race-detail {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 0.75rem 2rem;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
}

/* ===== Navigation ===== */
.cc-race-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  gap: 1rem;
}

/* Back button - square icon */
.cc-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.15s ease;
}

.cc-back-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.cc-back-btn svg {
  flex-shrink: 0;
}

/* Prev/Next race navigation - icon arrows */
.cc-race-nav-arrows {
  display: flex;
  gap: 0.5rem;
}

.cc-nav-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.15s ease;
}

.cc-nav-arrow:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.cc-nav-arrow--disabled {
  opacity: 0.3;
  pointer-events: none;
  cursor: not-allowed;
}

.cc-nav-arrow svg {
  flex-shrink: 0;
}

/* Legacy styles kept for compatibility */
.cc-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.5rem 0;
  transition: color 0.15s ease;
}

.cc-back-link:hover {
  color: var(--text);
}

.cc-nav-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--soft);
  border: 1px solid var(--outline);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.cc-nav-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

/* ===== Race Header ===== */
.cc-race-header {
  background: var(--card);
  border: 1px solid var(--outline);
  border-radius: 0;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.cc-race-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 0.75rem 0;
  line-height: 1.3;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.cc-race-codes-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cc-code-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 1.75rem;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  border-radius: 4px;
  transform: skewX(-8deg);
}

.cc-code-pill--reunion {
  background: #6b7280;
  color: white;
}

.cc-code-pill--race {
  background: #9ca3af;
  color: white;
}

.cc-race-name {
  color: var(--text);
}

.cc-race-code {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 800;
  margin-right: 0.5rem;
  transform: skewX(-3deg);
}

/* Meta row: time, type, distance, prize */
.cc-race-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.cc-race-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  background: var(--soft);
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
}

.cc-race-time {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.cc-race-prize {
  color: #ffd46b;
}

/* Runner count */
.cc-race-runners-count {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.9;
  margin-bottom: 0.75rem;
}

/* Conditions row: track, weather */
.cc-race-conditions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
  opacity: 0.85;
  margin-bottom: 0.75rem;
}

.cc-track-condition,
.cc-weather {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* Status badges */
.cc-race-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.cc-race-status--finished {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.cc-race-status--disabled {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.cc-race-status--open {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

/* Countdown timer */
.cc-countdown {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-weight: 800;
}

.cc-countdown-time {
  font-size: 1.1em;
  color: #ffd46b;
}

/* ===== Race Info Section ===== */
.cc-race-info {
  background: var(--soft);
  border: 1px solid var(--outline);
  border-radius: 0;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.cc-race-info p {
  margin: 0 0 0.5rem 0;
  line-height: 1.5;
}

.cc-race-info p:last-child {
  margin-bottom: 0;
}

.cc-race-comment {
  margin-top: 0.75rem;
}

.cc-race-comment summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  padding: 0.5rem 0;
}

.cc-race-comment summary:hover {
  text-decoration: underline;
}

.cc-race-comment p {
  margin-top: 0.5rem;
  opacity: 0.9;
  padding-left: 0.5rem;
  border-left: 2px solid var(--outline);
}

/* ===== Results Section ===== */
.cc-results-section {
  background: var(--card);
  border: 1px solid var(--outline);
  border-radius: 0;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* Results header with duration on right */
.cc-results-header {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0 0 1rem 0;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--outline);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cc-race-duration {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  font-family: 'Courier New', Courier, monospace;
}

/* Top 5 winners inline display */
.cc-top5-winners {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0;
  background: transparent;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.cc-top5-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.cc-top5-number {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  background: #10b981;
  width: 40px;
  height: 40px;
  border-radius: 10%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.cc-top5-silk {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}

.cc-top5-silk img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cc-top5-silk--placeholder {
  background: rgba(255, 255, 255, 0.1);
}

.cc-results-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cc-result-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--soft);
  border-radius: 6px;
  transition: transform 0.1s ease;
}

.cc-result-item:hover {
  transform: translateX(2px);
}

/* Podium styling */
.cc-result-item--position-1 {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.05));
  border-left: 3px solid #ffd700;
}

.cc-result-item--position-2 {
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.15), rgba(192, 192, 192, 0.05));
  border-left: 3px solid #c0c0c0;
}

.cc-result-item--position-3 {
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.15), rgba(205, 127, 50, 0.05));
  border-left: 3px solid #cd7f32;
}

.cc-result-position {
  min-width: 3.5rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.cc-result-details {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.cc-result-number {
  font-weight: 800;
  font-size: 1rem;
  background: var(--accent);
  color: #fff;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  min-width: 2rem;
  text-align: center;
}

.cc-result-horse {
  font-weight: 700;
  font-size: 1.05rem;
}

.cc-result-jockey {
  font-size: 0.9rem;
  opacity: 0.8;
}

.cc-result-odd {
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--pill);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

/* ===== Dividends Section ===== */
.cc-dividends-section {
  background: var(--card);
  border: 1px solid var(--outline);
  border-radius: 0;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.cc-dividends-section h2 {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0 0 1rem 0;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--outline);
}

.cc-dividends-list {
  display: grid;
  gap: 1rem;
}

/* Dividend group container */
.cc-dividend-group {
  background: var(--soft);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}

.cc-dividend-type {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0 0 0.5rem 0;
  padding: 0 0 0.5rem 0;
  color: var(--text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* All dividend rows - uniform structure */
.cc-dividend-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: center;
  padding: 0.5rem 0;
  margin: 0;
}

/* First row after header gets slight top margin */
.cc-dividend-type + .cc-dividend-row {
  margin-top: 0.25rem;
}

/* Zebra striping for grouped rows only */
.cc-dividend-row--grouped:nth-of-type(even) {
  background: rgba(255, 255, 255, 0.03);
  padding-left: 1rem;
  padding-right: 1rem;
  margin-left: -1rem;
  margin-right: -1rem;
}

.cc-dividend-combination {
  font-family: monospace;
  font-size: 0.9rem;
  opacity: 0.9;
  text-align: left;
}

.cc-dividend-payout {
  font-weight: 800;
  font-size: 1rem;
  color: #10b981;
  text-align: right;
  white-space: nowrap;
}

/* ===== Runners Section ===== */
.cc-runners-section {
  background: var(--card);
  border: 1px solid var(--outline);
  border-radius: 0;
  /* padding: 1.25rem; */
  margin-bottom: 1rem;
}

.cc-runners-section h2 {
  font-size: 1.25rem;
  color: aliceblue;
  font-weight: 800;
  margin: 0 0 1rem 0;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #edf1f8;
}

.cc-runners-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ===== RUNNERS HEADER WITH VIEW TOGGLE ===== */

.cc-runners-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 1rem 0;
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--outline);
}

.cc-runners-header h2 {
  margin: 0;
  padding: 0;
  border: none;
}

.cc-view-toggle {
  display: flex;
  gap: 0;
  background: var(--soft);
  border-radius: 6px;
  padding: 4px;
  border: 1px solid var(--outline);
}

.cc-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cc-view-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.cc-view-btn.is-active {
  background: var(--accent);
  color: #fff;
}

.cc-view-btn svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

/* ===== TABLE VIEW ===== */

.cc-runners-table-container {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--soft);
  border: 1px solid var(--outline);
}

.cc-runners-table-scroll {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--soft);
}

.cc-runners-table-scroll::-webkit-scrollbar {
  height: 8px;
}

.cc-runners-table-scroll::-webkit-scrollbar-track {
  background: var(--soft);
}

.cc-runners-table-scroll::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

.cc-runners-table {
  width: 100%;
  min-width: 1290px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95rem;
  background: var(--card);
}

.cc-runners-table thead {
  background: var(--soft);
  position: sticky;
  top: 0;
  z-index: 10;
}

.cc-runners-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 2px solid var(--outline);
  white-space: nowrap;
  background: var(--soft);
}

/* STICKY COLUMNS: Number and Name */

.cc-th-sticky,
.cc-td-sticky {
  position: sticky;
  z-index: 20;
  background: var(--card);
}

.cc-th-sticky {
  z-index: 30;
  background: var(--soft);
}

/* Zebra striping for sticky columns - layered over opaque background */
.cc-runner-row:nth-child(even) .cc-td-sticky {
  background:
    linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05)),
    var(--card);
}

.cc-runner-row--np:nth-child(even) .cc-td-sticky {
  background:
    linear-gradient(rgba(239, 68, 68, 0.08), rgba(239, 68, 68, 0.08)),
    var(--card);
}

.cc-th-number,
.cc-td-number {
  left: 0;
  min-width: 54px;
  width: 54px;
}

.cc-th-name,
.cc-td-name {
  left: 54px;
  min-width: 200px;
  max-width: 250px;
}

.cc-td-name {
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.15);
}

/* SCROLLABLE COLUMN WIDTHS */

.cc-th-jockey, .cc-td-jockey { min-width: 180px; }
.cc-th-trainer, .cc-td-trainer { min-width: 150px; }
.cc-th-age-sex, .cc-td-age-sex { min-width: 120px; }
.cc-th-owner, .cc-td-owner { min-width: 180px; }
.cc-th-performance, .cc-td-performance { min-width: 200px; }
.cc-th-odds, .cc-td-odds { min-width: 100px; }
.cc-th-probability, .cc-td-probability { min-width: 90px; text-align: center; }

/* TABLE ROWS */

.cc-runner-row {
  transition: background 0.15s ease;
}

/* Zebra striping for even rows */
.cc-runner-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

.cc-runner-row:hover {
  background: #252d35;
}

.cc-runner-row--np {
  opacity: 0.5;
  background: rgba(239, 68, 68, 0.05);
}

.cc-runner-row--np:nth-child(even) {
  background: rgba(239, 68, 68, 0.08);
}

.cc-runner-row--np:hover {
  background: rgba(239, 68, 68, 0.12);
}

.cc-runners-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--outline);
  vertical-align: middle;
  color: var(--text);
}

/* CELL CONTENT STYLING */

.cc-table-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: #605d5d;
  color: #fff;
  font-weight: 500;
  font-size: 1rem;
  border-radius: 6px;
  margin: 0 auto;
}

.cc-table-name {
  font-weight: 700;
  font-size: 1rem;
  color: #e1e1e1;
}

.cc-table-jockey-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cc-table-silk {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 2px solid #e5e7eb;
  background: #c3c3c3;
  object-fit: cover;
  flex-shrink: 0;
}

.cc-table-perf {
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  color: #f6f7f9;
  letter-spacing: 0.05em;
}

.cc-table-odd-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cc-table-odd-current {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.cc-table-odd-opening {
  font-size: 0.85rem;
  color: var(--muted);
}

.cc-table-odd-opening-only {
  font-size: 1rem;
  font-weight: 600;
  color: #9ca3af; /* Gray to indicate opening odds */
}

.cc-table-trend {
  font-size: 1.1rem;
  margin-left: 0.5rem;
  display: inline-block;
}

.cc-table-probability {
  font-size: 1.1rem;
  font-weight: 600;
  color: #10b981;
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 4px;
}

.cc-table-status-np {
  font-weight: 800;
  font-size: 0.9rem;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  display: inline-block;
}

.cc-runner-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--soft);
  border-radius: 8px;
  border: 1px solid var(--outline);
  transition: all 0.15s ease;
}

.cc-runner-item:hover {
  background: #292d33;
  transform: translateX(2px);
}

.cc-runner-item--non-partant {
  opacity: 0.5;
  background: rgba(239, 68, 68, 0.05);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Runner number badge */
.cc-runner-number {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.cc-runner-number-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  border-radius: 6px;
  transform: skewX(-3deg);
}

/* Jockey silk image */
.cc-runner-silk {
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 6px;
  border: 2px solid var(--outline);
  overflow: hidden;
}

.cc-silk-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: crisp-edges;
}

/* Runner details */
.cc-runner-details {
  flex: 1;
  min-width: 0;
}

.cc-runner-horse {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.cc-runner-horse strong {
  font-weight: 800;
}

.cc-runner-age,
.cc-runner-gender {
  font-size: 0.85rem;
  opacity: 0.75;
  margin-left: 0.5rem;
}

.cc-runner-jockey,
.cc-runner-trainer {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-bottom: 0.25rem;
}

.cc-runner-weight {
  opacity: 0.7;
}

.cc-runner-performance {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.cc-perf-label {
  font-weight: 600;
  opacity: 0.9;
}

.cc-perf-codes {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
}

.cc-perf-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.3rem;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 3px;
  background: var(--pill);
  color: var(--text);
}

/* Position-based coloring for performance codes */
.cc-perf-pos--1 {
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #1a1a1a;
}

.cc-perf-pos--2 {
  background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
  color: #1a1a1a;
}

.cc-perf-pos--3 {
  background: linear-gradient(135deg, #cd7f32, #e8a87c);
  color: #1a1a1a;
}

.cc-perf-pos--4,
.cc-perf-pos--5,
.cc-perf-pos--6 {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.cc-perf-pos--7,
.cc-perf-pos--8,
.cc-perf-pos--9,
.cc-perf-pos--0 {
  background: rgba(107, 114, 128, 0.2);
  color: #9ca3af;
  opacity: 0.8;
}

/* Separator "p" */
.cc-perf-sep {
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  min-width: auto;
  padding: 0 0.15rem;
}

/* DNF indicators (D, A, T) */
.cc-perf-dnf {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  font-weight: 800;
}

/* Historical forms dropdown */
.cc-runner-forms {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.cc-runner-forms summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  padding: 0.25rem 0;
  transition: color 0.15s ease;
}

.cc-runner-forms summary:hover {
  text-decoration: underline;
  color: var(--accent-700);
}

.cc-forms-list {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border: 1px solid var(--outline);
}

.cc-form-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  align-items: center;
  font-size: 0.85rem;
}

.cc-form-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.cc-form-date {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.cc-form-track {
  font-weight: 500;
  opacity: 0.85;
}

.cc-form-position {
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  text-align: center;
  white-space: nowrap;
}

.cc-form-position--1 {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
}

.cc-form-position--2 {
  background: rgba(192, 192, 192, 0.2);
  color: #c0c0c0;
}

.cc-form-position--3 {
  background: rgba(205, 127, 50, 0.2);
  color: #cd7f32;
}

.cc-form-distance {
  font-size: 0.8rem;
  opacity: 0.7;
  white-space: nowrap;
}

/* Pedigree dropdown */
.cc-runner-pedigree {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.cc-runner-pedigree summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  padding: 0.25rem 0;
}

.cc-runner-pedigree summary:hover {
  text-decoration: underline;
}

.cc-runner-pedigree p {
  margin: 0.5rem 0 0 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--outline);
  opacity: 0.85;
  line-height: 1.6;
}

/* Odd display */
.cc-runner-odd {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 4rem;
  text-align: center;
}

.cc-odd-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}

.cc-odd-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cc-odd-badge--favorite {
  background: #ffd46b;
  color: #1a1a1a;
}

.cc-runner-odd--pending {
  opacity: 0.4;
  font-size: 1.5rem;
}

/* Non-partant status */
.cc-runner-status--np {
  font-weight: 800;
  font-size: 0.9rem;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
}

/* ===== Alerts ===== */
.cc-alert {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.cc-alert p {
  margin: 0 0 0.75rem 0;
}

.cc-alert p:last-child {
  margin-bottom: 0;
}

.cc-alert--info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.cc-alert--error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* ===== Action Buttons ===== */
.cc-race-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--outline);
}

.cc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
}

.cc-btn--primary {
  background: var(--accent);
  color: #fff;
}

.cc-btn--primary:hover {
  background: var(--accent-700);
  transform: translateY(-1px);
}

.cc-btn--ghost {
  background: transparent;
  border: 1px solid var(--outline);
  color: var(--text);
}

.cc-btn--ghost:hover {
  background: var(--soft);
  border-color: var(--muted);
}

/* ===== Error State ===== */
.cc-race-error {
  max-width: 600px;
  margin: 3rem auto;
  padding: 0 1rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .cc-race-detail {
    padding: 0 0.5rem 1.5rem;
  }

  .cc-race-header {
    padding: 1rem;
  }

  .cc-race-title {
    font-size: 1.25rem;
  }

  .cc-race-code {
    font-size: 0.9rem;
    padding: 0.15rem 0.5rem;
  }

  .cc-race-meta > span {
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
  }

  .cc-result-item {
    padding: 0.6rem 0.75rem;
    gap: 0.75rem;
  }

  .cc-result-details {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .cc-runner-item {
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .cc-runner-number-badge {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }

  .cc-runner-odd {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 0.5rem;
    min-width: auto;
    padding-left: 2.5rem;
  }

  .cc-odd-value {
    font-size: 1.1rem;
  }

  /* Dividend groups on mobile */
  .cc-dividend-group {
    padding: 0.65rem 0.85rem;
  }

  .cc-dividend-type {
    font-size: 0.9rem;
    padding-bottom: 0.4rem;
  }

  .cc-dividend-row,
  .cc-dividend-single {
    gap: 1rem;
    padding: 0.4rem 0;
  }

  .cc-dividend-combination {
    font-size: 0.85rem;
  }

  .cc-dividend-payout {
    font-size: 0.95rem;
  }

  .cc-race-actions {
    flex-direction: column;
  }

  .cc-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================
   ODDS TRACKING STYLES
   ============================================ */

/* Main odds display container */
.cc-odd-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.cc-odd-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

/* Favorite badge */
.cc-odd-badge--fav {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Movement trend badges */
.cc-odd-trend {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.cc-odd-trend--hot {
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  color: white;
  animation: pulse-glow 2s ease-in-out infinite;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.cc-odd-trend--backed {
  background: #dcfce7;
  color: #16a34a;
  border: 1px solid #86efac;
}

.cc-odd-trend--drift {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

@keyframes pulse-glow {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
  }
  50% {
    opacity: 0.85;
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.5);
  }
}

/* Odds history expandable section */
.cc-runner-odds-history {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.cc-runner-odds-history summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  padding: 0.3rem;
  user-select: none;
  list-style: none;
}

.cc-runner-odds-history summary::-webkit-details-marker {
  display: none;
}

.cc-runner-odds-history summary:hover {
  color: var(--accent);
}

.cc-runner-odds-history[open] summary {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

/* Chart container */
.cc-odds-chart-container {
  background: white;
  padding: 1rem;
  border-radius: 6px;
  margin: 0.5rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cc-odds-chart-container canvas {
  max-height: 150px;
}

/* Odds insights grid */
.cc-odds-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.cc-insight {
  text-align: center;
  padding: 0.5rem;
  background: white;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
}

.cc-insight--current {
  background: #fef3f2;
  border-color: var(--accent);
}

.cc-insight-label {
  display: block;
  font-size: 0.65rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.cc-insight-value {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}

@media (max-width: 480px) {
  .cc-race-meta {
    gap: 0.5rem;
  }

  .cc-race-meta > span {
    font-size: 0.8rem;
    padding: 0.25rem 0.4rem;
  }

  .cc-runner-horse {
    font-size: 1rem;
  }

  .cc-result-position {
    min-width: 3rem;
    font-size: 1rem;
  }

  /* Odds adjustments for mobile */
  .cc-odd-value {
    font-size: 1.3rem;
  }

  .cc-odd-trend {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }

  .cc-odds-insights {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================
   PMU-STYLE RUNNER CARDS
   ============================================ */

/* Runner card with PMU layout: [Left | Center | Right] */
.cc-runner-item--pmu {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: start;
  padding: 1rem;
  background: #1e2329;
  border-bottom: 1px solid #474d57;
  transition: background 0.2s;
}

.cc-runner-item--pmu:hover {
  background: #252d35;
}

/* LEFT: Number + Silk */
.cc-runner-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.cc-runner-number-large {
  font-size: 2rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
  min-width: 3rem;
  text-align: center;
}

.cc-runner-silk-compact {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid #e5e7eb;
  background: #c3c3c3;
  border-radius: 999px;
}

.cc-runner-silk-compact img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* CENTER: Horse info and metadata */
.cc-runner-center {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0; /* Allow text truncation */
}

.cc-horse-name-large {
  font-size: 1.25rem;
  font-weight: 700;
  color: #e1e1e1;
  margin: 0 0 0.25rem 0;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.cc-runner-meta-line {
  font-size: 1.2rem;
  color: #d9dfea;
  line-height: 1;
}

.cc-performance-inline {
  font-family: 'Courier New', monospace;
  font-size: 1.25rem;
  color: #f6f7f9;
  letter-spacing: 0.05em;
}

/* RIGHT: Odds display - PMU style */
.cc-runner-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 80px;
}

.cc-odd-opening-small {
  font-size: 1.125rem;
  font-weight: 600;
  color: #9ca3af;
}

.cc-odd-button {
  min-width: 70px;
  padding: 0.75rem 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  background: #115e59; /* Teal-700 like PMU */
  border-radius: 6px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
}

.cc-odd-button:hover {
  background: #0f766e; /* Teal-800 */
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.cc-odd-button--favorite {
  background: #f59e0b; /* Yellow for favorites */
}

.cc-odd-button--favorite:hover {
  background: #d97706;
}

.cc-odd-button--pending {
  background: #d1d5db;
  color: #6b7280;
}

/* Opening odds fallback style */
.cc-odd-button--opening {
  background: #6b7280; /* Gray for opening odds */
  opacity: 0.85;
  font-size: 1.25rem; /* Same size as regular odds */
}

.cc-odd-button--opening:hover {
  background: #4b5563;
  opacity: 1;
}

.cc-odd-label-small {
  font-size: 0.75rem; /* Slightly bigger for readability */
  color: var(--muted);
  text-align: center;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.cc-odd-trend-compact {
  font-size: 1.25rem;
  line-height: 1;
}

/* Non-partant styling */
.cc-runner-item--non-partant {
  opacity: 0.5;
  background: #fef2f2;
}

.cc-runner-item--non-partant:hover {
  background: #fee2e2;
}

/* Mobile adjustments */
@media (max-width: 640px) {
  /* Table view responsive */
  .cc-runners-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
  }

  .cc-view-toggle {
    align-self: flex-end;
  }

  .cc-runners-table {
    min-width: 990px;
  }

  .cc-th-name, .cc-td-name {
    min-width: 150px;
    max-width: 180px;
  }

  .cc-runners-table th,
  .cc-runners-table td {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .cc-table-number {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
  }

  .cc-table-silk {
    width: 28px;
    height: 28px;
  }

  .cc-table-odd-current {
    font-size: 1.1rem;
  }

  /* Card view responsive */
  .cc-runner-item--pmu {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 0.75rem;
  }

  .cc-runner-left {
    grid-row: 1 / 3;
  }

  .cc-runner-center {
    grid-column: 2;
  }

  .cc-runner-right {
    grid-column: 2;
    flex-direction: row;
    justify-content: flex-start;
    gap: 1rem;
  }

  .cc-runner-number-large {
    font-size: 1.5rem;
  }

  .cc-runner-silk-compact {
    width: 2.5rem;
    height: 2.5rem;
  }

  .cc-horse-name-large {
    font-size: 1.125rem;
  }

  .cc-odd-button {
    font-size: 1.25rem;
    padding: 0.5rem 0.75rem;
    min-width: 60px;
  }
}

/* Very small screens (iPhone SE 320px) */
@media (max-width: 400px) {
  .cc-runners-table {
    min-width: 840px;
  }

  .cc-th-name, .cc-td-name {
    min-width: 120px;
  }

  .cc-runners-table th,
  .cc-runners-table td {
    padding: 0.5rem;
    font-size: 0.85rem;
  }
}

/* ===== HIDE DRUPAL DEFAULT NAVIGATION ELEMENTS ===== */

/* Hide page title (race header already shows all info) */
.cc-race-detail .page-title,
.cc-race-detail h1.page-title {
  display: none !important;
}

/* Hide breadcrumb navigation */
.breadcrumb,
.region-breadcrumb,
nav[aria-label="breadcrumb"],
#block-casacourses-breadcrumbs,
.block-system-breadcrumb-block {
  display: none !important;
}

/* Hide main navigation menu */
.region-primary-menu,
.region-navigation,
#block-casacourses-main-menu,
.block-system-menu-block,
nav[role="navigation"]:not(.cc-race-nav) {
  display: none !important;
}

/* ============================================
   NEW RACE HEADER LAYOUT (v2)
   Based on the design mockup
   ============================================ */

.cc-race-header-v2 {
  padding: 0.75rem 0.95rem;
  margin-bottom: 1rem;
}

/* Time/Status Line */
.cc-race-time-status {
  margin-bottom: 1rem;
}

.cc-time-label {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.cc-time-label--upcoming {
  color: #6ee7b7; /* Teal/green for upcoming */
}

.cc-time-label--finished {
  color: #9ca3af; /* Gray for finished */
}

.cc-time-label--disabled {
  color: #f87171; /* Red for disabled/postponed */
}

.cc-time-static,
.cc-time-countdown,
.cc-time-running {
  /* Inherit color from parent label */
}

.cc-countdown-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Track Line: R# FLAG TRACK_NAME */
.cc-race-track-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.cc-track-flag {
  font-size: 1.5rem;
  margin-left: 0.25rem;
}

.cc-track-name {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Race Line: C# RACE_NAME */
.cc-race-name-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Slanted code pills (same as programme page) */
.cc-race-header-v2 .cc-code-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  height: 2.25rem;
  padding: 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  border-radius: 4px;
  transform: skewX(-8deg);
}

.cc-race-header-v2 .cc-code-pill--reunion {
  background: #6b7280;
  color: #fff;
}

.cc-race-header-v2 .cc-code-pill--race {
  background: #9ca3af;
  color: #1b1e26;
}

/* Official comment toggle (standalone, white) */
.cc-race-comment-v2 {
  margin: 0 0 1rem 0;
  padding: 0 0.95rem;
}

.cc-race-comment-v2 summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  padding: 0.5rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 0.15s ease;
}

.cc-race-comment-v2 summary::-webkit-details-marker {
  display: none;
}

.cc-race-comment-v2 summary::before {
  content: '▶';
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.cc-race-comment-v2[open] summary::before {
  transform: rotate(90deg);
}

.cc-race-comment-v2 summary:hover {
  opacity: 0.8;
}

.cc-race-comment-v2 p {
  margin: 0.5rem 0 0 0;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  border-left: 3px solid rgba(255, 255, 255, 0.3);
  font-size: 0.9rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
}

.cc-race-name-v2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  flex: 1;
  min-width: 0;
  /* Allow text truncation on very long names */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Info button */
.cc-info-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.cc-info-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

.cc-info-btn svg {
  width: 20px;
  height: 20px;
}

/* Date Line */
.cc-race-date-line {
  font-size: 1.125rem;
  font-weight: 600;
  color: #6ee7b7; /* Green accent */
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

/* Metadata Line */
.cc-race-meta-line {
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
  margin-bottom: 1rem;
}

/* Menu Buttons */
.cc-race-menu-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.cc-menu-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 1.25rem;
  background: #fff;
  border: none;
  border-radius: 9999px;
  color: #1f2937;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.cc-menu-pill:hover {
  background: #f3f4f6;
  transform: translateY(-1px);
}

.cc-menu-pill:active {
  transform: translateY(0);
}

/* Mobile adjustments for new header */
@media (max-width: 640px) {
  .cc-race-header-v2 {
    padding: 0.5rem 0.75rem;
  }

  .cc-time-label {
    font-size: 1.1rem;
  }

  .cc-track-name {
    font-size: 1.4rem;
  }

  .cc-track-flag {
    font-size: 1.25rem;
  }

  .cc-race-name-v2 {
    font-size: 1.4rem;
  }

  .cc-race-header-v2 .cc-code-pill {
    min-width: 2.5rem;
    height: 1.875rem;
    font-size: 0.95rem;
    padding: 0 0.5rem;
  }

  .cc-race-date-line {
    font-size: 1rem;
  }

  .cc-race-meta-line {
    font-size: 0.95rem;
  }

  .cc-menu-pill {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
}

@media (max-width: 400px) {
  .cc-race-name-v2 {
    font-size: 1.2rem;
  }

  .cc-track-name {
    font-size: 1.2rem;
  }

  .cc-race-header-v2 .cc-code-pill {
    min-width: 2.25rem;
    height: 1.75rem;
    font-size: 0.875rem;
  }

  .cc-race-date-line {
    font-size: 0.95rem;
  }

  .cc-race-meta-line {
    font-size: 0.9rem;
  }
}
