/* ============================================
   EventLoyalty - Modern Light Theme
   Responsive, Compatible, Clean Design
   ============================================ */

:root {
  /* 主色調 - 優雅珊瑚粉漸變 */
  --primary-color: #ff7b7b;
  --primary-dark: #ff5f6d;
  --primary-light: #ffa8a8;
  --primary-gradient: linear-gradient(135deg, #ff5f6d 0%, #ffc371 100%);
  --primary-gradient-soft: linear-gradient(
    135deg,
    rgba(255, 95, 109, 0.1) 0%,
    rgba(255, 195, 113, 0.1) 100%
  );

  /* 輔助色 */
  --accent-color: #feca57;
  --success-color: #00b894;
  --success-gradient: linear-gradient(135deg, #00b894 0%, #1dd1a1 100%);
  --warning-color: #fdcb6e;
  --danger-color: #e17055;
  --info-color: #74b9ff;

  /* 淺色背景系統 */
  --bg-main: linear-gradient(135deg, #ffecd2 0%, #fcb69f 50%, #ffecd2 100%);
  --bg-light: #faf9f7;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(255, 255, 255, 0.95);

  /* 文字顏色 */
  --text-main: #2d3436;
  --text-secondary: #636e72;
  --text-light: #b2bec3;

  /* 陰影效果 */
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-strong: 0 12px 40px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 4px 20px rgba(255, 95, 109, 0.25);

  /* 圓角 */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;

  /* 間距 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* 過渡動畫 */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* ===== 重置與基礎 ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  font-family: "Noto Sans TC", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-main);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.7;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* ===== 背景裝飾 ===== */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.3;
  z-index: -1;
  animation: floatBlob 20s ease-in-out infinite alternate;
  will-change: transform;
}

.bg-blob:first-child {
  top: -15%;
  left: -10%;
  width: 45vw;
  height: 45vw;
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.bg-blob:nth-child(2) {
  bottom: -15%;
  right: -10%;
  width: 50vw;
  height: 50vw;
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  animation-delay: -10s;
}

@keyframes floatBlob {
  0% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(30px, 20px) scale(1.05);
  }
  100% {
    transform: translate(-20px, 40px) scale(0.95);
  }
}

/* ===== 側邊欄 ===== */
#sidebar {
  width: 260px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  height: 100vh;
  height: 100dvh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand-area {
  padding: var(--space-lg) var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.brand-logo {
  width: 42px;
  height: auto;
  border-radius: var(--radius-sm);
}

.brand-text {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-menu {
  list-style: none;
  padding: var(--space-md) var(--space-sm);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.nav-item {
  margin-bottom: var(--space-sm);
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-weight: 500;
  cursor: pointer;
  min-height: 48px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.8);
  color: var(--primary-color);
}

.nav-link.active {
  background: white;
  color: var(--primary-color);
  box-shadow: var(--shadow-soft);
}

.nav-link .material-icons-round {
  margin-right: 12px;
  font-size: 22px;
}

/* ===== 主內容區 ===== */
#main-app {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

#main-content {
  margin-left: 260px;
  padding: var(--space-lg);
  padding-bottom: 100px;
  transition: margin-left var(--transition-normal);
  width: calc(100% - 260px);
  max-width: 100%;
  min-height: 100vh;
}

/* ===== 手機頂部列 ===== */
.mobile-header {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 12px var(--space-md);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 99;
  border-bottom: 1px solid var(--glass-border);
  margin: calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg)) var(--space-lg);
}

/* ===== 卡片元件 ===== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-soft);
  margin-bottom: var(--space-md);
  transition: transform var(--transition-fast),
    box-shadow var(--transition-fast);
  width: 100%;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-medium);
}

/* ===== 按鈕系統 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  gap: var(--space-sm);
  min-height: 44px;
  touch-action: manipulation;
  user-select: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 95, 109, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
}

.btn-outline:hover {
  background: var(--primary-gradient);
  border-color: transparent;
  color: white;
}

.btn-success {
  background: var(--success-gradient);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, #e17055 0%, #d63031 100%);
  color: white;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  min-height: 36px;
}

/* ===== 表單元件 ===== */
.input-group {
  margin-bottom: var(--space-md);
  position: relative;
}

.input-field,
select,
textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.9);
  outline: none;
  font-size: 1rem;
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast);
  font-family: inherit;
}

