:root {
  --primary-color: #2563eb; /* Royal Blue */
  --primary-hover: #1d4ed8;
  --accent-color: #f59e0b; /* Amber for highlights */
  --dark-bg: #0f172a;      /* Slate 900 */
  --card-bg: #1e293b;      /* Slate 800 */
  --text-main: #334155;    /* Slate 700 */
  --text-light: #f8fafc;   /* Slate 50 */
  --font-main: 'Outfit', sans-serif;
}

body {
  background-color: #f1f5f9; /* Slate 100 */
  margin: 0;
  font-family: var(--font-main);
  color: var(--text-main);
  line-height: 1.6;
}

/* Contenedor general */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* NAV fijo arriba */
nav {
  position: sticky;
  top: 0;
  width: 100%;
  background: rgba(15, 23, 42, 0.95); /* Semi-transparent dark */
  backdrop-filter: blur(10px);
  color: #fff;
  z-index: 1000;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

nav .container {
  display: flex;
  justify-content: flex-end; /* Alinea todo a la derecha */
  align-items: center;
  height: 70px;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 32px;
  margin: 0;
  padding: 0;
}

nav a {
  color: #cbd5e1; /* Slate 300 */
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

nav a:hover {
  color: #fff;
}

/* MAIN + FOOTER en columna */
.main-content {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 70px);
  padding-top: 40px;
  padding-bottom: 40px;
}

main {
  flex: 1;
  width: 100%;
}

/* --- SECCIÓN BANNER CARRERAS (PREMIUM STYLE) --- */
.banner-carreras {
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  border-radius: 24px;
  padding: 60px 40px;
  color: white;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
}

/* Efecto de brillo sutil en el fondo */
.banner-carreras::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 60%);
  pointer-events: none;
}

.banner-carreras h2 {
  font-size: 2.5rem;
  margin: 0 0 10px 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.banner-carreras p {
  font-size: 1.1rem;
  color: #cbd5e1;
  margin-bottom: 40px;
  max-width: 600px;
}

/* Lista de Carreras */
.lista-carreras {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lista-carreras li {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  /* Padding removed from here, moved to .race-content */
  padding: 0;
  display: block; /* Changed from flex to block to contain absolute elements */
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.lista-carreras li:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.race-bg-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.race-gradient-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, rgba(15, 23, 42, 0.95) 40%, rgba(15, 23, 42, 0.2) 100%);
  z-index: 2;
}

.race-content {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  width: 100%;
  box-sizing: border-box;
}

.lista-carreras strong {
  font-size: 1.2rem;
  display: block;
  color: #fff;
}

.lista-carreras li span { /* Assuming date might be wrapped or just text */
  color: #94a3b8;
}

/* Botones */
.btn {
  display: inline-block;
  background-color: var(--primary-color);
  color: white;
  padding: 12px 24px;
  border-radius: 50px; /* Pill shape */
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
}

.btn:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.4);
  transform: translateY(-1px);
}

/* FOOTER */
footer {
  background: #e2e8f0;
  padding: 40px 0;
  text-align: center;
  color: #64748b;
  margin-top: auto;
}
/* Botón Outline (Ver más) */
.ver-mas-container {
  text-align: center;
  margin-top: 30px;
}

.btn-outline {
  display: inline-block;
  background-color: transparent;
  color: #fff;
  padding: 12px 30px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.btn-outline:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: #fff;
  transform: translateY(-1px);
}

/* Estado Vacío (Sin Carreras) */
.no-carreras {
  text-align: center;
  padding: 40px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  color: #cbd5e1;
}

.no-carreras p {
  font-size: 1.2rem;
  margin: 0;
  color: #fff;
}

.no-carreras .subtexto {
  font-size: 1rem;
  color: #94a3b8;
  margin-top: 8px;
}

