/* Variables para consistencia de colores y facilidad de mantenimiento */
:root {
  --primary-color: #25064D;
  --secondary-color: #FFFBD6;
  --text-color: #4B4B4D;
  --border-color: #ddd;
  --success-color: #3CB371;
  --error-color: #FF5252;
  --hover-color: #f1f1f1;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --border-radius: 8px;
  --input-border: 1px solid #ccc;
  --input-focus-border: 2px solid #25064D;
}

/* Reset y estilos base */
.word-games-container *,
.seleccion-container * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Contenedor principal - Estructura mejorada con flexbox */
.word-games-container {
  display: flex;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 20px;
}


/* Categorías */
.word-games-categories {
  width: 22%;
  padding: 15px;
  flex-shrink: 0;
}

.word-games-categories h4 {
  font-size: 18px;
  color: var(--primary-color);
  font-weight: bold;
  margin-bottom: 15px;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 8px;
}

.word-games-categories ul {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  list-style: none;
  padding: 12px;
  background-color: #f9f9f9;
  box-shadow: var(--shadow);
}

.word-games-categories ul li {
  margin-bottom: 12px;
}

.word-games-categories ul li a {
  text-decoration: none;
  color: var(--text-color);
  cursor: pointer;
  position: relative;
  padding: 8px 8px 8px 24px;
  display: block;
  transition: all 0.3s ease;
  border-radius: 4px;
}

.word-games-categories ul li a::before {
  content: ''; 
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; 
  height: 16px;
  background-image: url('https://www.domenc.com/wp-content/uploads/2025/01/icon-game.png'); 
  background-size: contain; 
  background-repeat: no-repeat;
}

.word-games-categories ul li a:hover,
.word-games-categories ul li a.active {
  color: var(--primary-color);
  font-weight: bold;
  background-color: rgba(37, 6, 77, 0.05);
}

/* Grilla de juegos - usando Grid con control explícito de columnas */
.word-games-grid {
  width: 78%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 15px;
}

/* Estado sin resultados */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: var(--border-radius);
  border: 2px dashed var(--border-color);
}

.no-results-icon {
  font-size: 3em;
  margin-bottom: 20px;
  opacity: 0.6;
}

.no-results h3 {
  color: var(--text-color);
  margin-bottom: 10px;
  font-size: 1.4em;
}

.no-results p {
  color: var(--text-color);
  opacity: 0.7;
  font-size: 1em;
  line-height: 1.5;
}

.word-games-item {
  text-align: center;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  padding: 15px;
  background: #fff;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.5s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px);
}

.word-games-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.word-games-item img {
  width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  object-fit: cover;
  aspect-ratio: 16/9;
}

