/* Table Styles - Entries and Standings
 * Based on design from rebelle-scoring-graphics.svg
 */

.scoring-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
}

.scoring-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0f1419; /* Solid dark background for dark mode */
}

.scoring-table tbody {
  width: 100%;
}

/* Table headers */
.scoring-table thead th {
  font-family: var(--font-body);
  font-size: var(--text-normal);
  font-weight: var(--weight-bold);
  color: var(--color-primary); /* Rebelle blue in dark mode */
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  padding: 16px 12px;
  border-bottom: 2px solid var(--border-primary);
}

/* Table body rows */
.scoring-table tbody tr {
  border-bottom: 0.5px solid var(--border-subtle);
  transition: background 0.15s ease;
  cursor: pointer;
}

.scoring-table tbody tr:hover {
  background: rgba(24, 159, 218, 0.08);
}

/* Alternating row background */
.scoring-table tbody tr:nth-child(odd) {
  background: rgba(0, 0, 0, 0.15);
}

.scoring-table tbody tr:nth-child(odd):hover {
  background: rgba(24, 159, 218, 0.12);
}

/* Table cells */
.scoring-table tbody td {
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  color: var(--text-primary);
  padding: 4px 12px;
  height: 48px;
  vertical-align: middle;
}

/* Column-specific styling */
.col-team {
  width: 100px;
  font-weight: var(--weight-bold);
  transition: color 0.2s ease;
}

.col-driver {
  min-width: 300px;
  transition: color 0.2s ease;
}

/* Hover effect - team and driver turn blue */
.scoring-table tbody tr:hover .col-team,
.scoring-table tbody tr:hover .col-driver {
  color: var(--color-primary);
}

.col-vehicle {
  width: 300px;
  min-width: 300px;
}

.col-designation {
  width: 120px;
  text-align: center;
}

.col-tech {
  width: 100px;
  text-align: center;
}

/* Standings page specific columns */
.col-rank {
  width: 80px;
  text-align: center;
}

/* Narrower driver column for standings (no hometown) */
.col-rank + .col-team + .col-driver {
  width: 280px;
  min-width: 280px;
}

.col-total {
  width: 100px;
  text-align: center;
}

.col-percent {
  width: 100px;
  text-align: center;
}

/* Tech status indicator */
.tech-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tech-status-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #00FF00;
}

.tech-status-dot.pending {
  background: #FFA500;
}

.tech-status-dot.incomplete {
  background: #FF0000;
}

/* Badge icons */
.badge-icons {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  height: 100%;
  
}

