@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Cohesive Maillard Color System */
  --bg-primary: #FCFBF9;
  --bg-secondary: #F6F2EC;
  --bg-accent: #EFE9DE;
  
  --maillard-dark: #2F211A;
  --maillard-espresso: #4E3629;
  --maillard-plum: #7D5167;
  --maillard-mauve: #A57C93;
  --maillard-taupe: #8E7164;
  --maillard-cream: #F4EBE1;
  --maillard-gold: #C28E5C;
  
  --text-primary: #2F211A;
  --text-secondary: #736257;
  --text-muted: #9E8E84;
  
  --border-color: #EADFD3;
  --border-active: #7D5167; /* Plum accent */
  
  --btn-shadow: 0 4px 20px rgba(78, 54, 41, 0.15);
  --glass-shadow: 0 8px 32px 0 rgba(78, 54, 41, 0.08);
  
  --transition-smooth: 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

/* Reset & Scaffold */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #F0E6DC;
  font-family: var(--font-body);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

/* Limit to mobile width and center */
.app-container {
  background-color: var(--bg-primary);
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  box-shadow: 0 0 50px rgba(47, 33, 26, 0.12);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 80px; /* Space for sticky bottom bar (padding 14px * 2 + button 48px + border 1px = 77px, rounded up) */
}

/* Typography elements */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
}

/* Header Navigation Bar */
.header-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(252, 251, 249, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
}

.brand-logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--maillard-dark);
  text-transform: uppercase;
  text-decoration: none;
}

.brand-logo span {
  color: var(--maillard-gold);
}

.nav-actions {
  display: flex;
  gap: 16px;
}

.nav-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--maillard-dark);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: var(--transition-smooth);
  overflow: visible; /* allow badge to render outside button bounds */
}

.nav-icon:hover {
  background-color: var(--bg-secondary);
}

.nav-icon svg {
  width: 22px;
  height: 22px;
}

.cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: var(--maillard-plum);
  color: white;
  font-size: 10px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: none; /* hidden by default; JS sets display:flex when count > 0 */
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1; /* stays above the icon svg but within header stacking context */
}

/* Scroll-Snap Product Gallery */
.gallery-container {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background-color: var(--bg-secondary);
}

.scroller {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  width: 100%;
  height: 100%;
}

.scroller::-webkit-scrollbar {
  display: none;
}

.slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  position: relative;
}

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

/* Gallery pagination indicators */
.gallery-indicators {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  background: rgba(47, 33, 26, 0.4);
  padding: 6px 12px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
  z-index: 10;
}

.indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: rgba(252, 251, 249, 0.5);
  transition: var(--transition-smooth);
}

.indicator-dot.active {
  background-color: var(--bg-primary);
  width: 14px;
  border-radius: 3px;
}

/* Flash Sale Countdown / Promo Bar */
.promo-bar {
  background: linear-gradient(90deg, var(--maillard-espresso), var(--maillard-taupe));
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
}

.promo-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
}

.promo-title svg {
  width: 16px;
  height: 16px;
  fill: var(--maillard-gold);
}

.countdown {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.countdown-box {
  background-color: rgba(255, 255, 255, 0.2);
  padding: 3px 6px;
  border-radius: 4px;
  font-weight: 700;
  font-family: monospace;
}

/* Product Info */
.product-info {
  padding: 20px;
}

.product-price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.price-current {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--maillard-plum);
}

.price-original {
  font-size: 16px;
  text-decoration: line-through;
  color: var(--text-muted);
}

