/* Estilos generales */
:root {
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --accent-color: #e74c3c;
  --light-color: #ecf0f1;
  --dark-color: #34495e;
  --success-color: #2ecc71;
  --warning-color: #f39c12;
}

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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  background-color: #f5f5f5;
  color: #333;
}

.container {
  width: 95%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 10px;
}

/* Header y navegación */
header {
  background-color: var(--primary-color);
  color: white;
  padding: 1rem 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

header h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 1.5rem;
}

header nav ul {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  gap: 10px;
  margin-bottom: 10px;
}

header nav a {
  color: white;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 4px;
  transition: background-color 0.3s;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9rem;
}

header nav a:hover {
  background-color: var(--secondary-color);
}

.user-menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-name {
  color: white;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Main content */
main {
  padding: 1rem 0;
  min-height: calc(100vh - 150px);
}

/* Cards */
.card {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 15px;
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

@media (min-width: 768px) {
  .card-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.card-title {
  font-size: 1.3rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Botones */
.btn {
  display: inline-block;
  padding: 8px 15px;
  background-color: var(--secondary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background-color 0.3s;
  text-align: center;
}

.btn:hover {
  background-color: #2980b9;
}

.btn-primary {
  background-color: var(--secondary-color);
}

.btn-success {
  background-color: var(--success-color);
}

.btn-warning {
  background-color: var(--warning-color);
}

.btn-danger {
  background-color: var(--accent-color);
}

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

.btn-sm {
  padding: 4px 8px;
  font-size: 0.8rem;
}

.w-100 {
  width: 100%;
}

.ml-2 {
  margin-left: 0.5rem;
}

.mt-3 {
  margin-top: 1rem;
}

.mt-4 {
  margin-top: 1.5rem;
}

.p-3 {
  padding: 1rem;
}

.p-4 {
  padding: 1.5rem;
}

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

/* Tablas */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

.table th {
  background-color: var(--primary-color);
  color: white;
}

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

.table tr:hover {
  background-color: #f1f1f1;
}

/* Responsive tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
  .table {
    border: 0;
  }

  .table thead {
    display: none;
  }

  .table tr {
    margin-bottom: 20px;
    display: block;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    background-color: #fff;
  }

  .table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid #eee;
  }

  .table td:last-child {
    border-bottom: 0;
  }

  .table td::before {
    content: attr(data-title);
    font-weight: bold;
    text-align: left;
    color: var(--primary-color);
  }

  .table td.actions-column {
    justify-content: center;
    padding-top: 15px;
    padding-bottom: 15px;
  }

  .table td.actions-column::before {
    display: none;
  }

  .btn-group {
    display: flex;
    gap: 10px;
    justify-content: center;
  }
}

/* Ranking específico */
.ranking-table .position {
  font-weight: bold;
  text-align: center;
}

.ranking-table .top-1 {
  background-color: gold;
  color: #333;
}

.ranking-table .top-2 {
  background-color: silver;
  color: #333;
}

.ranking-table .top-3 {
  background-color: #cd7f32; /* bronce */
  color: #333;
}

/* Formularios */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
}

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

.form-row {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 15px;
}

@media (min-width: 768px) {
  .form-row {
    flex-direction: row;
  }

  .form-row .form-group {
    flex: 1;
  }
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 576px) {
  .input-group {
    flex-direction: row;
  }

  .input-group-append {
    display: flex;
  }
}

/* Alertas */
.alert {
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.alert-success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-danger {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert-warning {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
}

/* Footer */
footer {
  background-color: var(--primary-color);
  color: white;
  text-align: center;
  padding: 1rem 0;
  margin-top: 2rem;
}

/* Estadísticas */
.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
}

.stat-card {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 15px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: bold;
  color: var(--secondary-color);
  margin: 10px 0;
}

.stat-card .stat-title {
  color: var(--dark-color);
  font-size: 1rem;
}

/* Partidas recientes */
.recent-matches {
  margin-top: 20px;
}

.match-card {
  display: flex;
  flex-direction: column;
  padding: 15px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  margin-bottom: 10px;
}

@media (min-width: 768px) {
  .match-card {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.match-players {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

@media (min-width: 576px) {
  .match-players {
    flex-direction: row;
    justify-content: center;
  }
}

.match-player {
  text-align: center;
}

.match-vs {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--accent-color);
  margin: 0 10px;
}

.match-winner {
  font-weight: bold;
  color: var(--success-color);
}

.match-points {
  background-color: var(--primary-color);
  color: white;
  padding: 5px 10px;
  border-radius: 20px;
  font-weight: bold;
  text-align: center;
  margin: 10px 0;
}

.match-date {
  color: #777;
  font-size: 0.9rem;
  text-align: center;
}

@media (min-width: 768px) {
  .match-points,
  .match-date {
    text-align: right;
  }
}

/* Asistencia */
.asistencia-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.asistencia-item {
  margin-bottom: 5px;
}

.asistencia-label {
  display: flex;
  align-items: center;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: all 0.2s;
}

.asistencia-label:hover {
  background-color: #f5f5f5;
}

.asistencia-label.presente {
  background-color: #d4edda;
  border-color: #c3e6cb;
}

.asistencia-label input {
  margin-right: 10px;
}

.alumno-nombre {
  flex-grow: 1;
  font-size: 0.9rem;
}

.alumno-puntos {
  font-weight: bold;
  color: var(--secondary-color);
  font-size: 0.9rem;
}

/* Emparejamientos */
.emparejamientos-container,
.alumnos-presentes-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.pareja-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  background-color: white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.pareja-card.partida-registrada {
  background-color: #d4edda;
  border-color: #c3e6cb;
}

.pareja-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

@media (min-width: 576px) {
  .pareja-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.pareja-numero {
  font-weight: bold;
  color: var(--primary-color);
}

.partida-badge {
  background-color: var(--success-color);
  color: white;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  display: inline-block;
}

.pareja-jugadores {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

@media (min-width: 576px) {
  .pareja-jugadores {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.pareja-jugador {
  flex: 1;
  text-align: center;
}

.pareja-vs {
  margin: 0 10px;
  font-weight: bold;
  color: var(--accent-color);
}

.jugador-nombre {
  font-weight: bold;
  margin-bottom: 5px;
  font-size: 0.9rem;
}

.jugador-puntos {
  color: var(--secondary-color);
  font-size: 0.9rem;
}

.alumno-presente-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px;
  background-color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: bold;
}

.bg-danger {
  background-color: var(--accent-color);
  color: white;
}

.bg-primary {
  background-color: var(--secondary-color);
  color: white;
}

/* Estilos para impresión */
@media print {
  /* Ocultar elementos que no se deben imprimir */
  header,
  footer,
  .btn,
  .no-print,
  nav,
  .card-header {
    display: none !important;
  }

  /* Resetear estilos para impresión */
  body,
  html {
    width: 100%;
    margin: 0;
    padding: 0;
    background-color: white;
    font-size: 12pt;
  }

  .container,
  main,
  .card {
    width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
    background-color: white;
  }

  /* Estilos para la tabla de ranking */
  .table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    page-break-inside: auto;
  }

  .table th {
    background-color: #f0f0f0 !important;
    color: black !important;
    border-bottom: 2px solid #333;
  }

  .table td,
  .table th {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
  }

  .table tr {
    page-break-inside: avoid;
  }

  /* Mantener colores para los top 3 */
  .ranking-table .top-1 {
    background-color: #ffd700 !important; /* gold */
  }

  .ranking-table .top-2 {
    background-color: #c0c0c0 !important; /* silver */
  }

  .ranking-table .top-3 {
    background-color: #cd7f32 !important; /* bronze */
  }

  /* Estilos para el encabezado y pie de página de impresión */
  .print-header,
  .print-footer {
    display: block;
    text-align: center;
    margin: 20px 0;
  }

  .print-header h1 {
    font-size: 18pt;
    margin-bottom: 5px;
  }

  .print-header p {
    font-size: 10pt;
    color: #666;
  }

  .print-footer {
    margin-top: 30px;
    font-size: 10pt;
    color: #666;
    border-top: 1px solid #ddd;
    padding-top: 10px;
  }

  /* Ocultar el encabezado y pie de página del navegador */
  @page {
    margin: 0.5cm;
  }
}

/* Estilos para el contenedor imprimible (solo visibles al imprimir) */
.print-header,
.print-footer {
  display: none;
}

#ranking-imprimible {
  width: 100%;
}

/* Estilos para dispositivos móviles */
@media (max-width: 576px) {
  .card {
    padding: 10px;
  }

  .card-title {
    font-size: 1.2rem;
  }

  .btn {
    padding: 6px 12px;
    font-size: 0.85rem;
  }

  .stats-container {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
  }

  .stat-card .stat-value {
    font-size: 1.5rem;
  }

  .stat-card .stat-title {
    font-size: 0.9rem;
  }

  .match-card {
    padding: 10px;
  }

  .match-vs {
    font-size: 1rem;
  }

  .match-points {
    font-size: 0.85rem;
  }

  .match-date {
    font-size: 0.8rem;
  }

  .asistencia-grid {
    grid-template-columns: 1fr;
  }

  .emparejamientos-container,
  .alumnos-presentes-container {
    grid-template-columns: 1fr;
  }

  .pareja-card {
    padding: 10px;
  }

  .jugador-nombre {
    font-size: 0.85rem;
  }

  .jugador-puntos {
    font-size: 0.8rem;
  }
}

/* Estilos para tarjetas de alumnos en móvil */
@media (max-width: 767px) {
  .alumno-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  }

  .alumno-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
  }

  .alumno-nombre {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--primary-color);
  }

  .alumno-puntos {
    font-weight: bold;
    color: var(--secondary-color);
    font-size: 1.2rem;
  }

  .alumno-info {
    margin-bottom: 15px;
  }

  .alumno-info-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #f5f5f5;
  }

  .alumno-info-label {
    font-weight: bold;
    color: #666;
  }

  .alumno-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
  }
}

/* Estilos para fotos de alumnos */
.alumno-foto {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary-color);
}

.alumno-foto-placeholder {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #adb5bd;
  font-size: 1.5rem;
  border: 2px solid #ced4da;
}

.foto-column {
  text-align: center;
}

.alumno-foto-lg {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary-color);
}

.alumno-foto-placeholder-lg {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background-color: #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #adb5bd;
  font-size: 2.5rem;
  border: 3px solid #ced4da;
}

.alumno-foto-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--primary-color);
  margin-right: 5px;
}

