/* Products Page Styles */

.product-page {
  padding: 40px 22px 80px;
  max-width: 1100px;
  margin: 0 auto;
}

.product-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 50px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

/* Gallery */
.product-gallery {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.main-image-container {
  position: relative;
  background: #ffffff; /* Keep white for product images which usually have white bg */
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-image-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.enlarge-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  backdrop-filter: blur(4px);
}

.enlarge-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.thumbnails {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.thumbnails::-webkit-scrollbar {
  height: 6px;
}
.thumbnails::-webkit-scrollbar-track {
  background: transparent;
}
.thumbnails::-webkit-scrollbar-thumb {
  background-color: var(--line);
  border-radius: 20px;
}

.thumb-btn {
  background: #fff;
  border: 2px solid transparent;
  border-radius: 8px;
  width: 70px;
  height: 70px;
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: border-color 0.2s;
}

.thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-btn.active {
  border-color: var(--primary-bright);
}

/* Product Details */
.product-details {
  display: flex;
  flex-direction: column;
}

.product-details .kicker {
  text-align: left;
  margin-bottom: 8px;
}

.product-details h1 {
  font-size: 32px;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}

.price-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}

.price-display {
  font-size: 36px;
  font-weight: 800;
  color: var(--primary-bright);
}

.price-note {
  color: var(--muted);
  font-size: 16px;
}

.inventory-status {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(47, 111, 237, 0.1);
  color: var(--primary-bright);
  margin-bottom: 24px;
  align-self: flex-start;
}

.inventory-status.out-of-stock {
  background: rgba(255, 87, 87, 0.1);
  color: #ff5757;
}

.description {
  font-size: 16px;
  color: var(--fg);
  line-height: 1.7;
  margin-bottom: 24px;
}

.features-list {
  list-style: none;
  margin: 0 0 32px 0;
  padding: 0;
}

.features-list li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 15px;
}

.features-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--primary-bright);
  font-weight: bold;
}

.purchase-actions {
  display: flex;
  gap: 16px;
  margin-top: auto;
}

.qty-selector {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.qty-btn {
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 20px;
  width: 44px;
  height: 48px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.qty-btn:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.05);
}

.qty-input {
  width: 50px;
  height: 48px;
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.purchase-actions .btn {
  flex: 1;
  font-size: 16px;
}

.purchase-actions .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.api-notice {
  margin-top: 12px;
  font-size: 13px;
  color: #ffb84d;
}

/* Cart Sidebar */
.cart-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.cart-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.cart-sidebar {
  position: fixed;
  top: 0;
  right: -420px;
  width: 100%;
  max-width: 400px;
  height: 100dvh; /* standard viewport height for mobile compatibility */
  max-height: 100dvh;
  background: var(--bg2);
  border-left: 1px solid var(--line);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}

.cart-sidebar.open {
  right: 0;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--line-soft);
}

.cart-header h2 {
  font-size: 20px;
  margin: 0;
}

.close-cart {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.close-cart:hover {
  color: var(--fg);
}

.cart-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-height: 0;
}

.cart-empty {
  text-align: center;
  color: var(--muted);
  margin-top: 40px;
}

.cart-empty .btn {
  margin-top: 24px;
}

.cart-item {
  display: flex;
  gap: 16px;
  background: var(--card);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
}

.cart-item-image {
  width: 80px;
  height: 80px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}

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

.cart-item-title {
  font-size: 14px;
  line-height: 1.4;
  margin: 0 0 4px 0;
}

.cart-item-price {
  color: var(--primary-bright);
  font-weight: 700;
  margin-bottom: 12px;
}

.cart-item-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.qty-selector.small {
  height: 32px;
}
.qty-selector.small .qty-btn {
  width: 32px;
  height: 32px;
  font-size: 16px;
}
.qty-selector.small .qty-input {
  width: 36px;
  height: 32px;
  font-size: 14px;
}

.remove-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.remove-btn:hover {
  color: #ff5757;
}

.cart-footer {
  padding: 24px;
  border-top: 1px solid var(--line-soft);
  background: rgba(5, 9, 20, 0.9);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 15px;
}

.total-row {
  color: var(--fg);
  font-weight: 700;
  font-size: 18px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.tax-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.4;
}

.checkout-btn {
  width: 100%;
  margin-top: 20px;
}

.checkout-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.checkout-notice {
  font-size: 13px;
  color: #ffb84d;
  text-align: center;
  margin-top: 12px;
}

/* Gallery Modal */
.gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.gallery-modal.open {
  opacity: 1;
  visibility: visible;
}

.close-gallery {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: white;
  font-size: 32px;
  cursor: pointer;
  z-index: 201;
}

.gallery-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-content img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  width: 60px;
  height: 60px;
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
}

.gallery-nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.gallery-nav.prev {
  left: 20px;
}

.gallery-nav.next {
  right: 20px;
}

.gallery-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  letter-spacing: 2px;
}

@media (max-width: 860px) {
  .product-container {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 24px;
  }
}

@media (max-width: 560px) {
  .product-page {
    padding: 24px 16px 60px;
  }
  .product-details h1 {
    font-size: 26px;
  }
  .price-display {
    font-size: 28px;
  }
  .purchase-actions {
    flex-direction: column;
  }
  .qty-selector {
    justify-content: space-between;
  }
  .qty-input {
    flex: 1;
  }
}