/* --- SECCIÓN RESULTADOS (PREMIUM STYLE) --- */
.banner-resultados {
  background: linear-gradient(135deg, #064e3b 0%, #111827 100%); /* Emerald to Dark */
  border-radius: 24px;
  padding: 60px 40px;
  color: white;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
}

.banner-resultados h2 {
  font-size: 2.5rem;
  margin: 0 0 10px 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.banner-resultados p {
  font-size: 1.1rem;
  color: #a7f3d0; /* Emerald 200 */
  margin-bottom: 40px;
  max-width: 600px;
}

/* Overlay específico para resultados (Verde/Oscuro) */
.race-gradient-overlay.overlay-resultados {
  background: linear-gradient(to right, rgba(6, 78, 59, 0.95) 40%, rgba(6, 78, 59, 0.2) 100%);
}

/* Botón Ver Resultados */
.btn-resultado {
  background-color: #10b981; /* Emerald 500 */
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

.btn-resultado:hover {
  background-color: #059669; /* Emerald 600 */
  box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4);
}

/* --- LOGIN PAGE STYLES --- */
.login-page {
  justify-content: center; /* Centra verticalmente si hay espacio */
  align-items: center;     /* Centra horizontalmente */
  background-color: #f8fafc; /* Slate 50 */
}

.login-container {
  width: 100%;
  max-width: 450px;
  padding: 20px;
}

.login-card {
  background: white;
  padding: 40px;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.login-card h1 {
  margin-top: 0;
  color: #1e293b;
  font-size: 2rem;
  font-weight: 700;
}

.login-subtitle {
  color: #64748b;
  margin-bottom: 30px;
}

/* Formularios */
.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #334155;
  font-weight: 600;
  font-size: 0.9rem;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 1rem;
  color: #1e293b;
  transition: all 0.2s;
  box-sizing: border-box; /* Importante para que el padding no rompa el ancho */
  font-family: inherit;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-block {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  margin-top: 10px;
  border: none;
  cursor: pointer;
}

.login-footer {
  margin-top: 24px;
  font-size: 0.9rem;
  color: #64748b;
}

.login-footer a {
  color: var(--primary-color);
  font-weight: 600;
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* Alertas */
.alert {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 24px;
  font-size: 0.95rem;
  text-align: left;
}

.alert.error-message {
  background-color: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert.success-message {
  background-color: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* Botón de Logout disfrazado de enlace (CSP Safe) */
.nav-form {
  display: inline;
  margin: 0;
  padding: 0;
}

.nav-link-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: #cbd5e1; /* Mismo color que nav a */
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.nav-link-btn:hover {
  color: #fff; /* Mismo hover que nav a */
}

/* --- Race Cards Grid (Added for Races View) --- */
.races-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.race-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.race-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.card-image {
    height: 160px;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-content {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-content h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: #1e293b;
}

.meta-info {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 1rem;
}

.btn-card {
    margin-top: auto;
    display: block;
    width: 100%;
    background-color: #6b7280;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    text-align: center;
    font-weight: 600;
    transition: background-color 0.2s;
    box-sizing: border-box;
}

.btn-card:hover {
    background-color: #4b5563;
}

/* --- Race Detail View --- */
.race-detail-card {
    background: white;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    margin-top: 2rem;
}

.race-hero {
    position: relative;
    height: 300px;
    background-color: #f1f5f9;
}

.race-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.race-hero-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 2rem;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.9) 0%, transparent 100%);
    color: white;
    box-sizing: border-box;
}

.race-hero-content h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.race-body {
    padding: 2rem;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 3rem;
}

/* Responsive: stack on mobile */
@media (max-width: 768px) {
    .race-body {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

.race-info h2 {
    color: #1e293b;
    margin-top: 0;
    font-size: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.race-info p {
    color: #475569;
    font-size: 1.1rem;
    line-height: 1.7;
}

.race-stats {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    height: fit-content;
}

.stat-item {
    margin-bottom: 1.5rem;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.25rem;
    color: #0f172a;
    font-weight: 500;
}

.race-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}

.btn-primary {
    background-color: #2563eb;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: #e2e8f0;
    color: #334155;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

/* --- Race Categories List (CSP Compatible) --- */
.race-categories-section {
    margin-bottom: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.race-categories-section h3 {
    font-size: 1.1rem;
    color: #334155;
    margin-bottom: 0.5rem;
}

.cat-list-container {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    color: #475569;
    font-size: 0.95rem;
}

.cat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cat-item {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed #cbd5e1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cat-name {
    font-weight: 600;
    color: #334155;
}

.cat-number {
    color: #94a3b8;
    font-size: 0.8em;
    margin-right: 6px;
}

.cat-age-badge {
    font-size: 0.85rem;
    background: #e2e8f0;
    padding: 2px 8px;
    border-radius: 4px;
    color: #475569;
}

.cat-empty {
    margin: 0;
    color: #94a3b8;
    font-style: italic;
}

/* --- Race Hero Fallback (CSP Compatible) --- */
.race-hero-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Page Header (Flex) --- */
.page-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

@media (max-width: 640px) {
    .page-header-flex {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        align-items: stretch;
    }
}

/* --- Create Race Form --- */
.form-container {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    max-width: 800px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.categories-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #e5e7eb;
}

.category-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1rem;
    background: #f9fafb;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #f3f4f6;
}

@media (max-width: 768px) {
    .category-row {
        grid-template-columns: 1fr;
    }
}

.btn-remove {
    background: #fee2e2;
    color: #ef4444;
    border: none;
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-remove:hover {
    background: #fecaca;
}

.btn-add {
    background: #dbeafe;
    color: #2563eb;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.btn-add:hover {
    background: #bfdbfe;
}

.form-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* --- CSP Helpers & New Classes --- */
.cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.cat-header h3 {
    margin: 0;
    color: #374151;
}

.form-group-compact {
    margin-bottom: 0;
}

.label-small {
    font-size: 0.85rem;
}

.btn-center {
    text-align: center;
}

/* --- Pilots Table Styles --- */
.pilots-list-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #e2e8f0;
}

.pilots-list-section h3 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: #1e293b;
}

.pilots-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.pilots-table th {
    text-align: left;
    padding: 1rem;
    background-color: #f8fafc;
    color: #64748b;
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
}

.pilots-table td {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
}

.pilots-table tr:hover td {
    background-color: #f1f5f9;
}

.pilot-name {
    font-weight: 500;
    color: #0f172a;
}

.badge-number {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    background-color: #e2e8f0;
    border-radius: 4px;
    font-family: monospace;
    font-weight: bold;
    color: #334155;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    background-color: #f8fafc;
    border-radius: 12px;
    border: 1px dashed #cbd5e1;
    color: #64748b;
}

/* --- Race Stats Sidebar (CSP Compliant) --- */
.stats-section-sidebar {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px dashed #e2e8f0;
}

.stats-label-primary {
    display: block;
    font-size: 0.875rem;
    color: #2563eb;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.stats-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.stats-total-text {
    font-weight: 600;
    color: #1e293b;
}

.stats-total-badge {
    background: #dbeafe;
    color: #1e40af;
    font-size: 1.1rem;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-weight: bold;
}

.stats-cat-list {
    font-size: 0.9rem;
}

.stats-cat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    color: #64748b;
}

/* --- Pilots Card Helpers --- */
.pilots-card-padding {
    padding: 2rem !important;
}

.title-clean {
    margin-top: 0 !important;
    color: #1e293b;
}

/* --- Admin Stats Grid (CSP Compliant) --- */
.stats-grid-container {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.stats-grid-title {
    font-size: 1.1rem;
    color: #334155;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.stat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    background: white;
}

.stat-card-label {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-card-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
}

.link-subtle {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #64748b;
    text-align: right;
}

.link-subtle a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.link-subtle a:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* --- CSP Utilities --- */
.hidden-form {
    display: none;
}

.race-fallback-icon {
    font-size: 5rem;
}

.icon-muted {
    color: #64748b;
    margin-right: 8px;
}

/* --- Action Buttons (Table) --- */
.actions-cell {
    white-space: nowrap;
    width: 1%; /* Fit to content */
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    margin-right: 4px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-icon:last-child {
    margin-right: 0;
}

.btn-icon:hover {
    transform: translateY(-2px);
}

.action-edit {
    background: #dbeafe;
    color: #2563eb;
}

.action-edit:hover {
    background: #bfdbfe;
    color: #1d4ed8;
}

.action-assign {
    background: #fef9c3;
    color: #d97706;
}

.action-assign:hover {
    background: #fde047;
    color: #b45309;
}

.action-change-num {
    background: #f1f5f9;
    color: #64748b;
}

.action-change-num:hover {
    background: #e2e8f0;
    color: #334155;
}

/* --- Utilities --- */
.text-right {
    text-align: right !important;
}

/* --- SVG Icons Support --- */
.btn-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

svg.icon-muted {
    width: 1.2rem;
    height: 1.2rem;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    vertical-align: middle;
}

/* --- Result Tables (CSP Compliant) --- */
.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 2rem;
}

.btn-filter {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-filter:hover {
    background: #f1f5f9;
    color: #334155;
    transform: translateY(-1px);
}

.btn-filter.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.results-table-container {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.results-table-container.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Podio Colors */
.podium-1 { background-color: #fefce8 !important; }
.podium-1 td:first-child .badge-pos { background: #fcd34d; color: #78350f; font-weight: bold; }

.podium-2 { background-color: #f8fafc !important; }
.podium-2 td:first-child .badge-pos { background: #cbd5e1; color: #334155; font-weight: bold; }

.podium-3 { background-color: #fff7ed !important; }
.podium-3 td:first-child .badge-pos { background: #fdba74; color: #7c2d12; font-weight: bold; }

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.results-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.results-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 0.95rem;
}

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

.badge-pos {
    display: inline-flex;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: bold;
}

.badge-category {
    background: #e0f2fe;
    color: #0369a1;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.table-time {
    font-family: monospace;
    font-size: 1.05rem;
    font-weight: 600;
}

.table-diff {
    color: #94a3b8;
    font-family: monospace;
    font-size: 0.9rem;
}

/* --- Race Hero Banner --- */
.race-hero {
    position: relative;
    width: 100%;
    height: 300px;
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.race-hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.2), rgba(0,0,0,0.7));
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 2rem;
    color: white;
}

.race-hero-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    line-height: 1.2;
}

.race-hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 0.5rem;
    font-weight: 500;
}

@media (max-width: 640px) {
    .race-hero {
        height: 200px;
        border-radius: 0; /* Full width on mobile looks better flat */
        margin-left: -1rem; /* Negative margin to break container padding if needed */
        margin-right: -1rem;
        width: calc(100% + 2rem);
    }
    .race-hero-title {
        font-size: 1.8rem;
    }
}

/* CSP Fix for Race Hero */
.race-hero-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}
/* Ensure overlay is on top */
.race-hero-overlay {
    z-index: 1;
}

/* --- Form Improvements for Edit Race --- */
.input-field[readonly] {
    background-color: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

.input-helper-text {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 0.8rem;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group.half-width {
    flex: 1;
    margin-bottom: 0; /* Let row handle gap */
}

/* Ensure select and textarea look good */
textarea.input-field {
    min-height: 100px;
    line-height: 1.5;
    font-family: monospace; /* Better for JSON editing */
}

select.input-field {
    appearance: none; /* Custom arrow ideally */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

/* --- Admin Edit Button --- */
.btn-tertiary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background-color: #ffffff;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    gap: 0.5rem;
}

.btn-tertiary:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
    color: #1e293b;
    transform: translateY(-1px);
}

/* --- Modern Form Elements --- */

/* Custom Select styling to match input fields but with a custom arrow */
.form-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25em;
    padding-right: 2.5rem !important; /* Make room for the arrow */
    cursor: pointer;
}

/* Specific style for code configuration textareas */
.input-code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    line-height: 1.4;
    background-color: #f8fafc;
    border-color: #cbd5e1;
    color: #334155;
    tab-size: 2;
    white-space: pre;
    overflow-x: auto; /* Allow scrolling for long lines */
}

/* Focus state for select to match inputs */
.form-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* --- FINAL FIX FOR FORM ELEMENTS --- */

/* 1. Ensure .input-field has base styles (cloned from .form-control) */
.input-field {
    width: 100%;
    padding: 0.75rem 1rem; /* More comfortable padding */
    border: 1px solid #d1d5db;
    border-radius: 8px; /* Slightly more rounded */
    font-size: 1rem;
    line-height: 1.5;
    color: #1e293b;
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    font-family: inherit;
    margin: 0; /* Reset margins */
}

.input-field:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 2. Specific fixes for Selects to match Inputs perfectly */
select.form-select.input-field {
    appearance: none;
    padding-right: 2.5rem; /* Space for arrow */
    height: auto; /* Let padding define height */
    /* Ensure background is white and arrow is visible */
    background-color: #fff;
    background-image: url('/img/icon-chevron.svg'); /* Local file CSP Safe */
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25em;
    cursor: pointer;
}

/* 3. Helper for code textarea */
textarea.input-code {
    min-height: 200px; /* Taller for JSON */
    font-family: 'Courier New', Courier, monospace !important;
    background-color: #f8fafc;
    font-size: 0.9rem;
}

/* --- Select Icons (Local Files) --- */

/* 1. Carrera/Tipo */
select.select-icon-type.form-select {
    background-image:
        url('/img/icon-chevron.svg'),
        url('/img/icon-flag.svg') !important;

    background-position: right 1rem center, left 0.75rem center !important;
    background-size: 1.25em, 1.25em !important;
    padding-left: 2.75rem !important;
    background-repeat: no-repeat !important;
}

/* 2. Estado/Visibilidad */
select.select-icon-status.form-select {
    background-image:
        url('/img/icon-chevron.svg'),
        url('/img/icon-eye.svg') !important;

    background-position: right 1rem center, left 0.75rem center !important;
    background-size: 1.25em, 1.25em !important;
    padding-left: 2.75rem !important;
    background-repeat: no-repeat !important;
}

/* --- Pilots View Helpers (CSP Fixes) --- */
.table-container {
    overflow-x: auto;
    margin-top: 2rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.pilot-meta {
    font-size: 0.85em;
    color: #64748b;
    margin-top: 2px;
}

.link-race {
    text-decoration: none;
    color: #2563eb;
    font-weight: 500;
}

.link-race:hover {
    text-decoration: underline;
}

.text-muted {
    color: #94a3b8;
}

.text-placeholder {
    color: #cbd5e1;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.placeholder-icon {
    font-size: 3rem;
    text-align: center;
    line-height: 1.5;
}
