/* ==========================================
   DTNR Tool – Dashboard Styles
   ========================================== */

.dashboard-body {
  background: var(--dust-deep);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Make navbar opaque on dashboard */
.dashboard-body .navbar {
  background: rgba(10, 9, 7, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}


/* --- Header --- */
.dash-header {
  background: rgba(10, 9, 7, 0.95);
  border-bottom: 1px solid rgba(212, 169, 84, 0.12);
  padding: 0 24px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.dash-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 100%;
  gap: 24px;
}
.dash-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.95rem;
  color: var(--sand);
  opacity: 0.7;
  letter-spacing: 1px;
}
.dash-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.dash-user {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.95rem;
  color: var(--sand-light);
  opacity: 0.8;
}
.dash-logout-btn {
  background: transparent;
  border: 1px solid rgba(192, 90, 48, 0.4);
  color: var(--terracotta);
  padding: 5px 14px;
  border-radius: 4px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
}
.dash-logout-btn:hover {
  background: rgba(192, 90, 48, 0.15);
}

/* --- Status Bar --- */
.dash-status-bar {
  max-width: 1400px;
  margin: 20px auto 0;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(212, 169, 84, 0.04);
  border: 1px solid rgba(212, 169, 84, 0.1);
  border-radius: 8px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.85rem;
  color: var(--sand-light);
}
.dash-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--terracotta);
  flex-shrink: 0;
}
.dash-status-dot.connected {
  background: #4caf50;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.5);
}
.dash-status-sep {
  opacity: 0.3;
}

.dash-archive-bar {
  max-width: 1400px;
  margin: 10px auto 0;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(212, 169, 84, 0.03);
  border: 1px solid rgba(212, 169, 84, 0.08);
  border-radius: 8px;
}

.dash-archive-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.6px;
  color: var(--sand);
  opacity: 0.7;
  white-space: nowrap;
}

.dash-archive-select {
  flex: 1;
  min-width: 0;
  background: rgba(10, 9, 7, 0.8);
  border: 1px solid rgba(212, 169, 84, 0.22);
  color: var(--sand-light);
  border-radius: 6px;
  height: 36px;
  padding: 0 10px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.95rem;
}

.dash-archive-select:focus {
  outline: none;
  border-color: rgba(212, 169, 84, 0.55);
}

.dash-archive-select:disabled {
  opacity: 0.55;
}

