/* ===== Design Tokens ===== */
:root {
  --gold: #c9a84c;
  --gold-light: #f4e5b1;
  --gold-dark: #a07c2a;
  --lv-brown: #4a3728;
  --lv-brown-light: #6b5341;
  --bg-warm: #faf8f4;
  --bg-card: #ffffff;
  --bg-overlay: rgba(74, 55, 40, 0.85);
  --text-main: #2d2014;
  --text-sub: #8c7a6a;
  --text-light: #b5a898;
  --red-like: #e74c5e;
  --green-ok: #4caf50;
  --shadow-card: 0 4px 24px rgba(74, 55, 40, 0.12);
  --shadow-heavy: 0 8px 40px rgba(74, 55, 40, 0.2);
  --radius: 20px;
  --radius-sm: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-tw: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --font-en: 'Lexend', sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enforce hidden attribute */
[hidden] {
  display: none !important;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-tw);
  background: var(--bg-warm);
  color: var(--text-main);
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ===== Views ===== */
.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  opacity: 0;
  will-change: opacity, transform;
}

.view.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
  animation: viewFadeIn 0.25s ease both;
}

@keyframes viewFadeIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ===== PICKER VIEW ===== */
.picker-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--lv-brown) 0%, var(--lv-brown-light) 100%);
  color: var(--gold-light);
  flex-shrink: 0;
}

.picker-header__lv {
  font-family: var(--font-en);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: 0.7;
}

.picker-header__title {
  font-size: 20px;
  font-weight: 700;
}

.picker-header__list-btn {
  position: relative;
  background: rgba(255, 255, 255, 0.15);
  color: var(--gold-light);
  font-size: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.picker-header__list-btn:active {
  background: rgba(255, 255, 255, 0.3);
}

.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--red-like);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-family: var(--font-en);
}

/* Snap scroll container */
.picker-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
}

/* Product Card */
.product-card {
  scroll-snap-align: start;
  height: calc(100dvh - 60px - 100px);
  /* minus header and footer */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px 20px 8px;
  position: relative;
  background: var(--bg-warm);
}

.product-card__badge {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--lv-brown);
  color: var(--gold-light);
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  z-index: 2;
}

.product-card__image-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-height: 55%;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-card);
}

.product-card__image {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  transition: transform 0.4s ease;
}

.product-card__image-wrap:active .product-card__image {
  transform: scale(1.05);
}

.product-card__tap-hint {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 12px;
  color: var(--text-light);
  background: rgba(255, 255, 255, 0.85);
  padding: 2px 8px;
  border-radius: 8px;
}

.product-card__info {
  width: 100%;
  padding: 12px 0 0;
  text-align: center;
}

.product-card__name {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-main);
  margin-bottom: 2px;
}

.product-card__name-en {
  font-family: var(--font-en);
  font-size: 14px;
  color: var(--text-sub);
  margin-bottom: 8px;
  font-weight: 400;
}

.product-card__price-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.product-card__price-twd {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 38px;
  color: var(--gold-dark);
  letter-spacing: -1px;
}

.product-card__price-unit {
  font-family: var(--font-en);
  font-size: 18px;
  font-weight: 600;
  color: var(--gold);
}

.product-card__price-vnd {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

.product-card__tag {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--gold-light);
  color: var(--gold-dark);
}

.product-card__liked-indicator {
  position: absolute;
  top: 20px;
  left: 20px;
  font-size: 28px;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.product-card__liked-indicator.show {
  opacity: 1;
}

/* Picker Footer */
.picker-footer {
  display: flex;
  gap: 12px;
  padding: 12px 20px calc(12px + var(--safe-bottom));
  background: var(--bg-card);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.picker-footer__btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 64px;
  border-radius: var(--radius-sm);
  font-size: 22px;
  font-weight: 700;
  transition: all var(--transition);
}

.picker-footer__btn:active {
  transform: scale(0.96);
}

.picker-footer__btn--skip {
  background: #f0ebe5;
  color: var(--lv-brown);
}

.picker-footer__btn--like {
  background: linear-gradient(135deg, var(--red-like) 0%, #d43d50 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(231, 76, 94, 0.35);
}

.picker-footer__btn--like.liked {
  background: linear-gradient(135deg, var(--green-ok) 0%, #3d9940 100%);
  box-shadow: 0 4px 16px rgba(76, 175, 80, 0.35);
}

.btn-icon {
  font-size: 26px;
}

.btn-label {
  font-size: 20px;
}

/* ===== LIST VIEW ===== */
.list-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--lv-brown) 0%, var(--lv-brown-light) 100%);
  color: var(--gold-light);
  flex-shrink: 0;
}

.back-btn {
  background: rgba(255, 255, 255, 0.15);
  color: var(--gold-light);
  font-size: 18px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 10px;
  transition: background var(--transition);
  white-space: nowrap;
}

.back-btn:active {
  background: rgba(255, 255, 255, 0.3);
}

.list-header__title {
  font-size: 22px;
  font-weight: 700;
}

.list-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 120px;
  -webkit-overflow-scrolling: touch;
}

/* List Item Card */
.list-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition);
  animation: slideIn 0.3s ease both;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.list-card.removing {
  animation: slideOut 0.3s ease both;
}

@keyframes slideOut {
  to {
    opacity: 0;
    transform: translateX(-100px);
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
  }
}

.list-card__image {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 10px;
  background: #f5f3ef;
  flex-shrink: 0;
}

.list-card__info {
  flex: 1;
  min-width: 0;
}

.list-card__name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-main);
}

.list-card__name-en {
  font-family: var(--font-en);
  font-size: 12px;
  color: var(--text-sub);
}

.list-card__price {
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 20px;
  color: var(--gold-dark);
  margin-top: 4px;
}

