/* ==========================================
   🎮 Drama Ling 設計系統 v3.0
   企業級英語學習平台統一設計標準
   ========================================== */

/* ==========================================
   🎨 設計系統變數定義
   ========================================== */

:root {
  /* ==========================================
     🌈 色彩系統 (Color System)
     ========================================== */

  /* 主要品牌色彩 */
  --primary-teal: #00E5CC;
  --primary-teal-light: #33E8D1;
  --primary-teal-dark: #00B3A0;

  /* 輔助色彩 */
  --secondary-purple: #8E44AD;
  --secondary-purple-light: #A569BD;
  --secondary-purple-dark: #6C3483;

  /* 強調色彩 */
  --accent-violet: #9B59B6;
  --accent-violet-light: #BB8FCE;
  --accent-violet-dark: #7D3C98;
  --accent-pink: #E91E63;
  --accent-orange: #FF6B35;

  /* 功能性色彩 */
  --success-green: #00D2A5;
  --warning-yellow: #F1C40F;
  --error-red: #E74C3C;
  --info-cyan: #3498DB;

  /* 暗色主題色調 */
  --text-primary: #FFFFFF;
  --text-secondary: #BDC3C7;
  --text-tertiary: #95A5A6;
  --background-primary: #2C3E50;
  --background-secondary: #34495E;
  --background-tertiary: #3C4F65;
  --background-dark: #1A252F;
  --divider: #4A6278;
  --card-background: #3A4A5C;

  /* 遊戲化色彩 */
  --star-active: #F1C40F;
  --star-inactive: #7F8C8D;
  --bronze: #CD7F32;
  --silver: #C0C0C0;
  --gold: #FFD700;
  --diamond: #B9F2FF;
  --exp-bar: #00E5CC;
  --level-background: #8E44AD;
  --achievement-glow: #F39C12;
  --rank-other: #718096;

  /* ==========================================
     📏 間距系統 (Spacing System)
     ========================================== */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* ==========================================
     🔄 圓角系統 (Border Radius)
     ========================================== */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-2xl: 32px;
  --radius-full: 50%;

  /* ==========================================
     📝 字體系統 (Typography)
     ========================================== */
  
  /* 字體大小 */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;
  --text-3xl: 34px;
  --text-4xl: 42px;

  /* 遊戲化特殊字體 */
  --text-game-score: 24px;
  --text-game-level: 14px;
  --text-game-title: 20px;

  /* ==========================================
     🌫️ 陰影系統 (Shadow System)
     ========================================== */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.25);
  --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.3);

  /* 發光效果 */
  --glow-teal: 0 0 20px rgba(0, 229, 204, 0.3);
  --glow-purple: 0 0 20px rgba(142, 68, 173, 0.3);
  --glow-pink: 0 0 20px rgba(233, 30, 99, 0.3);
  --glow-orange: 0 0 20px rgba(255, 107, 53, 0.3);
  --glow-yellow: 0 0 20px rgba(241, 196, 15, 0.3);

  /* ==========================================
     📱 響應式斷點 (Responsive Breakpoints)
     ========================================== */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
}

/* ==========================================
   🔧 基礎重置和全域樣式
   ========================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang TC', 'Microsoft JhengHei UI', sans-serif;
  background: var(--background-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ==========================================
   🎯 按鈕組件系統
   ========================================== */

/* 主要按鈕 */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-teal), var(--success-green));
  color: white;
  border: 2px solid var(--primary-teal);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-xl);
  font-weight: 700;
  font-size: var(--text-base);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  box-shadow: var(--glow-teal);
  text-decoration: none;
  min-height: 48px;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--success-green), var(--primary-teal));
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 229, 204, 0.4);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 次要按鈕 */
.btn-secondary {
  background: linear-gradient(135deg, var(--background-tertiary), var(--background-secondary));
  color: var(--text-primary);
  border: 2px solid var(--divider);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-xl);
  font-weight: 600;
  font-size: var(--text-base);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-decoration: none;
  min-height: 48px;
}

.btn-secondary:hover {
  background: linear-gradient(135deg, var(--secondary-purple), var(--accent-violet));
  color: white;
  border-color: var(--secondary-purple);
  transform: translateY(-2px);
  box-shadow: var(--glow-purple);
}