.dash-archive-controls {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash-archive-load-btn {
  height: 36px;
  min-width: 96px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid rgba(212, 169, 84, 0.35);
  background: rgba(212, 169, 84, 0.12);
  color: var(--sand-light);
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.dash-archive-load-btn:hover:not(:disabled) {
  background: rgba(212, 169, 84, 0.2);
}

.dash-archive-load-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.dash-btn--secondary {
  background: rgba(180, 180, 200, 0.10);
  border-color: rgba(180, 180, 200, 0.25);
  min-width: 80px;
}
.dash-btn--secondary:hover:not(:disabled) {
  background: rgba(180, 180, 200, 0.18);
}

/* --- Grid --- */
.dash-main {
  flex: 1;
  padding: calc(var(--nav-height, 70px) + 10px) 24px 40px;
}
.dash-grid {
  max-width: 1400px;
  margin: 20px auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

/* --- Cards --- */
.dash-card {
  background: rgba(212, 169, 84, 0.03);
  border: 1px solid rgba(212, 169, 84, 0.1);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.dash-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(212, 169, 84, 0.08);
}
.dash-card-tag {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  color: var(--sand);
  opacity: 0.6;
  letter-spacing: 1px;
}
.dash-card-body {
  padding: 24px 20px;
  flex: 1;
  min-height: 240px;
}

/* --- Stats bar (full-width above globe) --- */
.dash-card--stats-bar {
  max-width: 1400px;
  margin: 12px auto 0;
  background: rgba(212, 169, 84, 0.03);
  border: 1px solid rgba(212, 169, 84, 0.1);
  border-radius: 10px;
  overflow: hidden;
}
.dash-card--stats-bar .dash-card-header {
  padding: 10px 20px;
  border-bottom: 1px solid rgba(212, 169, 84, 0.08);
}
.dash-card--stats-bar .dash-card-body {
  padding: 10px 20px;
  min-height: 0;
}
.dash-card--stats-bar .dash-stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.dash-card--stats-bar .dash-stat-card {
  padding: 8px 10px;
}
.dash-card--stats-bar .dash-stat-icon {
  font-size: 1.4rem;
}
.dash-card--stats-bar .dash-stat-label {
  font-size: 0.65rem;
}
.dash-card--stats-bar .dash-stat-value {
  font-size: 0.9rem;
}
.dash-placeholder--inline {
  flex-direction: row;
  min-height: 0;
  gap: 10px;
  padding: 6px 0;
}
.dash-placeholder--inline .dash-placeholder-icon {
  font-size: 1.4rem;
  margin-bottom: 0;
}
.dash-placeholder--inline p {
  font-size: 0.85rem;
}

/* Top: full-width map in 16:9 */
.dash-card--map {
  grid-column: 1 / -1;
  grid-row: 1;
}
.dash-card--map .dash-card-body {
  padding: 0;
  min-height: 0;
  aspect-ratio: 16 / 9;
}

.dash-map-wrap {
  position: relative;
}

.dash-map-wrap #mapBody {
  width: 100%;
  height: 100%;
}

.dash-map-overlay-menu {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(10, 9, 7, 0.72);
  border: 1px solid rgba(212, 169, 84, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  backdrop-filter: blur(3px);
}

.dash-map-overlay-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  color: var(--sand-light);
  user-select: none;
}

.dash-map-overlay-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #d4a954;
}
.dash-map-overlay-sep {
  border: none;
  border-top: 1px solid rgba(212, 169, 84, 0.2);
  margin: 4px 0;
}

/* Division rank overlays on globe */
.dash-division-overlays {
  position: absolute;
  top: 0;
  left: 16px;
  bottom: 52px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 0;
  pointer-events: none;
}
.dash-div-overlay {
  background: rgba(10, 9, 7, 0.70);
  border: 1px solid rgba(212, 169, 84, 0.25);
  border-radius: 8px;
  padding: 4px 10px 5px;
  backdrop-filter: blur(3px);
  pointer-events: auto;
  width: 210px;
}
.dash-div-overlay-title {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.65;
  margin-bottom: 1px;
}
.dash-div-overlay-row {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.78rem;
  color: var(--sand-light);
  display: flex;
  align-items: baseline;
  gap: 4px;
  line-height: 1.25;
}
.dash-div-overlay-row .pos {
  font-weight: 700;
  flex-shrink: 0;
  width: 26px;
}
.dash-div-overlay-row .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.dash-div-overlay-row .dist {
  opacity: 0.5;
  font-size: 0.72rem;
  flex-shrink: 0;
  text-align: right;
  min-width: 48px;
}

.dash-map-globe {
  width: 100%;
  height: 100%;
  min-height: 260px;
}

.dash-map-globe canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Bottom row: full-width teams */
.dash-card--teams {
  grid-column: 1 / -1;
  grid-row: 2;
}

.dash-card--teams .dash-card-body {
  min-height: 280px;
}

/* Placeholder content */
.dash-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  opacity: 0.4;
  text-align: center;
}
.dash-placeholder-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}
.dash-placeholder p {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.95rem;
  color: var(--sand-light);
}

/* --- Footer --- */
.dash-footer {
  text-align: center;
  padding: 16px;
  border-top: 1px solid rgba(212, 169, 84, 0.08);
  font-size: 0.8rem;
  color: var(--sand-light);
  opacity: 0.4;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
  .dash-card--map,
  .dash-card--teams {
    grid-column: 1;
    grid-row: auto;
  }
  .dash-card--stats-bar .dash-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-card--map .dash-card-body {
    aspect-ratio: 16 / 9;
  }
  .dash-card--leaderboard {
    grid-row: auto;
  }
  .dash-card--leaderboard .dash-card-body {
    min-height: 300px;
  }
}