.badge-container {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.badge-icon {
  width: auto;
  height: 36px;
  display: block;
}

/* Badge Tooltips */
.badge-tooltip {
  position: fixed;
  background: var(--bg-panel-solid);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  width: 250px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 99999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.badge-container:hover .badge-tooltip {
  opacity: 1;
  visibility: visible;
}

.badge-tooltip-title {
  font-family: var(--font-heading);
  font-size: var(--text-small);
  color: var(--text-accent);
  text-transform: uppercase;
  letter-spacing: var(--spacing-wide);
  margin-bottom: var(--space-xs);
}

.badge-tooltip-text {
  font-family: var(--font-body);
  font-size: var(--text-tiny);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* Arrow for tooltip */
.badge-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: var(--color-primary);
}

/* ============================================
   ENTRIES PAGE MOBILE CARDS
   ============================================ */

/* Hide cards on desktop, show table */
@media (min-width: 769px) {
  .entries-cards,
  .standings-cards {
    display: none !important;
  }
}

/* Show cards on mobile, hide table */
@media (max-width: 768px) {
  .entries-cards,
  .standings-cards {
    display: block !important;
  }

  .entries-table-wrapper,
  .standings-table-wrapper {
    display: none !important;
  }

  /* Card structure matching daily-totals */
  .entries-cards .team-card,
  .standings-cards .team-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    transition: background 0.15s ease;
    cursor: pointer;
  }

  .entries-cards .team-card:hover,
  .standings-cards .team-card:hover {
    background: rgba(24, 159, 218, 0.08);
  }

  /* Card header: Team # only (entries) */
  .entries-cards .card-header {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-primary);
  }

  .entries-cards .card-header-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .entries-cards .card-header-label {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: var(--weight-bold);
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
  }

  /* Card header: Rank + Team # + Total + % (standings) */
  .standings-cards .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-primary);
  }

  .standings-cards .card-header-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
  }

  .standings-cards .card-stats {
    display: flex;
    align-items: baseline;
    gap: 16px;
  }

  /* Header items with labels */
  .standings-cards .card-header-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  /* Left side items - left aligned */
  .standings-cards .card-header-left .card-header-item {
    align-items: flex-start;
  }

  /* Right side items - right aligned */
  .standings-cards .card-stats .card-header-item {
    align-items: flex-end;
  }

  .standings-cards .card-header-label {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: var(--weight-bold);
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
  }

  .standings-cards .card-rank {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: var(--weight-bold);
    color: var(--color-primary);
    line-height: 1;
  }

  .standings-cards .card-total {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    line-height: 1;
  }

  .standings-cards .card-total.status-dq {
    color: #EF4444;
  }

  .standings-cards .card-percent {
    font-family: var(--font-body);
    font-size: var(--text-normal);
    font-weight: var(--weight-semibold);
    color: var(--color-primary);
    line-height: 1;
  }

  .entries-cards .card-team-num,
  .standings-cards .card-team-num {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    line-height: 1;
  }

  /* Driver names below header - white in dark mode */
  .entries-cards .card-drivers,
  .standings-cards .card-drivers {
    font-family: var(--font-body);
    font-size: var(--text-normal);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    margin-bottom: 20px;
  }

  /* Card sections with labels */
  .entries-cards .card-section,
  .standings-cards .card-section {
    margin-bottom: 16px;
  }

  .entries-cards .card-section:last-child,
  .standings-cards .card-section:last-child {
    margin-bottom: 0;
  }

  .entries-cards .card-label,
  .standings-cards .card-label {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: var(--weight-bold);
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
  }

  .entries-cards .card-value,
  .standings-cards .card-value {
    font-family: var(--font-body);
    font-size: var(--text-small);
    font-weight: var(--weight-normal);
    color: var(--text-primary);
  }

  /* Badge icons in cards - left aligned */
  .entries-cards .badge-icons,
  .standings-cards .badge-icons {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
  }

  .entries-cards .badge-icon,
  .standings-cards .badge-icon {
    height: 28px;
  }

  /* Tech status in card body */
  .entries-cards .tech-status {
    display: inline-flex;
    align-items: center;
  }
}

/* Light mode for cards */
@media (max-width: 768px) {
  :root[data-theme="light"] .entries-cards .team-card,
  :root[data-theme="light"] .standings-cards .team-card {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-subtle);
  }

  :root[data-theme="light"] .entries-cards .team-card:hover,
  :root[data-theme="light"] .standings-cards .team-card:hover {
    background: rgba(24, 159, 218, 0.08);
  }

  /* Driver names in light mode - use secondary color */
  :root[data-theme="light"] .entries-cards .card-drivers,
  :root[data-theme="light"] .standings-cards .card-drivers {
    color: var(--text-secondary);
  }

  :root[data-theme="light"] .col-driver {
    color: var(--text-secondary);
  }
}