.input-field:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(255, 95, 109, 0.1);
}

label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95rem;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.toggle-visibility {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.toggle-visibility:hover {
  color: var(--primary-color);
}

/* ===== 點數徽章 ===== */
.points-badge {
  background: var(--primary-gradient);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-glow);
}

/* ===== 網格系統 ===== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-lg);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-lg);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

/* ===== 區塊切換 ===== */
.section {
  display: none;
  animation: fadeSlideIn 0.4s ease;
}

.section.active {
  display: block;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== 頁籤 ===== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-lg);
  background: rgba(255, 255, 255, 0.6);
  padding: 6px;
  border-radius: var(--radius-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 12px 20px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  border-radius: var(--radius-md);
  white-space: nowrap;
  min-height: 44px;
  font-family: inherit;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-main);
}

.tab.active {
  background: white;
  color: var(--primary-color);
  box-shadow: var(--shadow-soft);
}

/* ===== 標籤徽章 ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-success {
  background: linear-gradient(
    135deg,
    rgba(0, 184, 148, 0.15) 0%,
    rgba(29, 209, 161, 0.15) 100%
  );
  color: var(--success-color);
}

.badge-danger {
  background: rgba(225, 112, 85, 0.12);
  color: var(--danger-color);
}

.badge-warning {
  background: rgba(253, 203, 110, 0.2);
  color: #d68910;
}

.badge-info {
  background: rgba(116, 185, 255, 0.15);
  color: #2980b9;
}

/* ===== Modal 彈窗 ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal.active {
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.25s ease;
}

.modal-content {
  background: white;
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-strong);
  animation: slideUp 0.3s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.modal-close {
  cursor: pointer;
  color: var(--text-secondary);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: rgba(225, 112, 85, 0.1);
  color: var(--danger-color);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: white;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-strong);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 360px;
  z-index: 1001;
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--transition-normal);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ===== 表格 ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.table th {
  background: var(--primary-gradient);
  color: white;
  padding: 16px;
  text-align: left;
  font-weight: 600;
}

.table td {
  padding: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover {
  background: rgba(255, 95, 109, 0.02);
}

.table-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ===== 統計卡片 ===== */
.stat-card {
  background: white;
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition-fast);
  text-align: center;
}

.stat-card:hover {
  transform: translateY(-4px);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: var(--space-sm) 0;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ===== AI 回應 ===== */
.ai-response {
  background: var(--primary-gradient-soft);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-top: 12px;
  line-height: 1.7;
  border-left: 4px solid var(--primary-color);
}

/* ===== API 狀態點 ===== */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-light);
}

.status-dot.connected {
  background: var(--success-color);
  box-shadow: 0 0 10px var(--success-color);
}

.status-dot.error {
  background: var(--danger-color);
}

/* ===== 活動卡片 ===== */
.event-card-v {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-normal),
    box-shadow var(--transition-normal);
}

.event-card-v:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-strong);
}

.event-thumb-v {
  width: 100%;
  height: 200px;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-light);
  transition: transform 0.5s ease;
}

.event-card-v:hover .event-thumb-v {
  transform: scale(1.05);
}