.alumno-foto-placeholder-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #e9ecef;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #adb5bd;
  font-size: 0.8rem;
  border: 1px solid #ced4da;
  margin-right: 5px;
}

/* Estilos para la ficha de alumno con foto */
.alumno-header-con-foto {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.alumno-info-con-foto {
  flex: 1;
}

/* Estilos para emparejamientos con fotos */
.jugador-card-con-foto {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.jugador-foto-container {
  margin-bottom: 10px;
}

/* Estilos para alumnos con foto en el ranking */
.alumno-con-foto {
  display: flex;
  align-items: center;
}

.oponente-con-foto {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Estilos para fotos en el podio */
.podium-foto {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #333;
}

.podium-foto-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #adb5bd;
  font-size: 1.5rem;
  border: 2px solid #ced4da;
  margin: 0 auto;
}

.podium-1 .podium-foto {
  width: 80px;
  height: 80px;
  border: 3px solid #333;
}

.podium-1 .podium-foto-placeholder {
  width: 80px;
  height: 80px;
  font-size: 2rem;
  border: 3px solid #ced4da;
}

/* Estilos para impresión de fotos */
@media print {
  .alumno-foto,
  .alumno-foto-lg,
  .alumno-foto-sm {
    border: 1px solid #333 !important;
    print-color-adjust: exact;
  }

  .alumno-foto-placeholder,
  .alumno-foto-placeholder-lg,
  .alumno-foto-placeholder-sm {
    background-color: #f0f0f0 !important;
    border: 1px solid #333 !important;
    color: #666 !important;
    print-color-adjust: exact;
  }
}
