/* ==========================================================================
   1. VARIABLES GLOBALES Y RESETEO
   ========================================================================== */
:root {
  /* Variables de color compartidas por toda la página. */
  --color-blue-dark-blue: #0D1E4A;
  --color-light-blue: #213264;
  --color-gray: #5D5D5D;
  --color-light-gray: #e5e5e5;
  --color-gold: #946A2D;
  --color-black: #000000;
}

* {
  /* Restablece márgenes y dimensiones para un diseño consistente. */
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  /* Configuración general y distribución vertical de la página. */
  font-family: 'Cinzel Decorative', sans-serif;
  background-color: #0D1E4A;
  color: var(--color-gold);
  padding: 0px 0px;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ==========================================================================
   2. ENCABEZADO Y RESUMEN DE PAGO
   ========================================================================== */
header.container {
  /* Encabezado a ancho completo con el color principal de la interfaz. */
  max-width: 100% !important;
  padding: 20px 40px;
  background-color: var(--color-light-blue);
  color: white;
  font-size: 20px;
}

header.container a {
  text-decoration: none;
  color: white;
}

.description img {
  height: 60px;
}

a.main {
  width: fit-content !important;
}

#payment-container {
  /* Mantiene visible el resumen de pago durante el desplazamiento. */
  max-width: 30rem;
  min-width: 280px;
  border: var(--color-gray) solid 1px;
  height: fit-content;

  position: sticky;
  top: 0;
}

#payment-container .text {
  font-weight: bold;
}

#payment, #user-form {
  /* Organiza los elementos de los formularios en una columna. */
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#user-form{
  /* Separa visualmente los datos del usuario del resumen del pedido. */
  border-top: var(--color-gold) solid 1px;
  margin-top: 20px;
  padding-top: 20px;
}

.order-summary {
  /* Estructura vertical del resumen y sus importes. */
  height: fit-content;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 15px;
}

.order-summary>div {
  /* Coloca cada concepto y su valor en extremos opuestos. */
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.order-summary p {
  margin: 0;
}

div.total {
  /* Resalta el importe final con líneas y espacio adicional. */
  padding: 15px 0;
  border-top: 1px solid var(--color-gray);
  border-bottom: 1px solid var(--color-gray);
}

/* ==========================================================================
   3. CATÁLOGO Y LISTA DEL CARRITO
   ========================================================================== */
.cart-container {
  font-family: 'Cinzel Decorative', sans-serif;
  /* Divide el contenido principal entre catálogo y carrito. */
  margin-top: 30px !important;

  max-width: 1500px;
  margin: 0 auto;

  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 100%;

  flex: 1;

  overflow-y: auto;
}

#shop_layout-container {
  margin-top: 24px;
}

.cart-title,
.section-subtitle {
  font-family: 'Cinzel Decorative', sans-serif;
  font-weight: 400;
}

.section-subtitle {
  font-family: 'Cinzel Decorative', sans-serif;
  font-size: 1.8rem;
  margin-bottom: 16px;
}

.cart-title {
  font-size: 2.8rem;
  margin-bottom: 24px;
}

/* Catálogo */
.catalog-section {
  margin-bottom: 50px;
  padding-bottom: 30px;
  border-bottom: 2px dashed var(--color-light-gray);
}

.catalog-grid {
  /* Genera una cuadrícula adaptable para las tarjetas de productos. */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.catalog-card {
  /* Estilo y distribución interna de una tarjeta de producto. */
  border: 1px solid var(--color-light-gray);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.catalog-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 12px;
}

.catalog-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.catalog-card-price {
  font-size: 0.95rem;
  color: var(--color-gray);
  margin-bottom: 12px;
}

.add-to-cart-btn {
  /* Acción principal para añadir productos al carrito. */
  background-color: var(--color-light-blue);
  color: #946A2D;
  border: none;
  padding: 10px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.add-to-cart-btn:hover {
  background-color: #333333;
}

/* Items del Carrito */
.cart-items-list {
  /* Delimita visualmente la lista de productos seleccionados. */
  border-top: 1px solid var(--color-light-gray);
}

.cart-item {
  /* Distribuye la imagen, los detalles y el precio del artículo. */
  display: flex;
  gap: 24px;
  padding: 24px 0;
  border-bottom: 1px solid var(--color-light-gray);
}

.item-image img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
}

.item-details {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.item-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.item-unit-price {
  font-size: 0.9rem;
  color: var(--color-gray);
  margin-bottom: 18px;
}

/* Control de cantidad */
.quantity-wrapper {
  /* Agrupa la etiqueta y el control de cantidad. */
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.quantity-label {
  font-weight: 700;
  font-size: 0.95rem;
}

.quantity-control {
  /* Contenedor visual de los botones y la cantidad actual. */
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-black);
  border-radius: 6px;
  padding: 2px 6px;
}

.qty-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 8px;
  color: var(--color-golf);
  line-height: 1;
}

.qty-btn:hover {
  opacity: 0.6;
}

.qty-number {
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0 8px;
}

/* Acciones (Eliminar / Favoritos) */
.item-actions {
  /* Mantiene juntas las acciones disponibles para cada artículo. */
  display: flex;
  gap: 12px;
}

.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-golf);
  transition: opacity 0.2s;
}

.action-btn:hover {
  opacity: 0.6;
}

.action-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.item-total-price {
  /* Destaca el precio total de cada producto. */
  font-size: 1.15rem;
  font-weight: 700;
  text-align: right;
  min-width: 100px;
}

.empty-cart-msg {
  padding: 40px 0;
  font-size: 1.1rem;
  color: var(--color-gray);
}

/* ==========================================================================
   4. MEDIA QUERIES CONSOLIDADAS
   ========================================================================== */
@media (max-width: 576px) {
  /* Ajustes para pantallas pequeñas y diseño sin desbordamientos. */
  header.container {
    font-size: 20px;
    gap: 0 !important;
  }

  header.container img,
  .description img {
    height: 35px;
  }

  .nav-actions {
    gap: 0 !important;
  }

  .order-summary>div {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  /* Ajuste responsivo para tarjetas del carrito */
  .cart-item {
    flex-direction: column;
    gap: 16px;
  }

  .item-total-price {
    text-align: left;
  }
}

/* Botones de envío del formulario: ocupan el ancho disponible en fila */
#submit-btns{
  /* Distribuye los botones del formulario en una misma fila. */
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

#submit-btns button{
  width: 50%;
}

/* Oculta elementos sin afectar el flujo general del layout */
.hide{
  /* Oculta elementos sin modificar el resto del diseño. */
  display: none !important;
}

/* Formulario de usuario con animación de apertura/cierre */
#user-form {
  /* Anima la apertura y el cierre del formulario de usuario. */
    overflow: hidden;
    max-height: 500px; /* ajusta según el alto real de tu formulario */
    opacity: 1;
    transform: translateY(0);
    transition: max-height 0.4s ease, opacity 0.7s ease, transform 0.7s ease;
}

#user-form.hide-anim {
    max-height: 0;
    opacity: 0;
    transform: translateY(-20px);
}