/* ── Circuit detail panel ───────────────────────────────────────────────── */

#circuit-panel {
  position: fixed;
  top: 52px;
  right: 0;
  width: 340px;
  max-height: 80vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.25);
  z-index: 800;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
  border-radius: 0 0 0 14px;
}

#circuit-panel.panel-open {
  transform: translateX(0);
}

/* ── Panel header ───────────────────────────────────────────────────────── */
#panel-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

/* Close button — inside panel top right */
#panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-pill);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  z-index: 1;
}

#panel-close:hover {
  background: var(--bg-pill-hover);
  color: var(--text-primary);
}

#panel-gp-name {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 3px;
  padding-right: 30px;
}

#panel-circuit-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 5px;
  padding-right: 30px;
}

#panel-location {
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
}

#panel-weather-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

#panel-weather-icon { font-size: 0.95rem; }
#panel-temp { color: var(--text-primary); font-weight: 600; }
#panel-weather-divider { color: var(--border); }
#panel-clock {
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  font-weight: 600;
}

/* ── Pills ──────────────────────────────────────────────────────────────── */
#panel-pills {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

#panel-pills::-webkit-scrollbar { display: none; }

.panel-pill {
  flex-shrink: 0;
  background: transparent;
  border: none;
  padding: 6px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 20px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  align-items: center;
  gap: 4px;
}

.panel-pill:hover:not(.active) {
  background: var(--bg-pill-hover);
  color: var(--text-primary);
}

.panel-pill.active {
  background: var(--accent);
  color: #ffffff;
}

/* ── Panel content area ─────────────────────────────────────────────────── */
#panel-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#panel-content::-webkit-scrollbar { width: 4px; }
#panel-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}



.panel-pane {
  display: none;
  padding: 14px 16px 20px;
}

/* Standings tab panels scroll independently */
.tab-panel {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  scrollbar-gutter: stable;
  padding-right: 4px;
  padding-bottom: 10px;
}

.tab-panel::-webkit-scrollbar { width: 4px; }
.tab-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Standings pane: label + tabs fixed, only table scrolls */
#pane-standings {
  display: none;
  padding: 14px 16px 0;
}

#pane-standings.active {
  display: flex;
  flex-direction: column;
}

#pane-standings .standings-round-label {
  flex-shrink: 0;
  padding: 0 0 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

#pane-standings .card-tabs {
  flex-shrink: 0;
  margin-bottom: 6px;
}






.panel-pane.active {
  display: block;
}

/* ── Track info pane ────────────────────────────────────────────────────── */
#panel-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat-item {
  background: var(--bg-card-inner);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.stat-item-label {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-item-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-item-unit {
  font-size: 0.6rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.stat-item-wide {
  grid-column: 1 / -1;
}

#panel-lap-record {
  background: var(--bg-card-inner);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

#panel-lap-record strong {
  color: var(--accent);
  font-size: 0.82rem;
}

/* ── Schedule pane ──────────────────────────────────────────────────────── */
.session-block {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.session-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.session-header:hover {
  background: var(--bg-pill);
}

.session-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.session-dot.past     { background: var(--accent); }
.session-dot.live     {
  background: var(--live-color);
  animation: livePulse 2s ease-in-out infinite;
}
.session-dot.upcoming { background: transparent; border: 2px solid var(--border); }

@keyframes livePulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(0,200,83,0.2); }
  50%      { box-shadow: 0 0 0 6px rgba(0,200,83,0.4); }
}

.session-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.session-label.live { color: var(--live-color); }

.session-time-str {
  font-size: 0.65rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.session-chevron {
  font-size: 0.65rem;
  color: var(--text-secondary);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.session-block.expanded .session-chevron {
  transform: rotate(180deg);
}



.session-results {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--bg-card-inner);
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.session-results::-webkit-scrollbar { width: 4px; }
.session-results::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}



.session-block.expanded .session-results {
  display: block;
}

.session-no-results {
  padding: 10px 12px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Results table inside session */
.session-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
}

.session-results-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.session-results-table tr:last-child td {
  border-bottom: none;
}

.result-pos {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  width: 24px;
  text-align: center;
}

.result-pos.p1 { color: #FFD700; }
.result-pos.p2 { color: #C0C0C0; }
.result-pos.p3 { color: #CD7F32; }

.result-driver {
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-team-bar {
  width: 3px;
  height: 16px;
  border-radius: 2px;
  flex-shrink: 0;
}

.result-abbr {
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

.result-pts {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
}

.result-status-dnf {
  font-size: 0.6rem;
  color: #ff6b6b;
  font-weight: 700;
}

/* ── Standings pane ─────────────────────────────────────────────────────── */
#panel-standings-pane .card-tabs {
  padding: 0 0 8px 0;
}






/* ── Mobile ─────────────────────────────────────────────────────────────── */



  @media (max-width: 768px) {
  #circuit-panel {
    width: 100%;
    top: auto;
    bottom: 0;
    height: auto;
    max-height: 60vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    z-index: 1200;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1),
                max-height 0.3s cubic-bezier(0.4,0,0.2,1);
  }

  #circuit-panel.panel-open {
    transform: translateY(0);
  }

  #circuit-panel.panel-expanded {
    max-height: calc(100vh - 52px);
  }

  #panel-expand-toggle {
    position: absolute;
    top: 10px;
    right: 44px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-pill);
    color: var(--text-secondary);
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
  }

  #panel-expand-toggle:hover {
    background: var(--bg-pill-hover);
    color: var(--text-primary);
  }
}

@media (min-width: 769px) {
  #panel-expand-toggle { display: none; }
}














@media (max-width: 480px) {
  #circuit-panel {
    max-height: 75vh;
  }
}


@media (max-width: 768px) {
  .leaflet-control-attribution {
    font-size: 0.42rem !important;
    padding: 1px 4px !important;
    line-height: 1.2 !important;
    opacity: 0.75;
  }
}





.panel-weather-label {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  opacity: 0.7;
}





/* ── Result note button and row ──────────────────────────────────────────── */



.result-note-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.7rem;
  color: #e10600;
  padding: 0 0 0 4px;
  vertical-align: middle;
  transition: color 0.15s, opacity 0.15s;
  line-height: 1;
}

.result-note-btn:hover {
  color: #ff3b30;
}








.result-note-text {
  font-size: 0.64rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 4px 10px 8px;
  line-height: 1.4;
  background: var(--bg-card-inner);
}