.event-content-v {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.event-desc-v {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event-footer-v {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* 活動日期顯示 */
.event-date-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--primary-color);
  margin: var(--space-xs) 0;
  font-weight: 500;
}

/* 已結束標籤 */
.event-ended-badge {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.event-thumb-v {
  position: relative;
}

/* ===== 兌換商品卡片 ===== */
.redeem-card {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.redeem-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-strong);
}

.redeem-thumb {
  width: 100%;
  height: 180px;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #f8f9fa;
  cursor: pointer;
  transition: transform 0.4s ease;
  position: relative;
}

.redeem-card:hover .redeem-thumb {
  transform: scale(1.03);
}

.redeem-thumb-placeholder {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
}

.redeem-content {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.redeem-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0 0 var(--space-sm) 0;
  line-height: 1.4;
}

.redeem-desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: var(--space-md);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.redeem-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-md);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.redeem-price {
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.redeem-btn {
  padding: 10px 20px;
  font-size: 0.85rem;
  border-radius: var(--radius-full);
}

/* 過期兌換券樣式 */
.expired-header {
  background: linear-gradient(145deg, #9ca3af 0%, #6b7280 100%) !important;
}

.coupon-card:has(.expired-header) {
  opacity: 0.8;
}

/* ===== Dashboard Hero ===== */
.dashboard-hero {
  background: white;
  padding: var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius-lg);
  border-left: 6px solid var(--primary-color);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-soft);
}

.hero-status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.featured-event-card {
  position: relative;
  overflow: hidden;
}

.featured-badge {
  position: absolute;
  top: var(--space-md);
  left: var(--space-md);
  background: var(--primary-gradient);
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 2;
  box-shadow: var(--shadow-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== 分享選單 ===== */
.share-menu {
  position: absolute;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-strong);
  padding: var(--space-sm) 0;
  z-index: 1000;
  min-width: 190px;
  display: none;
  animation: dropdownFade 0.2s ease;
}

.share-menu.active {
  display: block;
}

.share-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background var(--transition-fast);
  color: var(--text-main);
  font-size: 0.95rem;
  text-decoration: none;
}

.share-item:hover {
  background: rgba(0, 0, 0, 0.03);
}
.share-item .material-icons-round {
  font-size: 20px;
}
.line-color {
  color: #00b900 !important;
}
.fb-color {
  color: #1877f2 !important;
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== 滾動條 ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* 火狐瀏覽器滾動條 */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.03);
}

/* ===== 工具類 ===== */
.text-secondary {
  color: var(--text-secondary);
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
h1,
h2,
h3 {
  margin-bottom: var(--space-md);
  color: var(--text-main);
}
footer {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ============================================
   響應式設計
   ============================================ */

/* 平板與桌面中等尺寸 */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Dashboard 專用網格 */
.dashboard-grid {
  grid-template-columns: 1.4fr 1fr;
}

@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* 平板豎屏 */
@media (max-width: 768px) {
  :root {
    --space-lg: 20px;
    --space-xl: 28px;
  }

  #sidebar {
    transform: translateX(-100%);
    width: 85%;
    max-width: 320px;
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-strong);
  }

  #main-content {
    margin-left: 0;
    padding: var(--space-md);
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .mobile-header {
    display: flex;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  /* 確保所有卡片不超出螢幕 */
  .card {
    padding: var(--space-md);
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
  }
  
  /* Dashboard 卡片內的按鈕縮小 */
  .dashboard-grid .btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
  
  /* 推薦/即將到期卡片的項目 */
  .dashboard-grid .card > div {
    max-width: 100%;
    overflow: hidden;
  }

  .btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .modal-content {
    width: 95%;
    max-width: 95vw;
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
  }

  .tabs {
    padding: 4px;
  }

  .tab {
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  .table {
    font-size: 0.85rem;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .table th,
  .table td {
    padding: 12px;
    min-width: 100px;
  }

  .stat-value {
    font-size: 1.6rem;
  }

  .dashboard-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

  .dashboard-hero .btn {
    width: 100%;
  }

  .event-thumb-v {
    height: 180px;
  }
}

/* 手機 */
@media (max-width: 480px) {
  :root {
    --radius-lg: 18px;
    --radius-xl: 24px;
  }

  .points-badge {
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  #page-title {
    font-size: 1.2rem;
  }

  .brand-text {
    font-size: 0.95rem;
  }

  .nav-link {
    padding: 12px 14px;
    font-size: 0.9rem;
  }

  .stat-card {
    padding: var(--space-md);
  }
  .stat-value {
    font-size: 1.4rem;
  }
  .stat-label {
    font-size: 0.8rem;
  }

  .event-thumb-v {
    height: 150px;
  }
  .redeem-thumb {
    height: 120px;
  }

  .event-footer-v {
    flex-direction: column;
    align-items: stretch;
  }

  .event-footer-v .btn {
    width: 100%;
  }

  .toast {
    left: var(--space-md);
    right: var(--space-md);
    bottom: var(--space-md);
    max-width: none;
  }
}

/* 觸控設備優化 */
@media (pointer: coarse) {
  .btn {
    min-height: 48px;
  }
  .nav-link {
    min-height: 52px;
  }
  .tab {
    min-height: 48px;
  }

  .input-field,
  select,
  textarea {
    font-size: 16px; /* 防止 iOS 縮放 */
  }
}

/* 減少動畫（無障礙） */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .bg-blob {
    animation: none;
  }
}

/* 高對比模式 */
@media (prefers-contrast: high) {
  :root {
    --text-secondary: #4a4a4a;
    --glass-border: rgba(0, 0, 0, 0.2);
  }

  .btn-outline {
    border-width: 3px;
  }
}

/* Safari 相容性 */
@supports (-webkit-touch-callout: none) {
  #sidebar {
    height: -webkit-fill-available;
  }
  body {
    min-height: -webkit-fill-available;
  }
}

/* 防止內容溢出 */
img {
  max-width: 100%;
  height: auto;
}

/* Admin Tab */
.admin-tab {
  display: none;
  animation: fadeSlideIn 0.3s ease;
}

/* 票券標籤頁 */
.ticket-tab {
  animation: fadeSlideIn 0.3s ease;
}

/* 載入動畫 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== 票券網格佈局 ===== */
.tickets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
  width: 100%;
}

