/**
 * 購物網站全局樣式
 * 設計風格：簡約、溫暖、有質感
 * 目標族群：30-65歲女性
 * 商品類型：麵包與蛋糕甜點
 */

/* ============================================
   CSS 變數定義（配色系統）
   ============================================ */
:root {
  /* 主色系 - 暖色調 */
  --brand-primary: #9B3B2E;      /* 暖磚紅 */
  --brand-secondary: #C66B4A;    /* 焦糖 */
  --brand-accent: #C9A66B;       /* 柔金 */
  
  /* 背景色系 */
  --bg-base: #FFF8F2;            /* 象牙白 */
  --bg-card: #ECE6E1;            /* 卡片暖灰 */
  --bg-white: #FFFFFF;
  
  /* 文字色系 */
  --text-primary: #3A3633;       /* 深灰 */
  --text-secondary: #6B6865;     /* 中灰 */
  --text-muted: #9B9894;         /* 淺灰 */
  
  /* 語意顏色 */
  --color-success: #7BA572;      /* 溫和綠 */
  --color-danger: #C24A3E;       /* 溫和紅 */
  --color-warning: #D89C5F;      /* 溫和橙 */
  --color-info: #7A9DB5;         /* 溫和藍 */
  
  /* 陰影 */
  --shadow-sm: 0 2px 8px rgba(155, 59, 46, 0.08);
  --shadow-md: 0 4px 16px rgba(155, 59, 46, 0.12);
  --shadow-lg: 0 8px 24px rgba(155, 59, 46, 0.16);
  --shadow-hover: 0 8px 20px rgba(155, 59, 46, 0.15);
  
  /* 圓角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* 間距 */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  
  /* 過渡 */
  --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 500ms cubic-bezier(0.22, 1, 0.36, 1);
  
  /* 動畫曲線 */
  --ease-out-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   全局基礎樣式
   ============================================ */
* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-base);
  line-height: 1.6;
  font-size: 16px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  
  /* Sticky Footer 佈局 */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
}

/* 主內容區域自動擴展 */
main {
  flex: 1 0 auto;
  padding-bottom: 2rem; /* 與 footer 保持間距 */
}

/* 響應式偏好：減少動畫 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Placeholder 樣式（全站統一）
   ============================================ */
/* Chrome, Safari, Opera */
input::placeholder,
textarea::placeholder,
select::placeholder {
  color: #D0D0D0 !important;
  opacity: 1 !important;
}

/* Firefox */
input::-moz-placeholder,
textarea::-moz-placeholder,
select::-moz-placeholder {
  color: #D0D0D0 !important;
  opacity: 1 !important;
}

/* Edge */
input::-ms-input-placeholder,
textarea::-ms-input-placeholder,
select::-ms-input-placeholder {
  color: #D0D0D0 !important;
}

/* Internet Explorer 10-11 */
input:-ms-input-placeholder,
textarea:-ms-input-placeholder,
select:-ms-input-placeholder {
  color: #D0D0D0 !important;
}

/* Webkit (Safari, Chrome) - Older versions */
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder,
select::-webkit-input-placeholder {
  color: #D0D0D0 !important;
  opacity: 1 !important;
}

/* ============================================
   字體排版
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

h1 { font-size: clamp(28px, 5vw, 40px); font-weight: 700; }
h2 { font-size: clamp(24px, 4vw, 32px); font-weight: 700; }
h3 { font-size: clamp(20px, 3.5vw, 28px); font-weight: 600; }
h4 { font-size: clamp(18px, 3vw, 24px); font-weight: 600; }
h5 { font-size: clamp(16px, 2.5vw, 20px); font-weight: 600; }
h6 { font-size: 16px; font-weight: 600; }

p {
  line-height: 1.6;
  margin-bottom: 1rem;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--transition-base);
}

a:hover {
  color: var(--brand-secondary);
  text-decoration: none;
}

/* ============================================
   容器與佈局
   ============================================ */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

@media (min-width: 768px) {
  .container {
    padding: 0 2rem;
  }
}

/* ============================================
   卡片樣式
   ============================================ */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  border: none;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  overflow: hidden;
}

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

.card-img-top {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: transform var(--transition-smooth);
}

.card:hover .card-img-top {
  transform: scale(1.05);
}

.card-body {
  padding: var(--spacing-md);
}

.card-header {
  background: var(--brand-primary);
  color: white;
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  font-weight: 600;
}

/* ============================================
   按鈕樣式
   ============================================ */
