/* Estilos base */
:root {
  --primary: #1a3e72;
  --secondary: #e31937;
  --accent: #f8b133;
  --light: #f5f5f5;
  --dark: #333333;
  --gray: #777777;
  --white: #ffffff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', 'Roboto', sans-serif;
  line-height: 1.6;
  color: var(--dark);
  background-color: var(--light);
}

/* Header */
.header {
  background-color: var(--primary);
  color: white;
  padding: 1.5rem 0;
  text-align: center;
  margin-bottom: 2rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.header h1 {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
}

.header .subheader {
  font-size: 1.1rem;
  opacity: 0.9;
}

/* Contenedor principal */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Tarjetas */
.card {
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  margin-bottom: 2rem;
  overflow: hidden;
}

.card-header {
  background-color: var(--secondary);
  color: white;
  padding: 1rem;
  font-size: 1.3rem;
  font-weight: 500;
}

.card-body {
  padding: 1.5rem;
}

/* Tablas */
.table-responsive {
  overflow-x: auto;
}

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

th, td {
  padding: 12px 15px;
  text-align: center;
  border-bottom: 1px solid #e0e0e0;
}

/* SOLO los th con clase .apparatus-icon-header o dentro de .navbar tienen texto blanco */
.navbar th,
.apparatus-icon-header th,
th.apparatus-icon-header {
  color: white !important;
}

/* Para el resto de th, texto negro por defecto */
th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #000000 !important;  /* Forzar texto negro */
}

/* Específicamente para las tablas con clase table-light */
.table-light th,
.table-light th *,
th.table-light,
.table-light thead th {
  color: #000000 !important;
  background-color: #f8f9fa !important;
}

/* Para las cabeceras de las tablas de resultados */
thead th {
  color: #000000 !important;
  background-color: #f8f9fa;
}

/* Para los th que contienen enlaces */
th a {
  color: #000000 !important;
  text-decoration: none;
}

th a:hover {
  text-decoration: underline;
}

/* Eliminar cualquier regla que pueda estar forzando blanco */
th:not(.navbar th):not(.apparatus-icon-header) {
  color: #000000 !important;
}

tr:nth-child(even) {
  background-color: #f9f9f9;
}

tr:hover {
  background-color: #f0f0f0;
}