.no-image-placeholder {
  background-color: #f0f0f0;
  height: 140px;
  border-radius: var(--border-radius);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.no-image-placeholder::after {
  content: 'No imagen';
  color: #999;
  font-style: italic;
}

.word-games-item h3 {
  margin: 15px 0 10px;
  font-size: 18px;
  font-weight: bold;
  color: var(--primary-color);
  flex-grow: 1;
}

.word-games-item a {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  background-color: var(--primary-color);
  color: #fff;
  font-weight: bold;
  text-decoration: none;
  border-radius: 5px;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.word-games-item a:hover {
  background-color: var(--secondary-color);
  color: var(--primary-color);
  transform: scale(1.05);
}

/* Estilos para el indicador de carga moderno */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  grid-column: 1 / -1;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  text-align: center;
  height: 200px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.loading-indicator.fade-out {
  opacity: 0;
  transform: scale(0.95);
}

.loading-spinner {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  border: 3px solid rgba(37, 6, 77, 0.1);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  color: var(--primary-color);
  font-size: 18px;
  font-weight: 500;
  display: flex;
  align-items: center;
}

.dots {
  display: flex;
  margin-left: 5px;
}

.dot {
  font-size: 24px;
  line-height: 1;
  opacity: 0.3;
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: inline-block;
  margin-left: 1px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Mensaje de error y botón de reintento */
.error-message {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #fff1f0;
  border: 1px solid #ffa39e;
  padding: 20px;
  border-radius: var(--border-radius);
  text-align: center;
}

.error-icon {
  background-color: var(--error-color);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-bottom: 10px;
}

.retry-button {
  margin-top: 15px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.retry-button:hover {
  background-color: #33125E;
}

/* Mensaje de no hay items */
.no-items-message {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
  background-color: #f9f9f9;
  border-radius: var(--border-radius);
  color: var(--text-color);
  font-style: italic;
}

/* Media Queries mejoradas para mejor responsividad */
@media (max-width: 960px) {
  .word-games-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .search-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .sort-select {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .word-games-container {
    gap: 15px;
  }

  .word-games-main-content {
    flex-direction: column;
  }

  .word-games-categories,
  .word-games-grid {
    width: 100%;
  }

  .word-games-search-bar {
    padding: 15px;
  }

  .word-games-search {
    font-size: 16px; /* Prevenir zoom en iOS */
  }

  .search-filters {
    flex-direction: column;
    gap: 10px;
  }

  .results-info {
    text-align: center;
  }

  .word-games-categories ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
  }
  
  .word-games-categories ul li {
    margin-bottom: 0;
  }
  
  .word-games-categories h4 {
    margin-bottom: 10px;
  }
  
  .word-games-categories ul li a {
    white-space: nowrap;
    padding: 5px 10px 5px 24px;
  }
  
  .word-games-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .loading-spinner {
    width: 40px;
    height: 40px;
  }
  
  .loading-text {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .word-games-grid {
    grid-template-columns: 1fr;
  }
  
  .word-games-item h3 {
    font-size: 16px;
  }
  
  .word-games-categories ul {
    flex-direction: column;
  }
}

/* Estilos para mensajes de estado */
.mensaje-error,
.mensaje-exitoso {
  text-align: center;
  margin: 15px 0;
  padding: 12px;
  color: #fff;
  border-radius: var(--border-radius);
  animation: fadeIn 0.5s ease;
}

.mensaje-error {
  background-color: var(--error-color);
}

.mensaje-exitoso {
  background-color: var(--success-color);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mensaje de error del formulario */
.form-error-message {
  background-color: var(--error-color);
  color: white;
  padding: 12px;
  border-radius: var(--border-radius);
  margin-bottom: 20px;
  text-align: center;
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* Instrucciones del formulario */
.form-instrucciones {
  background-color: #f8f9fa;
  border-left: 4px solid var(--primary-color);
  padding: 15px;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  margin: 20px 0;
}

.form-instrucciones p {
  margin-bottom: 10px;
}

.form-instrucciones p:last-child {
  margin-bottom: 0;
}

/* Separador */
hr {
  border: 0;
  height: 1px;
  background-image: linear-gradient(to right, rgba(37, 6, 77, 0), rgba(37, 6, 77, 0.5), rgba(37, 6, 77, 0));
  margin: 20px 0;
}

/* Tablas de selección mejoradas */
.seleccioned-table {
  width: 100%;
  overflow-x: auto;
  background-color: #ffffff;
  padding: 25px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin: 20px 0;
  border: 1px solid #f0f0f0;
}

.seleccioned-table table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

.seleccioned-table th {
  background-color: var(--primary-color);
  color: white;
  padding: 15px;
  text-align: left;
  border-bottom: 2px solid #fff;
}

.seleccioned-table td {
  padding: 12px 15px;
  border-bottom: 1px solid #eee;
}

.seleccioned-table tr:last-child td {
  border-bottom: none;
}

.seleccioned-table tr:hover td {
  background-color: #f9f9f9;
}

.seleccioned-table tr:nth-child(even) {
  background-color: #fcfcfc;
}

.ver-archivo {
  color: var(--primary-color);
  text-decoration: none;
  padding: 5px 10px;
  background-color: #f0f0f0;
  border-radius: 4px;
  transition: all 0.3s;
  display: inline-block;
}

.ver-archivo:hover {
  background-color: var(--primary-color);
  color: white;
}

/* Estilo de estado del producto */
.producto-estado {
  background-color: var(--success-color);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.9em;
  display: inline-block;
}

/* Formulario mejorado */
#seleccion-productos-form {
  max-width: 800px;
  margin: 0 auto;
  padding: 25px;
  background-color: #f9f9f9;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

.seleccion-container {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.seleccion-encabezado {
  font-size: 22px;
  color: var(--primary-color);
  margin-bottom: 10px;
  text-align: center;
}

.seleccion-descripcion {
  text-align: center;
  color: #666;
  margin-bottom: 15px;
  font-style: italic;
}

/* Mejoras en campos de formulario */
.producto-form-group {
  background-color: #fff;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid #f0f0f0;
  transition: box-shadow 0.3s ease;
  animation: fadeInUp 0.5s ease-out;
}

.producto-form-group:hover {
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.seleccion-titulo {
  background-color: #f5f5f5;
  padding: 12px 15px;
  margin: 0;
  border-bottom: 2px solid var(--primary-color);
  color: var(--primary-color);
  font-size: 18px;
}

.producto-item {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.producto-item:hover {
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.producto-nota {
  padding: 20px;
  background-color: #f9f9f9;
  color: #666;
  font-style: italic;
  border-top: 1px solid #eee;
}

/* Campos requeridos */
.campo-requerido:after {
  content: '*';
  color: var(--error-color);
  margin-left: 4px;
  font-weight: bold;
}

.label-formsel {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #555;
}

/* Mejoras visuales input */
.producto-item input[type="url"],
.producto-item input[type="text"] {
  border: 2px solid #ddd;
  border-radius: 5px;
  padding: 12px 15px;
  font-size: 14px;
  width: 100%;
  transition: all 0.3s;
  box-sizing: border-box;
  margin-bottom: 15px;
  background-color: #fff;
}

.producto-item input[type="url"]:focus,
.producto-item input[type="text"]:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 6, 77, 0.1);
  outline: none;
}

.producto-item input[type="url"]::placeholder,
.producto-item input[type="text"]::placeholder {
  color: #999;
  opacity: 1;
}

.input-error {
  border-color: var(--error-color) !important;
  background-color: rgba(255, 82, 82, 0.05) !important;
}

/* Botón de enviar mejorado */
.boton-enviar {
  background: linear-gradient(to right, #25064D, #33125E);
  color: white;
  border: none;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
  display: block;
  margin: 25px auto 10px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.boton-enviar:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.boton-enviar:active {
  transform: translateY(0);
}

.boton-enviar:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.2);
  transition: width 0.3s ease;
}

.boton-enviar:hover:before {
  width: 100%;
}

.boton-enviar.procesando {
  background: #33125E;
  pointer-events: none;
  padding-right: 45px;
}

.boton-enviar.procesando:after {
  content: '';
  position: absolute;
  top: 50%;
  right: 15px;
  margin-top: -10px;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Onda de efecto al hacer clic */
.boton-enviar:after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.5s, opacity 0.8s;
}

.boton-enviar:active:after {
  transform: scale(0, 0);
  opacity: 0.3;
  transition: 0s;
}

.ver-producto-link {
    margin-left: auto;
    font-size: 13px;
    color: var(--primary-color);
    text-decoration: none;
    padding: 3px 8px;
    border-radius: 4px;
    background-color: rgba(37, 6, 77, 0.05);
    transition: all 0.3s;
    margin-left: 10px;
}

.ver-producto-link:hover {
    background-color: var(--primary-color);
    color: white;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsividad para tablas */
@media (max-width: 768px) {
  .seleccioned-table {
    padding: 15px;
  }
  
  .seleccioned-table table {
    min-width: 600px; /* Para asegurar scroll horizontal en móviles */
  }
  
  .seleccioned-table th,
  .seleccioned-table td {
    padding: 10px;
  }
  
  .producto-item {
    padding: 15px;
  }
  
  .producto-item input[type="url"],
  .producto-item input[type="text"] {
    padding: 10px;
    font-size: 14px;
  }
  
  .boton-enviar {
    width: 100%;
  }
}