.btn {
  padding: 0.75rem 1.5rem;
  font-weight: 500;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  line-height: 1.5;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

/* 主要按鈕 */
.btn-primary {
  background: var(--brand-primary);
  color: white;
}

.btn-primary:hover {
  background: #7F3125;
  color: white;
}

/* 次要按鈕 */
.btn-secondary {
  background: var(--brand-accent);
  color: var(--text-primary);
}

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

/* 外框按鈕 */
.btn-outline-primary {
  background: transparent;
  border: 2px solid var(--brand-primary);
  color: var(--brand-primary);
}

.btn-outline-primary:hover {
  background: var(--brand-primary);
  color: white;
}

.btn-outline-secondary {
  background: transparent;
  border: 2px solid var(--brand-accent);
  color: var(--brand-accent);
}

.btn-outline-secondary:hover {
  background: var(--brand-accent);
  color: var(--text-primary);
}

/* 按鈕尺寸 */
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

/* ============================================
   導航欄樣式
   ============================================ */
.navbar {
  background: var(--bg-white);
  box-shadow: var(--shadow-sm);
  padding: 1rem 0;
  transition: all var(--transition-base);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
  background-color: rgba(255, 248, 242, 0.95);
  flex-shrink: 0; /* 確保 navbar 不會被壓縮 */
}

.navbar.scrolled {
  background-color: rgba(255, 248, 242, 0.98);
  box-shadow: var(--shadow-md);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--brand-primary) !important;
  transition: color var(--transition-base);
}

.navbar-brand:hover {
  color: var(--brand-secondary) !important;
}

.nav-link {
  color: var(--text-primary) !important;
  font-weight: 500;
  padding: 0.5rem 1rem !important;
  transition: color var(--transition-base);
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--brand-primary);
  transition: all var(--transition-base);
  transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 80%;
}

.nav-link:hover {
  color: var(--brand-primary) !important;
}

/* 購物車圖示 */
.cart-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.cart-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--brand-primary);
  color: white;
  border-radius: 50%;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

/* ============================================
   商品卡片專用樣式
   ============================================ */
.product-card {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px) scale(1.02);
}

.product-thumb {
  width: 100%;
  height: 240px;
  object-fit: cover;
  transition: transform var(--transition-smooth);
  cursor: pointer;
}

.product-card:hover .product-thumb {
  transform: scale(1.08);
}

.product-card-body {
  padding: var(--spacing-md);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.product-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 2.8em;
}

.product-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
}

.product-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand-primary);
  margin-bottom: 0.75rem;
}

.product-price-original {
  font-size: 1rem;
  color: var(--text-muted);
  text-decoration: line-through;
  margin-left: 0.5rem;
}

.product-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--brand-primary);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

.product-badge.new {
  background: var(--color-warning);
}

.product-badge.hot {
  background: var(--color-danger);
}

.product-badge.sale {
  background: var(--brand-primary);
}

.btn-add-cart {
  width: 100%;
  background: var(--brand-primary);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-add-cart:hover {
  background: #7F3125;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-add-cart:active {
  transform: scale(0.98);
}

/* ============================================
   商品圖集與燈箱相關
   ============================================ */
.product-gallery {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.product-main-image {
  width: 100%;
  border-radius: var(--radius-md);
  cursor: zoom-in;
  transition: transform var(--transition-base);
}

.product-main-image:hover {
  transform: scale(1.02);
}

.product-thumbnails {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.5rem 0;
}

.product-thumbnail {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  border: 2px solid transparent;
}

.product-thumbnail:hover {
  border-color: var(--brand-primary);
  transform: scale(1.05);
}

.product-thumbnail.active {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--brand-primary);
}

/* ============================================
   燈箱 (Lightbox) 樣式
   ============================================ */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9999;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-base);
  backdrop-filter: blur(8px);
}

.lightbox-overlay.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

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

.lightbox-image {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-primary);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all var(--transition-base);
  z-index: 10001;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: white;
  transform: scale(1.1);
}

.lightbox-close {
  top: 20px;
  right: 20px;
}

.lightbox-prev {
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-prev:hover {
  transform: translateY(-50%) scale(1.1);
}

.lightbox-next {
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next:hover {
  transform: translateY(-50%) scale(1.1);
}

.lightbox-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Toast 提示
   ============================================ */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9998;
  pointer-events: none;
}

.toast-notify {
  background: white;
  color: var(--text-primary);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 300px;
  opacity: 0;
  transform: translateX(100%);
  transition: all var(--transition-smooth);
  pointer-events: all;
  border-left: 4px solid var(--brand-primary);
}

.toast-notify.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-notify.success {
  border-left-color: var(--color-success);
}

.toast-notify.error {
  border-left-color: var(--color-danger);
}

.toast-notify.warning {
  border-left-color: var(--color-warning);
}

.toast-notify .toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast-notify .toast-message {
  flex-grow: 1;
}

.toast-notify .toast-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition-base);
}