/* Aparatos específicos */
.salto { color: #1a3e72; }
.asimetricas { color: #e31937; }
.barra { color: #4caf50; }
.suelo { color: #9c27b0; }

/* Botones */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 4px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  border: 1px solid var(--primary);
}

.btn-primary:hover {
  background-color: #122a54;
  border-color: #122a54;
}

.btn-danger {
  background-color: var(--secondary);
  color: white;
  border: 1px solid var(--secondary);
}

.btn-danger:hover {
  background-color: #c0142d;
  border-color: #c0142d;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.85rem;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 62, 114, 0.2);
}

/* Alertas */
.alert {
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
}

.alert-success {
  background-color: #d4edda;
  color: #155724;
  border-left: 4px solid #28a745;
}

.alert-danger {
  background-color: #f8d7da;
  color: #721c24;
  border-left: 4px solid #dc3545;
}

/* Login */
.login-container {
  max-width: 400px;
  margin: 3rem auto;
}

/* Responsive */
@media (max-width: 768px) {
  .header h1 {
    font-size: 1.8rem;
  }
  
  th, td {
    padding: 8px 10px;
    font-size: 0.85rem;
  }
  
  .card-body {
    padding: 1rem;
  }
}

/* Estilos para los botones de categoría en el header */
.menu-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.menu-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  background-color: rgba(255, 255, 255, 0.15);
  color: white !important;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.menu-button:hover {
  background-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.menu-button i {
  color: white !important;
}

/* Estilos para los iconos de aparatos en las tablas */
.apparatus-icon {
  color: #000000 !important;  /* Cambiado a negro */
}

.apparatus-icon i {
  color: #000000 !important;  /* Cambiado a negro */
}

/* Para los iconos dentro de las celdas de notas */
td .apparatus-icon {
  color: #000000;
}

/* Estilos para los iconos de aparatos personalizados */
.apparatus-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  transition: all 0.3s ease;
}

.apparatus-icon:hover .apparatus-img {
  transform: scale(1.2);
}

/* ===== ESTILOS PARA LOGO Y NAVBAR ===== */

/* Estilos para el navbar personalizado */
.navbar-brand-custom {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-img {
    height: 65px;
    width: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
    vertical-align: middle;
    display: inline-block;
    margin: 0;
    padding: 0;
}

.logo-img:hover {
    transform: scale(1.05);
}

.trofeo-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    letter-spacing: 0.5px;
    line-height: 1.2;
    margin: 0;
    padding: 0;
    display: inline-block;
    vertical-align: middle;
}

/* Botón de volver */
.back-button {
    transition: all 0.3s ease;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white !important;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: fit-content;
    align-self: center;
}

.back-button:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: translateX(-3px);
    color: white !important;
}

.back-button i {
    color: white;
}

/* Contenedor flexible para el navbar */
.navbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 80px;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 100%;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
    height: 100%;
}

/* Estilos para el texto del aparato */
.apparatus-title {
    font-size: 1.5rem;
    margin: 0;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 100%;
}

.apparatus-title img {
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 5px;
    display: inline-block;
    vertical-align: middle;
}

/* Para el navbar de Bootstrap */
.navbar {
    min-height: 80px;
    padding: 0.5rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.navbar .container {
    display: flex;
    align-items: center;
    min-height: 80px;
}

/* Ajustes específicos para la fila del navbar */
.navbar .d-flex {
    display: flex;
    align-items: center !important;
}

/* Asegurar que los textos en el navbar sean blancos (solo en navbar) */
.navbar-text {
    color: white !important;
    display: flex;
    align-items: center;
    height: 100%;
}

/* Estilos para la fecha en el navbar */
.navbar-date {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: fit-content;
}

.navbar-date i {
    color: rgba(255, 255, 255, 0.9);
}

/* Para los iconos de aparatos en el header del navbar (solo aquí deben ser blancos) */
.apparatus-header-icon {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: white;
    height: 100%;
}

.apparatus-header-icon img {
    filter: brightness(0) invert(1);
    width: 30px;
    height: 30px;
    object-fit: contain;
}

/* Fix para cualquier desajuste en flexbox */
.d-flex.align-items-center {
    display: flex !important;
    align-items: center !important;
}

/* Responsive para tablets */
@media (max-width: 992px) {
    .navbar-left {
        flex-wrap: wrap;
    }
    
    .trofeo-title {
        font-size: 1.3rem;
    }
    
    .logo-img {
        height: 55px;
    }
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .navbar-content {
        flex-direction: column;
        gap: 10px;
        min-height: auto;
    }
    
    .navbar-left {
        width: 100%;
        justify-content: center;
        height: auto;
        min-height: 60px;
    }
    
    .navbar-right {
        width: 100%;
        justify-content: center;
        height: auto;
    }
    
    .trofeo-title {
        font-size: 1.1rem;
    }
    
    .logo-img {
        height: 45px;
    }
    
    .apparatus-title {
        font-size: 1.2rem;
    }
}

/* Responsive para móviles pequeños */
@media (max-width: 480px) {
    .navbar-left {
        gap: 10px;
    }
    
    .trofeo-title {
        font-size: 0.9rem;
    }
    
    .logo-img {
        height: 35px;
    }
    
    .back-button {
        padding: 0.3rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .apparatus-title {
        font-size: 1rem;
    }
    
    .apparatus-title img {
        width: 28px;
        height: 28px;
    }
}

/* Utilidades para el navbar de Bootstrap */
.navbar a {
    transition: all 0.3s ease;
}

/* ===== REGLAS FINALES PARA GARANTIZAR TEXTO NEGRO ===== */

/* Regla ultra específica: todos los th en cualquier tabla de resultados */
table th,
.thead th,
table thead th {
    color: #000000 !important;
    background-color: #f8f9fa !important;
}

/* Para los th con clase text-center (las columnas de iconos) */
table th.text-center {
    color: #000000 !important;
}

/* Para los th que contienen imágenes */
table th img {
    vertical-align: middle;
}

/* Excepción SOLO para el navbar */
.navbar table th,
.navbar th {
    color: white !important;
}

/* ==========================================================
   DISEÑO ADAPTABLE GLOBAL
   Prioridad: tablets en horizontal, sin perder soporte móvil
   ========================================================== */
html { -webkit-text-size-adjust: 100%; }
img, video, canvas, svg { max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; }
button, .btn, input[type="submit"], select { min-height: 42px; }
input, select, textarea { max-width: 100%; }
.table-responsive, .table-wrap, .table-container, .table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table { max-width: 100%; }
.card, .container, .container-fluid, main, section { min-width: 0; }
.navbar .container, .navbar .container-fluid { flex-wrap: wrap; }

/* Tablets en horizontal: espacio útil y controles cómodos */
@media screen and (min-width: 769px) and (max-width: 1366px) and (orientation: landscape) {
    body { font-size: 15px; }
    .container, .container-fluid { max-width: 100%; }
    .card, .card-body { padding: 1rem; }
    .table-responsive, .table-wrap { overflow-x: auto; }
    table th, table td { padding: .55rem .6rem; }
    input, select, textarea { min-height: 42px; }
    .btn, button { min-height: 44px; }
    .navbar { gap: .5rem; }
    .navbar-nav { flex-wrap: wrap; }
}

/* Móviles: evitar desbordamientos y facilitar pulsación */
@media screen and (max-width: 768px) {
    body { overflow-x: hidden; }
    .container, .container-fluid, .wrap, main {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    h1 { font-size: clamp(1.35rem, 5vw, 1.8rem); }
    h2 { font-size: clamp(1.15rem, 4.5vw, 1.5rem); }
    .card { margin-bottom: 1rem; }
    .card-body { padding: 12px; }
    .table-responsive, .table-wrap, .table-container, .table-wrapper {
        overflow-x: auto !important;
        max-width: 100%;
    }
    table { min-width: 620px; }
    th, td { white-space: nowrap; }
    input, select, textarea { min-height: 44px; font-size: 16px !important; }
    button, .btn, input[type="submit"] {
        min-height: 44px;
        touch-action: manipulation;
    }
    form .row, .form-row { row-gap: 10px; }
    .topbar, .top, .section-title {
        align-items: flex-start;
        gap: 10px;
    }
    .topbar > *, .top > * { max-width: 100%; }
    .navbar .navbar-collapse { width: 100%; }
    .navbar-nav { gap: 4px; }
}

/* Preferencias de accesibilidad */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}


/* Administración: cuadrículas y formularios fluidos */
.admin-grid, .dashboard-sections, .dashboard-stats {
    min-width: 0;
}
@media screen and (min-width: 769px) and (max-width: 1366px) {
    .dashboard-sections { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 18px; }
    .compact-form { table-layout: auto; }
    .compact-form th, .compact-form td { padding: 8px 6px; }
}
@media screen and (max-width: 900px) {
    .dashboard-sections { grid-template-columns: 1fr !important; }
}
@media screen and (max-width: 768px) {
    .topbar, .header, .navbar { padding-left: 10px; padding-right: 10px; }
    .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
    .dashboard-sections { grid-template-columns: 1fr !important; gap: 12px; }
    .action-buttons { grid-template-columns: 1fr !important; }
    .compact-form { min-width: 760px; }
    .form-control { max-width: 100% !important; }
    .btn, button { white-space: normal; }
    .login-container { max-width: 100%; }
}
