/* css/tienda.css */

/* Reutiliza variables de root definidas en index.html */

.tienda-section {
  padding: 40px 18px 80px;
  background: #fafbfc;
}

.tienda-inner {
  max-width: var(--container);
  margin: 0 auto;
}

.tienda-header {
  margin-bottom: 40px;
  text-align: center;
}

.tienda-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 900;
  color: var(--brown);
  margin-bottom: 10px;
}

.tienda-subtitle {
  color: var(--muted);
  font-size: 16px;
}

/* Grid de Productos */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 32px;
}

.product-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadowSoft);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.product-image-container {
  background: #f4f4f5;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

.product-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

.product-info {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.product-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.product-price {
  font-size: 16px;
  color: var(--muted);
  font-weight: 600;
}

.product-cta {
  margin-top: auto;
  padding-top: 16px;
}

.btn-primary {
  display: block;
  width: 100%;
  background: var(--brown);
  color: #fff;
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
  font-size: 14px;
}

.btn-primary:hover {
  background: #422a1f;
  /* un poco más claro u oscuro */
}

/* Modal Detalle */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: #fff;
  width: 100%;
  max-width: 900px;
  border-radius: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  box-shadow: var(--shadow);
  max-height: 90vh;
  position: relative;
}

.modal-image-col {
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.modal-image {
  max-width: 100%;
  max-height: 500px;
  object-fit: contain;
}

.modal-details-col {
  padding: 40px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.close-modal {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  z-index: 10;
}

/* Controles de Selección */
.detail-title {
  font-size: 32px;
  font-weight: 900;
  color: var(--brown);
  margin: 0;
}

.detail-price {
  font-size: 24px;
  color: var(--text);
  font-weight: 700;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-label {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}

/* Gender Toggle */
.gender-toggle {
  display: flex;
  background: #f0f0f0;
  padding: 4px;
  border-radius: 8px;
  width: fit-content;
}

.gender-opt {
  padding: 10px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
  color: var(--muted);
}

.gender-opt.active {
  background: #fff;
  color: var(--brown);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Colors */
.colors-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  /* para selección */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, border-color 0.2s;
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.active {
  border-color: var(--brown);
  transform: scale(1.1);
}

/* Sizes */
.sizes-grid {
  display: flex;
  gap: 12px;
}

.size-opt {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.size-opt:hover {
  border-color: var(--brown);
}

.size-opt.active {
  background: var(--brown);
  color: #fff;
  border-color: var(--brown);
}

/* Cart Drawer */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2000;
  display: none;
  justify-content: flex-end;
}

.cart-overlay.active {
  display: flex;
  overflow-y: auto;
  align-items: flex-start;
}

.cart-drawer {
  background: #fff;
  width: 100%;
  max-width: 450px;
  min-height: 100vh;
  height: auto;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
  overflow: visible;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

.cart-header {
  padding: 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-title {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
}

.close-cart {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

.cart-items {
  flex: 0 0 auto;
  max-height: 20vh;
  min-height: 80px;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cart-item {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 16px;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 16px;
}

.cart-item-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f8f9fa;
  border-radius: 8px;
}

.cart-item-details h4 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
}

.cart-item-meta {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  border-radius: 4px;
}

.cart-item-remove {
  background: none;
  border: none;
  color: #e53e3e;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  margin-top: 8px;
  display: block;
}

.cart-footer {
  padding: 16px 24px;
  background: #fafbfc;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 800;
}

#paypal-button-container {
  width: 100%;
  margin-top: 8px;
  min-height: 500px;
  padding-bottom: 60px;
}

/* Responsive - Móvil */
@media (max-width: 768px) {

  /* ========================================
     MODAL DE PRODUCTO - MÓVIL
     ======================================== */
  .modal-overlay.active {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .modal-content {
    display: block !important;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* Imagen STICKY - se queda fija mientras las opciones pasan por debajo */
  .modal-image-col {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 35vh;
    min-height: 180px;
    max-height: 35vh;
    padding: 10px 15px;
    padding-top: 50px;
    background: #f8f9fa;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }

  /* Pseudo-elemento para tapar el contenido que sube */
  .modal-image-col::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(to bottom, #f8f9fa 50%, rgba(248, 249, 250, 0.95) 100%);
    z-index: 101;
    pointer-events: none;
  }

  .modal-image {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    object-position: top center;
    position: relative;
    z-index: 102;
  }

  /* Detalles - pasan por debajo de la imagen al hacer scroll */
  .modal-details-col {
    position: relative;
    z-index: 1;
    padding: 20px;
    padding-bottom: 60px;
    background: #fff;
    min-height: 65vh;
  }

  .detail-title {
    font-size: 24px;
    margin: 0;
  }

  .detail-price {
    font-size: 20px;
  }

  .control-group {
    gap: 8px;
  }

  .control-label {
    font-size: 12px;
  }

  .gender-toggle {
    width: 100%;
  }

  .gender-opt {
    padding: 10px 20px;
    font-size: 14px;
    flex: 1;
    text-align: center;
  }

  .colors-grid {
    gap: 10px;
  }

  .color-swatch {
    width: 32px;
    height: 32px;
  }

  .sizes-grid {
    gap: 8px;
  }

  .size-opt {
    width: 44px;
    height: 44px;
    font-size: 13px;
  }

  .close-modal {
    position: fixed;
    top: 12px;
    right: 12px;
    font-size: 24px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
  }

  .btn-primary {
    padding: 14px;
    font-size: 15px;
  }

  /* ========================================
     CARRITO - MÓVIL (Solución scroll PayPal)
     ======================================== */
  .cart-overlay {
    justify-content: stretch;
  }

  .cart-overlay.active {
    display: block;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
  }

  .cart-drawer {
    width: 100%;
    max-width: 100%;
    min-height: auto;
    height: auto;
    overflow: visible;
  }

  .cart-header {
    padding: 16px;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    border-bottom: 1px solid var(--line);
  }

  .cart-items {
    max-height: none;
    flex: none;
    padding: 16px;
  }

  .cart-footer {
    padding: 16px;
    padding-bottom: 40px;
  }

  .cart-total {
    font-size: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
  }

  #paypal-button-container {
    min-height: 700px;
    padding-bottom: 150px;
  }
}