.toast-notify .toast-close:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* ============================================
   飛入動畫相關
   ============================================ */
.fly-clone {
  position: fixed;
  z-index: 2000;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  transition: transform 600ms var(--ease-out-smooth), opacity 600ms;
  pointer-events: none;
  will-change: transform, opacity;
}

@media (prefers-reduced-motion: reduce) {
  .fly-clone {
    transition: none !important;
  }
}

/* ============================================
   頁尾樣式
   ============================================ */
.footer {
  background: var(--text-primary);
  color: rgba(255, 255, 255, 0.8);
  padding: 3rem 0 1.5rem;
  margin-top: auto; /* 使用 auto，讓 flexbox 自動推到底部 */
  flex-shrink: 0; /* 確保 footer 不會被壓縮 */
}

.footer h5 {
  color: white;
  font-weight: 600;
  margin-bottom: 1rem;
  font-size: 1.125rem;
}

.footer a {
  color: rgba(255, 255, 255, 0.8);
  transition: color var(--transition-base);
}

.footer a:hover {
  color: white;
}

.footer .list-unstyled li {
  margin-bottom: 0.5rem;
}

.footer hr {
  border-color: rgba(255, 255, 255, 0.2);
  margin: 2rem 0 1.5rem;
}

/* ============================================
   Hero 區塊
   ============================================ */
.hero-section {
  position: relative;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
  color: white;
  padding: 4rem 0;
  border-radius: var(--radius-lg);
  margin-bottom: 3rem;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 600"><rect fill="%23ffffff" fill-opacity="0.05" width="1200" height="600"/></svg>');
  opacity: 0.1;
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem;
}

.hero-title {
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.hero-subtitle {
  font-size: clamp(18px, 3vw, 24px);
  margin-bottom: 2rem;
  opacity: 0.95;
}

.hero-cta {
  display: inline-flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ============================================
   表單樣式
   ============================================ */
.form-control,
.form-select {
  border: 2px solid var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  color: var(--text-primary);
  background: white;
  transition: all var(--transition-base);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(155, 59, 46, 0.1);
  outline: none;
}

.form-label {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.form-check-input:checked {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}

/* ============================================
   Badge 與標籤
   ============================================ */
.badge {
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
}

.badge.bg-danger {
  background: var(--color-danger) !important;
}

.badge.bg-success {
  background: var(--color-success) !important;
}

.badge.bg-warning {
  background: var(--color-warning) !important;
  color: var(--text-primary) !important;
}

.badge.bg-primary {
  background: var(--brand-primary) !important;
}

/* ============================================
   載入動畫
   ============================================ */
.spinner-border {
  border-color: var(--brand-primary);
  border-right-color: transparent;
}

/* ============================================
   Alert 提示框
   ============================================ */
.alert {
  border: none;
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  border-left: 4px solid;
}

.alert-success {
  background: rgba(123, 165, 114, 0.1);
  border-left-color: var(--color-success);
  color: var(--text-primary);
}

.alert-danger {
  background: rgba(194, 74, 62, 0.1);
  border-left-color: var(--color-danger);
  color: var(--text-primary);
}

.alert-warning {
  background: rgba(216, 156, 95, 0.1);
  border-left-color: var(--color-warning);
  color: var(--text-primary);
}

.alert-info {
  background: rgba(122, 157, 181, 0.1);
  border-left-color: var(--color-info);
  color: var(--text-primary);
}

/* ============================================
   響應式工具類
   ============================================ */
@media (max-width: 767px) {
  .hero-section {
    padding: 2rem 0;
  }
  
  .product-card {
    margin-bottom: 1rem;
  }
  
  .lightbox-prev,
  .lightbox-next {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
  
  .lightbox-close {
    top: 10px;
    right: 10px;
  }
  
  .toast-notify {
    min-width: 280px;
  }
}

/* ============================================
   可訪問性增強
   ============================================ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 聚焦樣式 */
*:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* ============================================
   列印樣式
   ============================================ */
@media print {
  .navbar,
  .footer,
  .btn,
  .toast-container {
    display: none;
  }
  
  body {
    background: white;
  }
}