@media (max-width: 600px) {
  .dash-header {
    padding: 0 12px;
  }
  .dash-title {
    display: none;
  }
  .dash-main {
    padding: 0 12px 24px;
  }
  .dash-status-bar {
    font-size: 0.75rem;
  }
  .dash-archive-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .dash-archive-controls {
    width: 100%;
  }
  .dash-archive-load-btn {
    min-width: 88px;
  }
  .dash-card--stats-bar .dash-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================
   Dashboard – Leaderboard Table
   ========================================== */
.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.9rem;
}
.dash-table thead th {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  color: var(--sand);
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(212, 169, 84, 0.1);
  white-space: nowrap;
}
.dash-table tbody tr {
  border-bottom: 1px solid rgba(212, 169, 84, 0.04);
  transition: background 0.2s;
}
.dash-table tbody tr:hover {
  background: rgba(212, 169, 84, 0.04);
}
.dash-table td {
  padding: 7px 10px;
  color: var(--sand-light);
  vertical-align: middle;
}
.dash-rank {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--sand);
  opacity: 0.5;
  width: 36px;
  text-align: center;
}
.dash-row.dash-rank-top .dash-rank {
  opacity: 1;
  color: var(--sand);
}
.dash-row.dash-rank-top:first-child .dash-rank {
  color: #ffd700;
}
.dash-row.dash-rank-top:nth-child(2) .dash-rank {
  color: #c0c0c0;
}
.dash-row.dash-rank-top:nth-child(3) .dash-rank {
  color: #cd7f32;
}
.dash-team-name {
  font-weight: 600;
  color: var(--sand);
}
.dash-mono {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.82rem;
}
.dash-division-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ==========================================
   Dashboard – Map Canvas
   ========================================== */
.dash-map-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 4px;
}

/* --- Teams tab bar --- */
.dash-card--teams .dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dash-teams-tabs {
  display: flex;
  gap: 4px;
}
.dash-teams-tab {
  background: transparent;
  border: 1px solid rgba(212, 169, 84, 0.18);
  color: var(--sand-light);
  opacity: 0.5;
  padding: 4px 16px;
  border-radius: 4px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s, border-color 0.2s;
}
.dash-teams-tab:hover {
  opacity: 0.8;
}
.dash-teams-tab.active {
  opacity: 1;
  background: rgba(212, 169, 84, 0.12);
  border-color: rgba(212, 169, 84, 0.4);
}
.dash-teams-tab[data-division="bike"].active {
  border-color: #d4a954;
  color: #d4a954;
}
.dash-teams-tab[data-division="buggy"].active {
  border-color: #c05a30;
  color: #c05a30;
}
.dash-teams-tab[data-division="truck"].active {
  border-color: #5a8a5e;
  color: #5a8a5e;
}

/* ==========================================
   Dashboard – Teams Panel
   ========================================== */
.dash-division-group {
  margin-bottom: 16px;
}
.dash-division-group:last-child {
  margin-bottom: 0;
}
.dash-division-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 2px solid rgba(212, 169, 84, 0.2);
  margin-bottom: 8px;
}
.dash-division-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sand);
}
.dash-division-count {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  color: var(--sand-light);
  opacity: 0.5;
}