.price-discount {
  background-color: var(--maillard-cream);
  color: var(--maillard-plum);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.product-title {
  font-size: 18px;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.product-tagline {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.stars-wrapper {
  display: flex;
  color: var(--maillard-gold);
}

.stars-wrapper svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* Selection Section */
.selectors-section {
  padding: 0 20px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.selector-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.selector-value {
  text-transform: none;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Color Circle select buttons */
.color-list {
  display: flex;
  gap: 12px;
}

.color-option {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 2px;
  cursor: pointer;
  background: none;
  transition: var(--transition-smooth);
}

.color-dot {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.color-option.active {
  border-color: var(--border-active);
  transform: scale(1.1);
}

/* Size Pill select buttons */
.size-grid {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 0;
}

.size-grid::-webkit-scrollbar {
  display: none;
}

.size-option {
  flex: 0 0 55px;
  height: 38px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.size-option:hover {
  background-color: var(--bg-secondary);
}

.size-option.active {
  background-color: var(--maillard-dark);
  color: white;
  border-color: var(--maillard-dark);
  box-shadow: var(--btn-shadow);
}

.size-helper-link {
  font-size: 12px;
  color: var(--maillard-plum);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
}

/* Premium Specifications/Details Accordion */
.details-section {
  padding: 0 20px;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.accordion-item {
  border-bottom: 1px solid var(--border-color);
}

.accordion-item:last-child {
  border-bottom: none;
}

.accordion-header {
  width: 100%;
  padding: 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  text-align: left;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
}

.accordion-icon {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-smooth);
}

.accordion-item.active .accordion-icon {
  transform: rotate(180deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-smooth);
}

.accordion-item.active .accordion-content {
  max-height: 500px;
}

.accordion-inner-content {
  padding-bottom: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
}

.spec-table td {
  padding: 6px 0;
  border-bottom: 1px solid #FAF7F2;
}

.spec-label {
  font-weight: 500;
  color: var(--text-primary);
  width: 40%;
}

/* Reviews Section */
.reviews-section {
  padding: 20px;
}

.reviews-header-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.review-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.stat-pill {
  background-color: var(--bg-secondary);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
}

.review-card {
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
}

.review-card:last-child {
  border-bottom: none;
}

.review-user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.review-username {
  font-weight: 600;
  font-size: 13px;
}

.review-date {
  font-size: 11px;
  color: var(--text-muted);
}

.review-meta-info {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
}

.review-comment {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.review-helpful {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
}

.review-helpful svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* Sticky Bottom Action Bar */
.sticky-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background-color: rgba(252, 251, 249, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  padding: 14px 20px;
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: stretch; /* both buttons grow to same height */
  gap: 14px;
  z-index: 90;
}

.icon-button {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--maillard-dark);
  transition: var(--transition-smooth);
  height: 48px;
}

.icon-button:hover {
  background-color: var(--bg-accent);
}

.icon-button svg {
  width: 22px;
  height: 22px;
}

.primary-add-button {
  background-color: var(--maillard-plum);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--btn-shadow);
  transition: var(--transition-smooth);
  height: 48px;
}

.primary-add-button:hover {
  background-color: var(--maillard-dark);
  transform: translateY(-2px);
}

.primary-add-button svg {
  width: 20px;
  height: 20px;
}

/* Modern Bottom Sheet Dialog (using dialog HTML element) */
dialog.bottom-sheet {
  border: none;
  background-color: var(--bg-primary);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 480px;
  margin: auto auto 0 auto;
  padding: 24px;
  box-sizing: border-box;
  box-shadow: 0 -8px 40px rgba(47, 33, 26, 0.15);
  transform: translateY(100%);
  opacity: 0;
  transition: 
    transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
    opacity 0.4s ease, 
    display 0.4s allow-discrete, 
    overlay 0.4s allow-discrete;
}

dialog.bottom-sheet[open] {
  transform: translateY(0);
  opacity: 1;
}

@starting-style {
  dialog.bottom-sheet[open] {
    transform: translateY(100%);
    opacity: 0;
  }
}

dialog.bottom-sheet::backdrop {
  background-color: rgba(47, 33, 26, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: 
    background-color 0.4s ease, 
    backdrop-filter 0.4s ease, 
    display 0.4s allow-discrete, 
    overlay 0.4s allow-discrete;
}

dialog.bottom-sheet[open]::backdrop {
  background-color: rgba(47, 33, 26, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

@starting-style {
  dialog.bottom-sheet[open]::backdrop {
    background-color: rgba(47, 33, 26, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
}

.sheet-title {
  font-size: 18px;
  color: var(--text-primary);
}

.sheet-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
}

.sheet-close-btn svg {
  width: 22px;
  height: 22px;
}

.sheet-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.sheet-product-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.sheet-product-img {
  width: 80px;
  height: 107px;
  border-radius: 8px;
  object-fit: cover;
  background-color: var(--bg-secondary);
}

.sheet-product-details {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sheet-product-price {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--maillard-plum);
  margin-bottom: 4px;
}

.sheet-product-choice {
  font-size: 12px;
  color: var(--text-muted);
}

.sheet-confirm-btn {
  width: 100%;
  background-color: var(--maillard-plum);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  height: 48px;
  margin-top: 24px;
  cursor: pointer;
  box-shadow: var(--btn-shadow);
  transition: var(--transition-smooth);
}

.sheet-confirm-btn:hover {
  background-color: var(--maillard-dark);
}

/* Sizing Guide Table */
.guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 10px;
}

.guide-table th {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
  padding: 8px;
  border: 1px solid var(--border-color);
}

.guide-table td {
  padding: 8px;
  border: 1px solid var(--border-color);
  text-align: center;
}

/* Off-canvas Cart Panel Drawer */
.cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  transform: translateX(100%); /* fully off-screen to the right by default */
  z-index: 120;
  width: 100%;
  max-width: 480px;
  height: 100%;
  background-color: var(--bg-primary);
  box-shadow: -8px 0 40px rgba(47, 33, 26, 0.15);
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  visibility: hidden;
}

.cart-panel.active {
  transform: translateX(0); /* slide fully into view */
  visibility: visible;
}

/* On wider screens, pin the cart drawer to align with the centered app-container */
@media (min-width: 481px) {
  .cart-panel {
    right: auto;
    left: 50%;
    /* Hidden: shifted right so it sits just off the right edge of the 480px container */
    transform: translateX(240px);
  }
  .cart-panel.active {
    /* Active: shift left by 240px (half of max-width) to align perfectly over container */
    transform: translateX(-240px);
  }
}
/* On mobile the base styles already handle it: right:0 + translateX(100%) hidden, translateX(0) active */


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

.cart-items-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.cart-item {
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.cart-item-img {
  width: 60px;
  height: 80px;
  border-radius: 6px;
  object-fit: cover;
}

.cart-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.cart-item-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.cart-item-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.cart-item-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-item-price {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--maillard-plum);
}

.quantity-controls {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-secondary);
}

.qty-btn {
  background: none;
  border: none;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
}

.qty-val {
  font-size: 12px;
  padding: 0 8px;
  font-weight: 600;
}

.cart-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

.cart-checkout-btn {
  width: 100%;
  height: 48px;
  background-color: var(--maillard-dark);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.cart-checkout-btn:hover {
  background-color: var(--maillard-plum);
}

/* Recommendations Grid */
.recommendations-section {
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

.recommendations-title {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  text-align: center;
}

.recommendations-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.reco-card {
  background-color: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: var(--transition-smooth);
}

.reco-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--glass-shadow);
}

.reco-img-wrapper {
  aspect-ratio: 3/4;
  position: relative;
  background-color: var(--bg-accent);
}

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

.reco-info {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reco-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reco-price-row {
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.reco-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--maillard-plum);
}

.reco-original-price {
  font-size: 10px;
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Reduced Motion Settings */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-delay: 0s !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
  }
}