/* 桌面大螢幕 */
@media (min-width: 1200px) {
  .tickets-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 900px) and (max-width: 1199px) {
  .tickets-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 600px) and (max-width: 899px) {
  .tickets-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 599px) {
  .tickets-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
}

/* 票券卡片樣式 */
.ticket-card,
.coupon-card {
  text-align: center;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.ticket-card:hover,
.coupon-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-strong);
}

.ticket-header {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
}

.coupon-header {
  background: var(--success-gradient);
}

.ticket-icon {
  font-size: 28px;
  color: white;
}

.ticket-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: var(--space-xs);
  word-break: break-word;
}

.ticket-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.ticket-qr {
  background: white;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  margin-bottom: var(--space-md);
}

.ticket-qr img {
  display: block;
}

.ticket-code {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-main);
  margin-bottom: var(--space-sm);
}

.coupon-code {
  color: var(--primary-color);
}

.ticket-status {
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* 兌換券特殊樣式 */
.coupon-card {
  background: linear-gradient(135deg, rgba(0, 184, 148, 0.05) 0%, rgba(29, 209, 161, 0.08) 100%);
  border: 1px solid rgba(0, 184, 148, 0.15);
}

.coupon-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding-top: var(--space-md);
  margin-top: var(--space-sm);
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

.coupon-cost {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== 子標籤頁 ===== */
.sub-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--radius-md);
}

.sub-tab {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sub-tab:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-main);
}

.sub-tab.active {
  background: white;
  color: var(--primary-color);
  box-shadow: var(--shadow-soft);
}

/* ===== Footer 版權宣告 ===== */
footer {
  text-align: center;
  padding: 30px 20px;
  margin-top: auto;
  color: var(--text-secondary);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

/* ===== 主內容區域優化 ===== */
#main-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#main-content > .section {
  flex: 1;
}

/* 標題字體優化 */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1.1rem;
}

/* 段落和說明文字優化 */
p {
  line-height: 1.75;
}

.text-secondary {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* 空白狀態優化 */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
  font-size: 1rem;
  letter-spacing: 0.02em;
}
