﻿/**
 * Product Detail Page Styles
 * Uses Pilot theme's grid system for responsive layout
 */

/* ==========================================================================
   Product Gallery
   ========================================================================== */

.product-gallery {
  position: relative;
}

/* Sticky gallery on desktop only */
@media (min-width: 768px) {
  .product-gallery {
    position: sticky;
    /*top: calc(var(--header-height, 80px) + 20px);*/
    height: fit-content;
  }
}

.gallery-main {
  margin-bottom: var(--spacing-md, 1rem);
  position: relative;
}

.gallery-main-image {
  position: relative;
  padding-top: 100%; /* 1:1 aspect ratio */
  background-color: var(--color-light-gray, #f5f5f5);
  overflow: hidden;
  /*border: 1px solid var(--color-border, #ddd);*/
}

.gallery-main-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-main-image .product-badge {
  position: absolute;
  top: var(--spacing-md, 1rem);
  left: var(--spacing-md, 1rem);
  z-index: 2;
  padding: 0.25rem 0.75rem;
  background-color: #000;
  color: #fff;
  border: 1px solid #fff;
  font-size: 0.875rem;
  border-radius: 4px;
}

.gallery-zoom-btn {
  position: absolute;
  bottom: var(--spacing-md, 1rem);
  right: var(--spacing-md, 1rem);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-white, #fff);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 2;
}

.gallery-main-image:hover .gallery-zoom-btn {
  opacity: 1;
}

/* Gallery Thumbnails */
.gallery-thumbnails {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-sm, 0.5rem);
}

.gallery-thumbnails .thumbnail-item {
  position: relative;
}