/* 危險按鈕 */
.btn-danger {
  background: linear-gradient(135deg, var(--background-tertiary), var(--background-secondary));
  color: var(--error-red);
  border: 2px solid var(--error-red);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-xl);
  font-weight: 600;
  font-size: var(--text-base);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-decoration: none;
  min-height: 48px;
}

.btn-danger:hover {
  background: linear-gradient(135deg, var(--error-red), rgba(231, 76, 60, 0.8));
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(231, 76, 60, 0.4);
}

/* 按鈕尺寸變體 */
.btn-lg {
  padding: var(--space-6) var(--space-8);
  font-size: var(--text-lg);
  min-height: 56px;
}

.btn-sm {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  min-height: 36px;
}

.btn-xs {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  min-height: 28px;
}

/* ==========================================
   📝 輸入框組件
   ========================================== */

.input-field {
  width: 100%;
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(135deg, var(--background-secondary), var(--background-tertiary));
  border: 2px solid var(--divider);
  border-radius: var(--radius-xl);
  font-size: var(--text-base);
  color: var(--text-primary);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  min-height: 48px;
}

.input-field:focus {
  outline: none;
  background: linear-gradient(135deg, var(--background-tertiary), var(--card-background));
  border-color: var(--primary-teal);
  box-shadow: var(--glow-teal);
  transform: scale(1.01);
}

.input-field::placeholder {
  color: var(--text-tertiary);
}

.input-field:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--background-dark);
}

/* 搜尋輸入框 */
.search-input {
  position: relative;
}

.search-input::before {
  content: '🔍';
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
}

/* ==========================================
   🃏 卡片組件系統
   ========================================== */

.card {
  background: linear-gradient(135deg, var(--background-secondary), var(--background-tertiary));
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  border: 2px solid var(--divider);
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(20px);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg), var(--glow-teal);
  border-color: var(--primary-teal);
}

/* 遊戲化卡片 */
.card-game {
  background: linear-gradient(135deg, var(--secondary-purple), var(--accent-violet));
  border: 2px solid var(--primary-teal);
  color: white;
  box-shadow: var(--glow-purple);
}

.card-game:hover {
  box-shadow: var(--shadow-lg), var(--glow-purple);
}

/* 成就卡片 */
.card-achievement {
  background: linear-gradient(135deg, var(--gold), #FFA000);
  border: 2px solid var(--achievement-glow);
  color: var(--background-dark);
  box-shadow: var(--glow-yellow);
}

/* 統計卡片 */
.card-stats {
  background: linear-gradient(135deg, var(--info-cyan), #2196F3);
  border: 2px solid var(--info-cyan);
  color: white;
  text-align: center;
}

/* ==========================================
   📊 數據可視化組件
   ========================================== */

.stat-card {
  background: linear-gradient(135deg, var(--background-secondary), var(--background-tertiary));
  padding: var(--space-6);
  border-radius: var(--radius-2xl);
  border: 2px solid var(--divider);
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--primary-teal);
  box-shadow: var(--glow-teal);
}

.stat-number {
  font-size: var(--text-3xl);
  font-weight: 900;
  color: var(--primary-teal);
  margin-bottom: var(--space-2);
  text-shadow: 0 0 8px rgba(0, 229, 204, 0.3);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 進度條 */
.progress-bar {
  width: 100%;
  height: 12px;
  background: linear-gradient(135deg, var(--background-tertiary), var(--background-secondary));
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--divider);
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, var(--primary-teal), var(--success-green));
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 0 12px rgba(0, 229, 204, 0.5);
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shine 2s ease-in-out infinite;
}

@keyframes shine {
  0% { left: -100%; }
  50%, 100% { left: 100%; }
}

/* ==========================================
   🌟 遊戲化元素
   ========================================== */

/* 星級評分 */
.star-rating {
  display: flex;
  gap: var(--space-1);
  justify-content: center;
  margin: var(--space-2) 0;
}

.star {
  width: 24px;
  height: 24px;
  color: var(--star-inactive);
  transition: all 0.3s ease;
  cursor: pointer;
}

.star.active {
  color: var(--star-active);
  filter: drop-shadow(0 0 8px rgba(241, 196, 15, 0.6));
  animation: starGlow 2s ease-in-out infinite alternate;
}

@keyframes starGlow {
  0% { filter: drop-shadow(0 0 8px rgba(241, 196, 15, 0.6)); }
  100% { filter: drop-shadow(0 0 16px rgba(241, 196, 15, 0.9)); }
}

