/* ============================================================
   Driver Score Dashboard — Estilos premium
   ============================================================ */

#page-scores {
  background: linear-gradient(135deg, #0d1117 0%, #161b22 60%, #0d1117 100%);
  min-height: 100%;
  padding: 0;
  color: #e6edf3;
}

/* ── Header ─────────────────────────────────────────────── */
.ds-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.ds-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ds-header-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #1565C0, #42A5F5);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 20px rgba(21, 101, 192, 0.4);
}

.ds-header-title {
  font-size: 22px;
  font-weight: 700;
  color: #e6edf3;
  letter-spacing: -0.3px;
}

.ds-header-sub {
  font-size: 13px;
  color: #8b949e;
  margin-top: 2px;
}

.ds-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ds-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.ds-btn-primary {
  background: linear-gradient(135deg, #1565C0, #1976D2);
  color: #fff;
  box-shadow: 0 2px 12px rgba(21, 101, 192, 0.35);
}
.ds-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(21, 101, 192, 0.5); }

.ds-btn-ghost {
  background: rgba(255,255,255,0.06);
  color: #8b949e;
  border: 1px solid rgba(255,255,255,0.1);
}
.ds-btn-ghost:hover { background: rgba(255,255,255,0.1); color: #e6edf3; }

/* ── KPI Cards ───────────────────────────────────────────── */
.ds-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  padding: 0 28px 20px;
}

.ds-kpi-card {
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid rgba(48, 54, 61, 0.8);
  border-radius: 14px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.ds-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.ds-kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--kpi-color, #1565C0);
}

.ds-kpi-icon {
  font-size: 22px;
  margin-bottom: 10px;
  display: block;
}
.ds-kpi-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--kpi-color, #e6edf3);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ds-kpi-label {
  font-size: 12px;
  color: #8b949e;
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ds-kpi-sub {
  font-size: 11px;
  margin-top: 6px;
  font-weight: 500;
}

/* ── Section dividers ────────────────────────────────────── */
.ds-section {
  padding: 0 28px 28px;
}

.ds-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ds-section-title {
  font-size: 15px;
  font-weight: 700;
  color: #e6edf3;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ds-section-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 16px;
  background: #1565C0;
  border-radius: 2px;
}

.ds-filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.ds-select {
  background: rgba(22,27,34,0.9);
  border: 1px solid rgba(48,54,61,0.8);
  color: #e6edf3;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.ds-select option { background: #161b22; }

/* ── Ranking Grid ────────────────────────────────────────── */
.ds-ranking-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* ── Driver Card ─────────────────────────────────────────── */
.ds-driver-card {
  background: rgba(22, 27, 34, 0.95);
  border: 1px solid rgba(48, 54, 61, 0.8);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.ds-driver-card:hover {
  transform: translateY(-3px);
  border-color: rgba(21, 101, 192, 0.5);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(21,101,192,0.2);
}
.ds-driver-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(21,101,192,0.04));
  pointer-events: none;
}

