/* ════════════════════════════════════════════════════════════════
   PRODUCT DETAIL PAGE — css/product-detail.css
   ════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --color-primary: var(--brick, #B5341A);
  --color-primary-dark: var(--brick-dark, #7A1E08);
  --color-text: var(--concrete, #2C2C2C);
  --color-text-muted: var(--mid, #6B6B6B);
  --color-bg: var(--cream, #FAF6EE);
  --color-bg-light: var(--sand-light, #F5EDD8);
  --color-border: #e0e0e0;
  --color-border-light: #f0f0f0;
}

/* ── Page layout ──────────────────────────────────────────── */
.detail-page {
  background: var(--color-bg);
  min-height: 100vh;
}

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.breadcrumb a {
  color: var(--color-primary);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb .sep {
  color: var(--color-text-muted);
}

/* ── Detail hero: 2-col ───────────────────────────────────── */
.detail-hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
}

@media (max-width: 768px) {
  .detail-hero {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

/* ── Gallery ──────────────────────────────────────────────── */
.detail-gallery {
  position: sticky;
  top: 100px;
  align-self: start;
}

.gallery-main {
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 4/3;
  background: #f5f5f5;
  position: relative;
}

.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  background: var(--color-bg-light);
}

.gallery-thumbs {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.thumb.active,
.thumb:hover {
  border-color: var(--color-primary);
}

/* ── Product info ─────────────────────────────────────────── */
.detail-info {
  padding-top: 0.5rem;
}

.detail-category {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary);
  opacity: 0.9;
}

.detail-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  margin: 0.4rem 0 1rem;
  line-height: 1.3;
  color: var(--color-text);
}

.detail-price-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.detail-price {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
}

.detail-unit {
  font-size: 1rem;
  color: var(--color-text-muted);
}

.detail-stock {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 4px;
  margin-left: 8px;
}

.badge-stock.in {
  background: #dcfce7;
  color: #166534;
}

.badge-stock.out {
  background: #fee2e2;
  color: #991b1b;
}

.badge-stock.low {
  background: #fef3c7;
  color: #92400e;
}

.badge-stock.pending {
  background: #dbeafe;
  color: #1e40af;
}

/* ── Actions ──────────────────────────────────────────────── */
.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.qty-wrap label {
  font-size: 0.875rem;
  font-weight: 600;
  display: block;
  margin-bottom: 0.4rem;
  color: var(--color-text);
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 0;
}

.qty-controls button {
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--color-border);
  background: #f5f5f5;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.15s;
}

.qty-controls button:hover {
  background: #e8e8e8;
}

.qty-controls button:first-child {
  border-radius: 6px 0 0 6px;
}

.qty-controls button:last-child {
  border-radius: 0 6px 6px 0;
}

.qty-controls input {
  width: 60px;
  height: 40px;
  text-align: center;
  border: 1.5px solid var(--color-border);
  border-left: 0;
  border-right: 0;
  font-size: 1rem;
  font-family: 'Mulish', sans-serif;
}

.qty-controls input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.btn-primary {
  padding: 0.85rem 1.5rem;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-secondary {
  padding: 0.85rem 1.5rem;
  border-radius: 8px;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
  background: transparent;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
  text-align: center;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ── Quick specs ──────────────────────────────────────────── */
.detail-specs-quick {
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--color-border-light);
}

.spec-row span:first-child {
  color: var(--color-text-muted);
}

.spec-row span:last-child {
  font-weight: 600;
  color: var(--color-text);
}

/* ── Tabs ─────────────────────────────────────────────────── */
.detail-tabs {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--color-primary);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-content {
  line-height: 1.8;
  color: var(--color-text);
  font-size: 1rem;
}

.tab-content p {
  margin-bottom: 1rem;
}

.specs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.specs-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.specs-table tr td:first-child {
  width: 40%;
  color: var(--color-text-muted);
  font-weight: 500;
  background: var(--color-bg-light);
}

.specs-table tr td:last-child {
  font-weight: 600;
}

/* ── Related products ─────────────────────────────────────── */
.related-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.related-section h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--color-text);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.related-card {
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  display: block;
  background: #fff;
  transition: box-shadow 0.15s, transform 0.15s;
}

.related-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.related-image {
  aspect-ratio: 4/3;
  overflow: hidden;
  position: relative;
}

.related-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.related-emoji {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.related-info {
  padding: 0.75rem;
}

.related-name {
  font-family: 'Mulish', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  color: var(--color-text);
  line-height: 1.4;
}

.related-price {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.95rem;
  color: var(--color-primary);
  font-weight: 700;
  margin: 0;
}

/* ── Back link ────────────────────────────────────────────── */
.back-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.back-link {
  color: var(--color-primary);
  text-decoration: none;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  transition: opacity 0.15s;
}

.back-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .detail-gallery {
    position: static;
  }

  .detail-name {
    font-size: 1.5rem;
  }

  .detail-price {
    font-size: 1.5rem;
  }

  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    flex-shrink: 0;
    padding: 0.6rem 1rem;
  }

  .related-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .specs-table tr td:first-child {
    width: 45%;
  }
}

@media (max-width: 480px) {
  .detail-actions {
    gap: 0.5rem;
  }

  .btn-primary,
  .btn-secondary {
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }
}