.gallery-thumbnails .thumbnail {
  position: relative;
  display: block;
  width: 100%;
  padding-top: 100%;
  /*border: 2px solid var(--color-border, #ddd);*/
  background-color: var(--color-light-gray, #f5f5f5);
  cursor: pointer;
  transition: border-color 0.2s ease;
  overflow: hidden;
}

.gallery-thumbnails .thumbnail img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-thumbnails .thumbnail:hover,
.gallery-thumbnails .thumbnail.active {
  border-color: var(--color-primary, #007bff);
}

/* ==========================================================================
   Product Info
   ========================================================================== */

.product-detail-info {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg, 1.5rem);
}

.product-header .product-category {
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--color-text-muted, #6c757d);
  margin-bottom: var(--spacing-xs, 0.25rem);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.product-header .product-category a {
  color: inherit;
  transition: color 0.2s ease;
  text-decoration: none;
}

.product-header .product-category a:hover {
  color: var(--color-primary, #007bff);
}

.product-header .product-title {
  font-size: 1.6rem;
  font-weight: var(--font-weight-semibold, 600);
  margin-bottom: var(--spacing-md, 1rem);
  line-height: 1.2;
}

/* Price Section */
.product-price-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: var(--spacing-sm, 0.8rem) 0;
  border-top: 1px solid var(--color-border, #ddd);
  border-bottom: 1px solid var(--color-border, #ddd);
}

.product-price-section .price-current {
  font-size: 1.3125rem; /* 21px */
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
}

.product-availability {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs, 0.25rem);
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: var(--font-weight-medium, 500);
}

.product-availability.in-stock {
  color: var(--color-success, #28a745);
}

.product-availability.out-of-stock {
  color: var(--color-danger, #dc3545);
}

.product-description {
  color: var(--color-text, #333);
  line-height: 1.6;
}

/* ==========================================================================
   Product Options
   ========================================================================== */

.product-options {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg, 1.5rem);
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm, 0.5rem);
}

.option-label {
  font-size: var(--font-size-base, 1rem);
  font-weight: var(--font-weight-semibold, 600);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Color Swatches */
.color-swatches {
  display: flex;
  gap: var(--spacing-sm, 0.5rem);
  flex-wrap: wrap;
}

.color-swatches .color-swatch {
  width: 48px;
  height: 48px;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.color-swatches .color-swatch i {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--color-white);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.color-swatches .color-swatch.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-white), 0 0 0 4px var(--color-primary);
}

.color-swatches .color-swatch.active i {
  opacity: 1;
}

/* Size Buttons */
.size-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm, 0.5rem);
}

.size-btn {
  min-width: 60px;
  padding: 12px 16px;
  background-color: var(--color-white, #fff);
  border: 2px solid var(--color-border);
  font-size: var(--font-size-base, 1rem);
  font-weight: var(--font-weight-medium, 500);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.size-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
}

.size-btn.active {
  background-color: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
}

.size-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  text-decoration: line-through;
}

/* Quantity Selector */
.quantity-selector {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--color-border, #ddd);
  width: fit-content;
}

.qty-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-white, #fff);
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.qty-btn:hover {
  background-color: var(--color-light-gray, #f5f5f5);
}

.qty-input {
  width: 60px;
  height: 40px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--color-border, #ddd);
  border-right: 1px solid var(--color-border, #ddd);
  font-size: var(--font-size-base, 1rem);
  font-weight: var(--font-weight-medium, 500);
}

.qty-input::-webkit-inner-spin-button,
.qty-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ==========================================================================
   Product Actions
   ========================================================================== */

.product-actions {
  display: flex;
  gap: var(--spacing-md, 1rem);
  flex-wrap: wrap;
}

.product-actions .product-add-to-cart {
  flex: 1;
  min-width: 200px;
}

.product-actions .wishlist-btn {
  width: 56px;
  padding: 0;
}

/* ==========================================================================
   Product Features
   ========================================================================== */

.product-features {
  padding: var(--spacing-lg, 1.5rem);
  background-color: var(--color-light-gray, #f5f5f5);
  border-radius: var(--border-radius-md, 8px);
}

.product-features .feature-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm, 0.5rem);
  font-size: var(--font-size-sm, 0.875rem);
}

.product-features .feature-item i {
  font-size: 1.25rem;
  color: var(--color-success, #28a745);
}

/* ==========================================================================
   Product Accordion
   ========================================================================== */

.product-accordion {
  border-top: 1px solid var(--color-border, #ddd);
}

.accordion-item {
  border-bottom: 1px solid var(--color-border, #ddd);
}

.accordion-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md, 1rem) 0;
  background: none;
  border: none;
  font-size: var(--font-size-base, 1rem);
  font-weight: var(--font-weight-semibold, 600);
  cursor: pointer;
  text-align: left;
  transition: color 0.2s ease;
}

.accordion-header:hover {
  color: var(--color-primary, #007bff);
}

.accordion-header i {
  transition: transform 0.3s ease;
}

.accordion-header.active i {
  transform: rotate(180deg);
}

.accordion-content {
  display: none;
  padding-bottom: var(--spacing-md, 1rem);
  color: var(--color-text, #333);
  line-height: 1.6;
}

.accordion-content ul {
  list-style: disc;
  padding-left: var(--spacing-lg, 1.5rem);
}

.accordion-content li {
  margin-bottom: var(--spacing-xs, 0.25rem);
}

/* ==========================================================================
   Product Tabs
   ========================================================================== */

.product-tabs {
  background-color: var(--color-white, #fff);
  border: 1px solid var(--color-border, #ddd);
  border-radius: var(--border-radius-md, 8px);
}

.tabs-header {
  display: flex;
  border-bottom: 1px solid var(--color-border, #ddd);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  flex: 1;
  min-width: max-content;
  padding: var(--spacing-md, 1rem) var(--spacing-lg, 1.5rem);
  background: none;
  border: none;
  font-size: var(--font-size-base, 1rem);
  font-weight: var(--font-weight-medium, 500);
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--color-primary, #007bff);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.tab-btn.active,
.tab-btn:hover {
  color: var(--color-primary, #007bff);
}

.tab-btn.active::after {
  transform: scaleX(1);
}

.tabs-content {
  padding: var(--spacing-xl, 2rem);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.tab-pane h3 {
  margin-bottom: var(--spacing-md, 1rem);
}

.tab-pane ul {
  list-style: disc;
  padding-left: var(--spacing-lg, 1.5rem);
}

.tab-pane li {
  margin-bottom: var(--spacing-sm, 0.5rem);
}

/* Specifications Table */
.specs-table {
  width: 100%;
  border-collapse: collapse;
}

.specs-table tr {
  border-bottom: 1px solid var(--color-border, #ddd);
}

.specs-table td {
  padding: var(--spacing-md, 1rem);
  word-break: break-word;
}

.specs-table td:first-child {
  width: 30%;
  font-weight: var(--font-weight-medium, 500);
}

/* ==========================================================================
   Product Info Table
   ========================================================================== */

.product-info-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.product-info-table table {
  width: 100%;
  min-width: 100%;
}

.product-info-table td code {
  word-break: break-all;
  white-space: normal;
}

/* ==========================================================================
   Price Display Components
   ========================================================================== */

.price-display {
  max-width: 100%;
  overflow-x: hidden;
}

.price-display .badges-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.price-breakdown {
  max-width: 100%;
}

.price-breakdown table {
  width: 100%;
  max-width: 100%;
}

/* Package Unit Display */
.package-unit-info ul {
  list-style: none;
  padding-left: 0;
}

.package-unit-info li {
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.product-detail-section {
  max-width: 100%;
  overflow-x: clip;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.product-detail-section img {
  max-width: 100%;
  height: auto;
}

/* ==========================================================================
   Phase 2 — Typed Related Products Sections
   ========================================================================== */

/* Accessories & Spare Parts sections share consistent layout */
.product-accessories-section,
.product-spare-parts-section {
    border-top: 1px solid var(--color-border, #e5e5e5);
}

.product-accessories-section .section-title,
.product-spare-parts-section .section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

/* Up-sell banner — placed above Add-to-Cart */
.product-upsell-banner {
    border-left: 3px solid var(--color-primary, #c1121f);
}

.product-upsell-banner .upsell-thumb {
    border: 1px solid var(--color-border, #e5e5e5);
}

.product-upsell-banner a {
    color: var(--color-text, #212529);
}

.product-upsell-banner a:hover {
    color: var(--color-primary, #c1121f);
}

/* Cart cross-sell suggestions — "Frequently bought together" on cart page */
.cart-cross-sell-section {
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border, #e5e5e5);
}

.cart-cross-sell-section h4 {
    font-size: 1.15rem;
    font-weight: 700;
}

/* ==========================================================================
   Container-fluid mobile padding — reduce from Bootstrap's default (1.5rem)
   to sm-equivalent (0.75rem) on xs screens (< 576px)
   ========================================================================== */
@media (max-width: 575.98px) {
    .product-detail-section .container-fluid,
    .site-main > .container-fluid {
        --bs-gutter-x: 0.75rem;
        padding-right: calc(var(--bs-gutter-x) * 1.2);
        padding-left: calc(var(--bs-gutter-x) * 1.2);
    }
}