.ds-card-top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.ds-rank-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #8b949e;
  flex-shrink: 0;
  margin-top: 2px;
}
.ds-rank-badge.top3 {
  background: linear-gradient(135deg, #B8860B, #FFD700);
  color: #000;
}

.ds-card-info { flex: 1; min-width: 0; }

.ds-driver-name {
  font-size: 16px;
  font-weight: 700;
  color: #e6edf3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ds-driver-meta {
  font-size: 12px;
  color: #8b949e;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ds-nivel-pill {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  flex-shrink: 0;
  text-transform: uppercase;
}
.nivel-excelente { background: rgba(46,160,67,0.2);  color: #3fb950; border: 1px solid rgba(46,160,67,0.3); }
.nivel-bueno      { background: rgba(210,153,34,0.2);  color: #d29922; border: 1px solid rgba(210,153,34,0.3); }
.nivel-riesgoso   { background: rgba(249,117,2,0.2);   color: #f97316; border: 1px solid rgba(249,117,2,0.3); }
.nivel-peligroso  { background: rgba(248,81,73,0.2);   color: #f85149; border: 1px solid rgba(248,81,73,0.3); }

/* ── Gauge ───────────────────────────────────────────────── */
.ds-card-body {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ds-gauge-wrap {
  flex-shrink: 0;
  position: relative;
}

.ds-gauge-svg {
  width: 100px;
  height: 100px;
  transform: rotate(-225deg);
}

.ds-gauge-track {
  fill: none;
  stroke: rgba(255,255,255,0.06);
  stroke-width: 8;
  stroke-linecap: round;
}

.ds-gauge-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dasharray 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ds-gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ds-gauge-score-num {
  font-size: 22px;
  font-weight: 800;
  color: #e6edf3;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.ds-gauge-score-label {
  font-size: 10px;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Card Stats ──────────────────────────────────────────── */
.ds-card-stats {
  flex: 1;
  min-width: 0;
}

.ds-stat-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.ds-stat-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.ds-stat-chip.leve     { color: #d29922; border-color: rgba(210,153,34,0.2); background: rgba(210,153,34,0.08); }
.ds-stat-chip.moderado { color: #f97316; border-color: rgba(249,117,2,0.2);  background: rgba(249,117,2,0.08); }
.ds-stat-chip.grave    { color: #f85149; border-color: rgba(248,81,73,0.2);  background: rgba(248,81,73,0.08); }
.ds-stat-chip.sos      { color: #ff6b6b; border-color: rgba(255,107,107,0.3);background: rgba(255,107,107,0.1); }
.ds-stat-chip.clean    { color: #3fb950; border-color: rgba(46,160,67,0.2);  background: rgba(46,160,67,0.08); }

.ds-tendencia {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.tend-mejorando  { color: #3fb950; }
.tend-estable    { color: #8b949e; }
.tend-empeorando { color: #f85149; }

.ds-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.ds-badge {
  font-size: 18px;
  cursor: default;
  transition: transform 0.2s;
}
.ds-badge:hover { transform: scale(1.3); }

/* ── Mini bar chart (sparkline) ──────────────────────────── */
.ds-sparkline {
  margin-top: 12px;
  height: 32px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
}

.ds-spark-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  transition: height 0.8s ease;
  background: rgba(21, 101, 192, 0.6);
}
.ds-spark-bar:hover { background: rgba(21, 101, 192, 1); }
.ds-spark-bar.has-events { background: rgba(248, 81, 73, 0.6); }
.ds-spark-bar.has-events:hover { background: rgba(248, 81, 73, 1); }

/* ── Fleet distribution bar ─────────────────────────────── */
.ds-distribution {
  display: flex;
  height: 6px;
  border-radius: 4px;
  overflow: hidden;
  gap: 2px;
  margin: 12px 28px;
}
.ds-dist-segment {
  transition: flex 0.8s ease;
  border-radius: 4px;
}

/* ── Detail Modal ────────────────────────────────────────── */
.ds-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: dsOverlayIn 0.2s ease;
}
@keyframes dsOverlayIn { from { opacity:0 } to { opacity:1 } }

.ds-modal {
  background: #161b22;
  border: 1px solid rgba(48,54,61,0.8);
  border-radius: 20px;
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  overflow-y: auto;
  animation: dsModalIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
  scrollbar-width: thin;
  scrollbar-color: #30363d #0d1117;
}
@keyframes dsModalIn {
  from { opacity:0; transform: scale(0.9) translateY(20px) }
  to   { opacity:1; transform: scale(1)   translateY(0) }
}

.ds-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 16px;
  border-bottom: 1px solid rgba(48,54,61,0.6);
  position: sticky;
  top: 0;
  background: #161b22;
  z-index: 10;
}

.ds-modal-name {
  font-size: 20px;
  font-weight: 700;
  color: #e6edf3;
}

.ds-modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #8b949e;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.ds-modal-close:hover { background: rgba(248,81,73,0.15); color: #f85149; border-color: rgba(248,81,73,0.3); }

.ds-modal-body { padding: 24px; }

.ds-modal-hero {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.ds-modal-gauge-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.ds-modal-gauge-svg {
  width: 150px;
  height: 150px;
  transform: rotate(-225deg);
}

.ds-modal-info { flex: 1; min-width: 200px; }

.ds-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ds-info-cell {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 12px 14px;
}
.ds-info-cell-label { font-size: 11px; color: #8b949e; text-transform: uppercase; letter-spacing: 0.4px; }
.ds-info-cell-value { font-size: 18px; font-weight: 700; color: #e6edf3; margin-top: 4px; }
.ds-info-cell-value.green { color: #3fb950; }
.ds-info-cell-value.yellow { color: #d29922; }
.ds-info-cell-value.orange { color: #f97316; }
.ds-info-cell-value.red { color: #f85149; }

.ds-modal-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 20px 0 12px;
}

/* ── Infraction breakdown bars ───────────────────────────── */
.ds-infraction-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.ds-infraction-label { width: 80px; font-size: 12px; color: #8b949e; }
.ds-infraction-track { flex: 1; height: 8px; background: rgba(255,255,255,0.06); border-radius: 4px; overflow: hidden; }
.ds-infraction-bar { height: 100%; border-radius: 4px; transition: width 0.8s ease; }
.ds-infraction-count { width: 28px; font-size: 12px; font-weight: 700; text-align: right; }

/* ── Chart containers ────────────────────────────────────── */
.ds-chart-box {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

/* ── Geocercas list ──────────────────────────────────────── */
.ds-geocerca-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.ds-geocerca-name { flex: 1; font-size: 13px; color: #c9d1d9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-geocerca-track { width: 120px; height: 6px; background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden; }
.ds-geocerca-bar { height: 100%; background: linear-gradient(90deg, #1565C0, #42A5F5); border-radius: 3px; transition: width 0.8s ease; }
.ds-geocerca-count { font-size: 12px; font-weight: 700; color: #8b949e; width: 28px; text-align: right; }

/* ── Empty state ─────────────────────────────────────────── */
.ds-empty {
  text-align: center;
  padding: 60px 20px;
  color: #8b949e;
}
.ds-empty-icon { font-size: 48px; margin-bottom: 16px; }
.ds-empty-text { font-size: 15px; }

/* ── Skeleton loading ────────────────────────────────────── */
.ds-skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: dsSkeleton 1.5s infinite;
  border-radius: 8px;
}
@keyframes dsSkeleton {
  0%   { background-position: 200% 0 }
  100% { background-position: -200% 0 }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .ds-header, .ds-kpis, .ds-section { padding-left: 16px; padding-right: 16px; }
  .ds-ranking-grid { grid-template-columns: 1fr; }
  .ds-info-grid { grid-template-columns: 1fr; }
  .ds-modal-hero { flex-direction: column; align-items: center; }
}