/* 用戶頭像 */
.user-avatar {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-teal), var(--success-green));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 3px solid var(--primary-teal);
  color: white;
  font-weight: 700;
  font-size: var(--text-xl);
  box-shadow: var(--glow-teal);
}

.user-avatar::before {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  background: linear-gradient(45deg, var(--primary-teal), var(--success-green), var(--secondary-purple), var(--accent-pink));
  border-radius: var(--radius-full);
  z-index: -1;
  animation: rotate 4s linear infinite;
}

@keyframes rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 等級徽章 */
.level-badge {
  background: linear-gradient(135deg, var(--level-background), var(--accent-violet));
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-game-level);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: var(--glow-purple);
  border: 2px solid var(--secondary-purple);
}

/* 經驗值條 */
.exp-bar {
  width: 100%;
  height: 16px;
  background: var(--background-dark);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 2px solid var(--exp-bar);
  position: relative;
}

.exp-fill {
  height: 100%;
  background: linear-gradient(135deg, var(--exp-bar), var(--success-green));
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 0 16px rgba(0, 229, 204, 0.6);
  position: relative;
}

.exp-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: expShine 3s ease-in-out infinite;
}

@keyframes expShine {
  0% { left: -100%; }
  50%, 100% { left: 100%; }
}

/* ==========================================
   🎭 動畫效果庫
   ========================================== */

/* 懸停效果 */
.hover-lift {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
  transform: translateY(-2px);
}

.hover-lift-lg {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift-lg:hover {
  transform: translateY(-4px) scale(1.02);
}

/* 脈衝動畫 */
.pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { 
    opacity: 1; 
    transform: scale(1);
  }
  50% { 
    opacity: 0.8; 
    transform: scale(1.05);
  }
}

/* 彈出動畫 */
.popup-enter {
  animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes popIn {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* 滑入動畫 */
.slide-in-up {
  animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInUp {
  from {
    transform: translateY(100%) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* 搖擺動畫 */
.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* 成功動畫 */
.success-bounce {
  animation: successBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes successBounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ==========================================
   📱 響應式工具類
   ========================================== */

/* 隱藏/顯示工具 */
.hidden { display: none !important; }
.visible { display: block !important; }

@media (max-width: 640px) {
  .sm\:hidden { display: none !important; }
  .sm\:visible { display: block !important; }
}

@media (max-width: 768px) {
  .md\:hidden { display: none !important; }
  .md\:visible { display: block !important; }
}

@media (max-width: 1024px) {
  .lg\:hidden { display: none !important; }
  .lg\:visible { display: block !important; }
}

/* 間距工具類 */
.m-0 { margin: 0; }
.m-1 { margin: var(--space-1); }
.m-2 { margin: var(--space-2); }
.m-3 { margin: var(--space-3); }
.m-4 { margin: var(--space-4); }
.m-6 { margin: var(--space-6); }
.m-8 { margin: var(--space-8); }

.p-0 { padding: 0; }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

/* 文字工具類 */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

/* 佈局工具類 */
.flex { display: flex; }
.grid { display: grid; }
.block { display: block; }
.inline-block { display: inline-block; }

.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ==========================================
   🔧 無障礙支援
   ========================================== */

/* 高對比模式 */
@media (prefers-contrast: high) {
  :root {
    --divider: #6B7280;
    --text-secondary: #D1D5DB;
  }
}

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

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

/* 跳過連結 */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-teal);
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: var(--radius-md);
  z-index: 9999;
}

.skip-link:focus {
  top: 6px;
}

/* ==========================================
   🖨️ 列印樣式
   ========================================== */

@media print {
  * {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  .no-print {
    display: none !important;
  }
}

/* ==========================================
   📱 響應式斷點樣式
   ========================================== */

@media (max-width: 640px) {
  .card {
    padding: var(--space-6);
    border-radius: var(--radius-xl);
  }
  
  .btn-primary,
  .btn-secondary,
  .btn-danger {
    min-height: 44px;
    padding: var(--space-3) var(--space-5);
  }
  
  .stat-number {
    font-size: var(--text-2xl);
  }
}

@media (max-width: 768px) {
  body {
    font-size: var(--text-sm);
  }
  
  .user-avatar {
    width: 60px;
    height: 60px;
  }
}

@media (min-width: 1280px) {
  .card:hover {
    transform: translateY(-6px) scale(1.01);
  }
  
  .hover-lift-lg:hover {
    transform: translateY(-6px) scale(1.03);
  }
}