/* Responsive: Mobile */
@media (max-width: 768px) {
  /* Switch to card layout on mobile */
  .scoring-table {
    display: block;
  }

  .scoring-table thead {
    display: none;
  }

  .scoring-table tbody {
    display: block;
    max-height: none;
    overflow-y: visible;
  }

  .scoring-table tbody tr {
    display: grid;
    grid-template-columns: 60px 1fr auto auto;
    grid-template-rows: auto auto auto auto;
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 16px;
    padding: 16px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    cursor: pointer;
    gap: 0;
    position: relative;
  }

  .scoring-table tbody tr:hover {
    background: rgba(24, 159, 218, 0.08);
  }

  .scoring-table tbody td {
    padding: 0;
    border: none;
  }

  /* Remove default labels for header cells only */
  .col-rank::before,
  .col-team::before,
  .col-total::before,
  .col-percent::before {
    content: none !important;
  }

  /* But keep the # symbol on team */
  .scoring-table tbody tr .col-team::before {
    content: '#' !important;
  }

  /* ============================================
     STANDINGS MOBILE CARD LAYOUT - Match Daily Totals Style
     ============================================ */

  /* Row 1: Header data (NO labels, just values like daily totals) */
  .col-rank {
    grid-column: 1;
    grid-row: 1;
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: var(--weight-bold);
    color: var(--color-primary);
    align-self: center;
    text-align: left;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-primary);
    margin-right: 8px;
  }

  .col-team {
    grid-column: 2;
    grid-row: 1;
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    align-self: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-primary);
  }

  .col-total {
    grid-column: 3;
    grid-row: 1;
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    text-align: right;
    align-self: center;
    padding-right: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-primary);
  }

  .col-percent {
    grid-column: 4;
    grid-row: 1;
    font-family: var(--font-body);
    font-size: var(--text-normal);
    font-weight: var(--weight-semibold);
    color: var(--color-primary);
    text-align: right;
    align-self: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-primary);
  }

  /* Row 2: Driver names - NO label, white in dark mode */
  .col-driver {
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 16px 0 16px 0;
    font-family: var(--font-body);
    font-size: var(--text-normal);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
  }

  /* Remove the DRIVER / CO-DRIVER label */
  .scoring-table tbody tr .col-driver::before {
    content: none !important;
    display: none !important;
  }

  /* Row 3: Vehicle with blue label */
  .col-vehicle {
    grid-column: 1 / -1;
    grid-row: 3;
    padding: 0 0 16px 0;
    font-family: var(--font-body);
    font-size: var(--text-small);
    font-weight: var(--weight-normal);
    color: var(--text-primary);
  }

  .scoring-table tbody tr .col-vehicle::before {
    content: 'VEHICLE' !important;
    display: block !important;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: var(--weight-bold);
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
  }

  /* Row 4: Designation badges with blue label */
  .col-designation {
    grid-column: 1 / -1;
    grid-row: 4;
    text-align: left;
    padding: 0;
  }

  .scoring-table tbody tr .col-designation::before {
    content: 'DESIGNATION' !important;
    display: block !important;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: var(--weight-bold);
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
  }

  /* ============================================
     ENTRIES MOBILE CARD LAYOUT - Cleaner Design
     ============================================ */

  /* For entries page without rank/total/percent columns */
  /* Adjust grid for entries (no rank/total/percent) */
  .scoring-table tbody tr:not(:has(.col-rank)) {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto auto;
  }

  /* Row 1: Team number and tech status - both part of header with shared border */
  .scoring-table tbody tr:not(:has(.col-rank)) .col-team {
    grid-column: 1;
    grid-row: 1;
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    align-self: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-primary);
  }

  .scoring-table tbody tr:not(:has(.col-rank)) .col-tech {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 12px;
    padding-left: 12px;
    border-bottom: 1px solid var(--color-primary);
  }

  /* Row 2: Driver names - NO label, white in dark mode */
  .scoring-table tbody tr:not(:has(.col-rank)) .col-driver {
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 16px 0 16px 0;
    font-family: var(--font-body);
    font-size: var(--text-normal);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
  }

  /* Row 3: Vehicle with label */
  .scoring-table tbody tr:not(:has(.col-rank)) .col-vehicle {
    grid-column: 1 / -1;
    grid-row: 3;
    padding: 0 0 16px 0;
  }

  /* Row 4: Designation with label */
  .scoring-table tbody tr:not(:has(.col-rank)) .col-designation {
    grid-column: 1 / -1;
    grid-row: 4;
    padding: 0;
  }

  /* Hide tech column on standings mobile (with rank) */
  .scoring-table tbody tr:has(.col-rank) .col-tech {
    display: none;
  }

  .badge-icon {
    height: 28px;
  }

  /* Don't turn team/driver blue on hover on mobile */
  .scoring-table tbody tr:hover .col-team,
  .scoring-table tbody tr:hover .col-driver {
    color: var(--text-primary);
  }
}

/* Smaller mobile screens */
@media (max-width: 400px) {
  .scoring-table tbody tr {
    padding: 10px;
    margin-bottom: 10px;
  }

  .scoring-table tbody td {
    padding: 6px 0;
  }

  .badge-icon {
    height: 24px;
  }
}

/* ============================================
   LIGHT MODE OVERRIDES
   ============================================ */

:root[data-theme="light"] .scoring-table thead {
  background: #ffffff; /* Solid white background for light mode */
}

:root[data-theme="light"] .scoring-table thead th {
  color: var(--color-navy); /* Dark text in light mode */
}

:root[data-theme="light"] .scoring-table tbody tr:nth-child(odd) {
  background: rgba(0, 0, 0, 0.03);
}

:root[data-theme="light"] .scoring-table tbody tr:nth-child(odd):hover {
  background: rgba(24, 159, 218, 0.12);
}

:root[data-theme="light"] .scoring-table tbody tr:hover {
  background: rgba(24, 159, 218, 0.08);
}

/* Light mode scrollbar */
:root[data-theme="light"] .scoring-table tbody::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 5px;
}

:root[data-theme="light"] .scoring-table tbody::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border: 2px solid rgba(0, 0, 0, 0.05);
}

:root[data-theme="light"] .scoring-table tbody::-webkit-scrollbar-thumb:hover {
  background: #1fb5e8;
  border-color: rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] .scoring-table tbody {
  scrollbar-color: var(--color-primary) rgba(0, 0, 0, 0.05);
}