.list-card__delete {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fce8ea;
  color: var(--red-like);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.list-card__delete:active {
  background: var(--red-like);
  color: #fff;
}

/* Empty State */
.list-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}

.list-empty__icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.list-empty__text {
  font-size: 22px;
  color: var(--text-sub);
  line-height: 1.5;
  margin-bottom: 24px;
}

/* List Footer */
.list-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding: 12px 20px calc(12px + var(--safe-bottom));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  z-index: 10;
}

.list-footer__summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 16px;
  color: var(--text-sub);
}

.list-footer__summary strong {
  color: var(--text-main);
  font-size: 20px;
  font-family: var(--font-en);
}

.list-footer__total strong {
  color: var(--gold-dark);
  font-size: 24px;
}

/* CTA Buttons */
.cta-btn {
  display: block;
  width: 100%;
  height: 64px;
  border-radius: var(--radius-sm);
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(201, 168, 76, 0.4);
  transition: all var(--transition);
}

.cta-btn:active {
  transform: scale(0.97);
}

.cta-btn--share {
  background: linear-gradient(135deg, var(--green-ok) 0%, #2e7d32 100%);
  box-shadow: 0 4px 16px rgba(76, 175, 80, 0.4);
}

.cta-btn--add {
  background: linear-gradient(135deg, var(--red-like) 0%, #c62828 100%);
  box-shadow: 0 4px 16px rgba(231, 76, 94, 0.4);
}

.cta-btn--added {
  background: linear-gradient(135deg, var(--green-ok) 0%, #2e7d32 100%);
  box-shadow: 0 4px 16px rgba(76, 175, 80, 0.4);
}

/* ===== DETAIL VIEW ===== */
.detail-header {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--lv-brown) 0%, var(--lv-brown-light) 100%);
  color: var(--gold-light);
  flex-shrink: 0;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 100px;
}

.detail-image-wrap {
  width: 100%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  min-height: 300px;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
  cursor: zoom-in;
}

.detail-image-wrap.active-zoom {
  overflow: auto;
  display: flex;
  cursor: zoom-out;
  align-items: flex-start;
  justify-content: flex-start;
}

.detail-image-wrap.active-zoom .detail-image {
  max-width: none;
  max-height: none;
  width: 200%;
  height: auto;
  margin: 0;
  flex-shrink: 0;
}

.detail-image {
  max-width: 85%;
  max-height: 50vh;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.detail-zoom-hint {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 13px;
  color: var(--text-light);
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 10px;
  border-radius: 8px;
}

.detail-info {
  padding: 20px 24px;
  text-align: center;
}

.detail-badge {
  display: inline-block;
  background: var(--lv-brown);
  color: var(--gold-light);
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 14px;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.detail-name {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 4px;
}

.detail-name-en {
  font-family: var(--font-en);
  font-size: 16px;
  color: var(--text-sub);
  margin-bottom: 16px;
}

.detail-price-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin-bottom: 4px;
}

.detail-price-twd {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 44px;
  color: var(--gold-dark);
  letter-spacing: -1px;
}

.detail-price-unit {
  font-family: var(--font-en);
  font-size: 20px;
  font-weight: 600;
  color: var(--gold);
}

.detail-price-vnd {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.detail-tag {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  background: var(--gold-light);
  color: var(--gold-dark);
}

.detail-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 20px calc(12px + var(--safe-bottom));
  background: var(--bg-card);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  z-index: 10;
}

.detail-actions {
  display: flex;
  gap: 12px;
}

.detail-actions .cta-btn {
  flex: 1;
  font-size: 18px;
}

.cta-btn--next-detail {
  background: #fff;
  color: var(--text-main);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.cta-btn--next-detail:active {
  background: #f5f5f5;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-overlay);
  color: #fff;
  padding: 12px 28px;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 600;
  z-index: 100;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Heart Animation ===== */
@keyframes heartPop {
  0% {
    transform: scale(0);
    opacity: 1;
  }

  50% {
    transform: scale(1.6);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.heart-pop {
  animation: heartPop 0.5s ease both;
}

/* ===== Loading Skeleton ===== */
.skeleton {
  background: linear-gradient(90deg, #f0ebe5 25%, #e8e2d9 50%, #f0ebe5 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 12px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ===== Share Modal ===== */
.share-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.share-modal {
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 500px;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.share-modal__title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-main);
}

.share-modal__btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-modal__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 56px;
  border-radius: var(--radius-sm);
  font-size: 20px;
  font-weight: 600;
  transition: all var(--transition);
}

.share-modal__btn:active {
  transform: scale(0.97);
}

.share-modal__btn--line {
  background: #06C755;
  color: #fff;
}

.share-modal__btn--copy {
  background: #f0ebe5;
  color: var(--lv-brown);
}

.share-modal__btn--close {
  background: transparent;
  color: var(--text-sub);
  font-size: 18px;
  height: 48px;
}

/* ===== Tablet (768px+) ===== */
@media (min-width: 768px) {
  .product-card {
    padding: 24px 40px 12px;
  }

  .product-card__name {
    font-size: 32px;
  }

  .product-card__price-twd {
    font-size: 48px;
  }

  .picker-footer__btn {
    height: 72px;
    font-size: 24px;
  }

  .list-card {
    padding: 16px;
  }

  .list-card__image {
    width: 100px;
    height: 100px;
  }

  .list-card__name {
    font-size: 22px;
  }

  .list-card__price {
    font-size: 24px;
  }

  .detail-name {
    font-size: 36px;
  }

  .detail-price-twd {
    font-size: 52px;
  }

  .cta-btn {
    height: 72px;
    font-size: 24px;
    max-width: 500px;
    margin: 0 auto;
  }
}