/**
 * Fast Product Viewer Styles
 * Styles for the fast-product-viewer web component
 *
 * @package FastTheme
 */

/* ========================================
   Overlay & Backdrop
   ======================================== */

.product-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.product-viewer-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.product-viewer-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

/* ========================================
   Container Base
   ======================================== */

.product-viewer-container {
  position: relative;
  background: white;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.95) translateY(20px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.product-viewer-overlay.is-open .product-viewer-container {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ========================================
   Modal Mode (Desktop)
   Centered dialog respecting store layout width
   ======================================== */

.product-viewer-container.mode-modal {
  /* Center via overlay flexbox (no fixed positioning) */
  width: min(80rem, 96vw); /* ~1280px or viewport-bound */
  max-height: 90vh;
  border-radius: 16px;
}

/* Transition uses base .product-viewer-container rules (scale/translate) */

/* ========================================
   Bottom Sheet Mode (Mobile)
   ======================================== */

.product-viewer-container.mode-bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 90vh;
  max-height: 90vh;
  border-radius: 20px 20px 0 0;
  transform: translateY(100%);
}

.product-viewer-overlay.is-open .product-viewer-container.mode-bottom-sheet {
  transform: translateY(0);
}

/* Desktop: bottom sheet ocupa todo el ancho */
@media (min-width: 1024px) {
  .product-viewer-container.mode-bottom-sheet {
    width: 100%;
    left: 0;
    transform: translateY(100%);
  }
  .product-viewer-overlay.is-open .product-viewer-container.mode-bottom-sheet {
    transform: translateY(0);
  }
}

/* ========================================
   Header
   ======================================== */

.product-viewer-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.product-viewer-container.mode-bottom-sheet .product-viewer-header {
  padding-top: 1rem;
}

/* Bottom sheet handle bar */
.product-viewer-container.mode-bottom-sheet .product-viewer-header::before {
  content: '';
  position: absolute;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
}

/* Desktop: header con mismo ancho del contenido */
@media (min-width: 1024px) {
  .product-viewer-container.mode-bottom-sheet .product-viewer-header {
    max-width: min(80rem, 96vw);
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.product-viewer-close {
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: #6b7280;
  transition: color 0.2s ease, background-color 0.2s ease;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-viewer-close:hover {
  color: #111827;
  background-color: #f3f4f6;
}

.product-viewer-close:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* ========================================
   Content
   ======================================== */

.product-viewer-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  -webkit-overflow-scrolling: touch;
}

/* Adjustments for both modal and bottom sheet modes */
.product-viewer-container.mode-modal .product-viewer-content,
.product-viewer-container.mode-bottom-sheet .product-viewer-content {
  padding: 1rem;
}

/* Desktop: contenido con ancho máximo del layout centrado */
@media (min-width: 1024px) {
  .product-viewer-container.mode-bottom-sheet .product-viewer-content {
    max-width: min(80rem, 96vw); /* ~1280px o viewport-bound */
    margin-left: auto;
    margin-right: auto;
    padding: 1rem 2rem;
  }
}

/* Custom scrollbar */
.product-viewer-content::-webkit-scrollbar {
  width: 8px;
}

.product-viewer-content::-webkit-scrollbar-track {
  background: #f3f4f6;
}

.product-viewer-content::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.product-viewer-content::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ========================================
   Loading State - Skeleton
   ======================================== */

.product-viewer-loading {
  display: block;
  padding: 1rem;
  overflow-y: auto;
}

/* Force hide when hidden attribute is present */
.product-viewer-loading[hidden] {
  display: none !important;
}

.skeleton-loader {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 100%;
}

/* Skeleton image */
.skeleton-image {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 8px;
}

/* Skeleton content container */
.skeleton-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0 0.5rem;
}

/* Skeleton lines */
.skeleton-line {
  height: 16px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-title {
  height: 24px;
  width: 80%;
  margin-bottom: 0.5rem;
}

.skeleton-price {
  height: 20px;
  width: 40%;
  margin-bottom: 0.5rem;
}

.skeleton-text {
  width: 100%;
}

.skeleton-text.short {
  width: 60%;
}

.skeleton-stock {
  height: 20px;
  width: 50%;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

/* Skeleton actions row */
.skeleton-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.skeleton-quantity {
  width: 120px;
  height: 48px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 8px;
  flex-shrink: 0;
}

/* Skeleton button */
.skeleton-button {
  height: 48px;
  flex: 1;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ========================================
   Accessibility
   ======================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ========================================
   Product Content Styles
   ======================================== */

/* Hide layout elements that shouldn't appear in quick view */
.product-viewer-content .breadcrumb-wrapper,
.product-viewer-content .breadcrumbs,
.product-viewer-content .woocommerce-breadcrumb,
.product-viewer-content nav[aria-label="breadcrumb"],
.product-viewer-content .site-header,
.product-viewer-content .site-footer,
.product-viewer-content .mobile-bottom-nav,
.product-viewer-content .pswp,
.product-viewer-content .photoswipe,
.product-viewer-content .woocommerce-product-gallery__overlay,
.product-viewer-content [class*="lightbox"],
.product-viewer-content [class*="modal-"],
.product-viewer-content [class*="overlay-"],
.product-viewer-content .age-verification-overlay,
.product-viewer-content [data-overlay],
.product-viewer-content [role="dialog"]:not(.product-viewer-container) {
  display: none !important;
}

/* Gallery Styles */
.product-viewer-content .woocommerce-product-gallery {
  margin-bottom: 1.5rem;
}

.product-viewer-content .woocommerce-product-gallery__wrapper {
  display: grid;
  gap: 1rem;
}

.product-viewer-content .woocommerce-product-gallery__image {
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.product-viewer-content .woocommerce-product-gallery__image:hover {
  opacity: 0.8;
}

.product-viewer-content .woocommerce-product-gallery__image.active {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Product Info */
.product-viewer-content .product_title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.product-viewer-content .price {
  font-size: 1.25rem;
  font-weight: 600;
  color: #059669;
  margin-bottom: 1rem;
}

.product-viewer-content .woocommerce-product-details__short-description {
  color: #6b7280;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* Add to Cart Form */
.product-viewer-content form.cart {
  margin-bottom: 1.5rem;
}

.product-viewer-content .quantity {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 0.75rem;
}

.product-viewer-content .single_add_to_cart_button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.product-viewer-content .single_add_to_cart_button:hover {
  background: #2563eb;
}

.product-viewer-content .single_add_to_cart_button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* Variations */
.product-viewer-content .variations {
  margin-bottom: 1rem;
}

.product-viewer-content .variations tr {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

.product-viewer-content .variations label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.product-viewer-content .variations select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
}

/* ========================================
   Responsive Breakpoints
   ======================================== */

@media (max-width: 767px) {
  /* Force bottom sheet mode on mobile */
  .product-viewer-container.mode-auto {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 90vh;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }

  .product-viewer-overlay.is-open .product-viewer-container.mode-auto {
    transform: translateY(0);
  }

  .product-viewer-content {
    padding: 0.5rem;
  }

  .product-viewer-content .product_title {
    font-size: 1.25rem;
  }
}

@media (min-width: 768px) {
  /* Force modal mode on desktop */
  .product-viewer-container.mode-auto {
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    border-radius: 12px;
  }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
  .product-viewer-overlay {
    display: none !important;
  }
}