/* Light mode badge tooltips */
:root[data-theme="light"] .badge-tooltip {
  background: white;
  border: 2px solid var(--color-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

:root[data-theme="light"] .badge-tooltip-title {
  color: var(--color-navy);
}

:root[data-theme="light"] .badge-tooltip-text {
  color: var(--text-secondary);
}

:root[data-theme="light"] .badge-tooltip::after {
  border-top-color: var(--color-primary);
}

/* Light mode mobile cards */
@media (max-width: 768px) {
  :root[data-theme="light"] .scoring-table tbody tr {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-subtle);
  }

  /* Disable tooltips on mobile - they interfere with touch */
  .badge-tooltip {
    display: none !important;
  }
}

/* ============================================
   STANDINGS EXPAND/COLLAPSE FUNCTIONALITY
   ============================================ */

/* Shadowbox backdrop overlay */
.shadowbox-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.shadowbox-backdrop.backdrop-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Light mode backdrop */
:root[data-theme="light"] .shadowbox-backdrop {
  background: rgba(255, 255, 255, 0.92);
}

/* Expanded navigation bar */
.expanded-nav {
  display: none;
  position: absolute;
  top: 30px;
  right: 40px;
  max-width: 70%;
  height: 50px;
  background: rgba(15, 20, 25, 0.95);
  border: 1px solid var(--color-primary);
  border-radius: 8px;
  padding: 0 20px;
  z-index: 140;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  backdrop-filter: blur(10px);
}

.panel-container-expanded .expanded-nav {
  display: flex;
}

/* Flash prevention: Show navigation bar immediately only when will expand */
html.panel-will-expand .panel-container-expanded .expanded-nav {
  display: flex !important;
}

/* Move elements down when expanded */
.panel-container-expanded .class-tab {
  top: 55px !important;
}

.panel-container-expanded .panel-title {
  margin-top: 35px;
}

/* Class selector in expanded nav */
.expanded-class-selector {
  display: flex;
  gap: 10px;
  flex: 1;
  justify-content: center;
}

.expanded-class-selector button {
  background: transparent;
  border: 1px solid var(--color-primary);
  color: var(--text-primary);
  padding: 8px 20px;
  border-radius: 6px;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.expanded-class-selector button:hover {
  background: rgba(24, 159, 218, 0.1);
}

.expanded-class-selector button.active {
  background: var(--color-primary);
  color: white;
}

/* Theme toggle in expanded nav */
.expanded-theme-toggle {
  background: transparent;
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.expanded-theme-toggle:hover {
  background: rgba(24, 159, 218, 0.2);
  transform: scale(1.05);
}

/* Expand/collapse button */
.expand-button {
  position: absolute;
  top: 80px;
  right: 40px;
  z-index: 150;
  background: transparent;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease;
  padding: 0;
}

.panel-container-expanded .expand-button {
  top: 120px;
}

.expand-button:hover {
  background: rgba(24, 159, 218, 0.2);
  transform: scale(1.1);
}

.expand-button svg {
  width: 20px;
  height: 20px;
  transition: opacity 0.2s ease;
}

/* Tooltip for expand button */
.expand-tooltip {
  position: absolute;
  bottom: -35px;
  right: 0;
  background: var(--bg-panel-solid);
  border: 1px solid var(--color-primary);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.expand-button:hover .expand-tooltip {
  opacity: 1;
}

/* Hide expand button on mobile/tablet */
@media (max-width: 1280px) {
  .expand-button {
    display: none !important;
  }
}

/* Expanded panel state - desktop only */
@media (min-width: 1281px) {
  .panel-container-expanded {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 95vw !important;
    height: 95vh !important;
    max-width: 95vw !important;
    max-height: 95vh !important;
    border-radius: 16px;
    z-index: 9999;
    box-shadow: none;
    background-image: none !important;
    background: var(--bg-panel) !important;
    border: none !important;
  }

  /* Inset border */
  .panel-container-expanded::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    pointer-events: none;
    z-index: 1;
  }

  /* Light mode expanded panel */
  :root[data-theme="light"] .panel-container-expanded {
    background: white !important;
  }
}

/* Light mode nav adjustments */
:root[data-theme="light"] .expanded-nav {
  background: rgba(255, 255, 255, 0.95);
}

:root[data-theme="light"] .expanded-class-selector button {
  color: var(--color-navy);
}

:root[data-theme="light"] .expanded-class-selector button.active {
  background: var(--color-primary);
  color: white;
}