/* --- Team Table --- */
.dash-team-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.88rem;
}
.dash-team-table thead th {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.72rem;
  color: var(--sand);
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(212, 169, 84, 0.15);
  white-space: nowrap;
  text-align: center;
}
.dash-team-table tbody tr {
  border-bottom: 1px solid rgba(212, 169, 84, 0.04);
  transition: background 0.15s;
}
.dash-team-table tbody tr:hover {
  background: rgba(212, 169, 84, 0.05);
}
.dash-team-table td {
  padding: 5px 8px;
  color: var(--sand-light);
  vertical-align: middle;
  white-space: nowrap;
}
.tt-col-vis, .tt-col-rte { width: 36px; text-align: center; }
.tt-col-pos { width: 44px; text-align: center; font-family: 'Orbitron', sans-serif; font-size: 0.82rem; font-weight: 700; }
.tt-col-team { font-weight: 600; text-align: left; }
.tt-col-driver { opacity: 0.7; text-align: left; }
.tt-col-dist, .tt-col-rem, .tt-col-eta { text-align: center; }
.tt-col-status { text-align: center; font-family: 'Share Tech Mono', monospace; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.5px; }
.tt-status-rcv { color: #6ec96e; }
.tt-status-dnf { color: #e05050; }
.tt-status-off { color: #888; }
.tt-status-rdy { color: #d4a954; }
.tt-dnf { color: #e05050; font-size: 0.78rem; font-weight: 400; }

/* --- Checkbox toggle --- */
.tt-cb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  width: 20px;
  height: 20px;
}
.tt-cb input { position: absolute; opacity: 0; width: 0; height: 0; }
.tt-cb-mark {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(212, 169, 84, 0.35);
  border-radius: 3px;
  background: rgba(212, 169, 84, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.tt-cb-mark::after {
  content: "\200B";
  font-size: 11px;
  line-height: 1;
}
.tt-cb input:checked + .tt-cb-mark {
  background: rgba(212, 169, 84, 0.22);
  border-color: #d4a954;
}
.tt-cb input:checked + .tt-cb-mark::after {
  content: "✓";
  font-size: 11px;
  color: #d4a954;
  line-height: 1;
}
.tt-cb-disabled {
  opacity: 0.25;
  pointer-events: none;
}
.tt-cb-disabled .tt-cb-mark {
  border-color: rgba(136, 136, 136, 0.3);
  background: rgba(136, 136, 136, 0.06);
}

@media (max-width: 900px) {
  .tt-col-rem, .tt-col-eta { display: none; }
}
@media (max-width: 600px) {
  .tt-col-driver, .tt-col-rem, .tt-col-eta { display: none; }
  .dash-team-table { font-size: 0.8rem; }
  .dash-team-table thead th { font-size: 0.65rem; }
}

/* ==========================================
   Dashboard – Stats Panel
   ========================================== */
.dash-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.dash-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(212, 169, 84, 0.03);
  border-radius: 6px;
  border: 1px solid rgba(212, 169, 84, 0.06);
}
.dash-stat-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}
.dash-stat-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  color: var(--sand);
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.dash-stat-value {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--sand-light);
  margin-top: 2px;
}

@media (max-width: 600px) {
  .dash-stats-grid {
    grid-template-columns: 1fr;
  }
  .dash-table {
    font-size: 0.8rem;
  }
  .dash-table thead th {
    font-size: 0.65rem;
  }
}

/* ── Globe Team Markers ───────────────────────────────────── */
.globe-team-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  transform: translate(-11px, -11px);
}
.globe-team-marker svg {
  filter: drop-shadow(0 0 2px rgba(0,0,0,0.7));
}
.globe-team-marker-label {
  font: bold 9px 'Segoe UI', Arial, sans-serif;
  white-space: nowrap;
  text-shadow: 0 0 3px #000, 0 0 6px #000;
  margin-top: 1px;
  letter-spacing: 0.3px;
}

/* ── Replay Bar ───────────────────────────────────────────── */
.dash-replay-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 6;
  background: rgba(10, 9, 7, 0.82);
  border-top: 1px solid rgba(212, 169, 84, 0.30);
  padding: 8px 14px;
  backdrop-filter: blur(4px);
}

.dash-replay-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash-replay-play-btn {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(212, 169, 84, 0.45);
  border-radius: 6px;
  background: rgba(212, 169, 84, 0.12);
  color: #d4a954;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.dash-replay-play-btn:hover {
  background: rgba(212, 169, 84, 0.25);
}

.dash-replay-elapsed,
.dash-replay-total {
  font-family: 'Rajdhani', monospace;
  font-size: 0.85rem;
  color: var(--sand-light);
  min-width: 44px;
  text-align: center;
  flex-shrink: 0;
}

.dash-replay-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(212, 169, 84, 0.18);
  outline: none;
  cursor: pointer;
}
.dash-replay-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d4a954;
  border: 2px solid #1a1814;
  cursor: pointer;
}
.dash-replay-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d4a954;
  border: 2px solid #1a1814;
  cursor: pointer;
}

.dash-replay-speed {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.8rem;
  color: #d4a954;
  background: rgba(10, 9, 7, 0.8);
  border: 1px solid rgba(212, 169, 84, 0.35);
  border-radius: 5px;
  padding: 3px 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.dash-replay-speed option {
  background: #1a1814;
  color: #d4a954;
}
