/* 全局樣式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 全局變數 */
:root {
  --primary-color: #00d4ff;
  --primary-dark: #0099cc;
  --secondary-color: #1a1a2e;
  --accent-color: #ff6b6b;
  --success-color: #4ecdc4;
  --warning-color: #ffe66d;
  --error-color: #ff6b6b;
  --text-primary: #ffffff;
  --text-secondary: #b8c5d6;
  --bg-primary: rgba(26, 26, 46, 0.9);
  --bg-secondary: rgba(255, 255, 255, 0.05);
  --bg-dark: #0f0f23;
  --border-color: rgba(0, 212, 255, 0.3);
  --shadow-light: 0 4px 20px rgba(0, 212, 255, 0.2);
  --shadow-medium: 0 8px 30px rgba(0, 212, 255, 0.3);
  --shadow-heavy: 0 15px 50px rgba(0, 212, 255, 0.4);
  --border-radius: 16px;
  --border-radius-small: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --neon-glow: 0 0 20px rgba(0, 212, 255, 0.5);
}

/* 基礎樣式 */
body {
  font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 25%, #16213e 50%, #0f3460 75%, #533483 100%);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 16px;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 80%, rgba(0, 212, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 107, 107, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(78, 205, 196, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 標題區域 */
.header {
  text-align: center;
  margin-bottom: 40px;
  background: var(--bg-primary);
  backdrop-filter: blur(20px);
  border-radius: var(--border-radius);
  padding: 40px;
  box-shadow: var(--shadow-medium);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.1), transparent);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.header h1 {
  font-size: 2.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 15px;
  text-shadow: 0 0 30px rgba(0, 212, 255, 0.5);
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  text-align: center;
  width: 100%;
}

.header h1 i {
  color: var(--accent-color);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

.subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  font-weight: 400;
  position: relative;
  z-index: 1;
}

/* 主要內容區域 */
.main-content {
  flex: 1;
  background: var(--bg-primary);
  backdrop-filter: blur(20px);
  border-radius: var(--border-radius);
  padding: 40px;
  box-shadow: var(--shadow-medium);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
  position: relative;
}

.main-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    linear-gradient(45deg, transparent 30%, rgba(0, 212, 255, 0.05) 50%, transparent 70%);
  border-radius: var(--border-radius);
  pointer-events: none;
}

/* 表單樣式 */
.calculator-form {
  display: flex;
  flex-direction: column;
  gap: 30px;
  position: relative;
  z-index: 1;
}

.form-section {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 35px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.form-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color), var(--success-color));
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.form-section:hover::before {
  transform: scaleX(1);
}

.form-section:hover {
  box-shadow: var(--shadow-light);
  transform: translateY(-3px);
  border-color: var(--primary-color);
}

.form-section h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 25px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.form-section h2 i {
  color: var(--accent-color);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
}

.form-group {
  margin-bottom: 25px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 25px;
}

.form-group label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  font-size: 1rem;
  text-shadow: 0 0 5px rgba(0, 212, 255, 0.3);
}

.required {
  color: var(--accent-color);
  font-weight: 700;
  text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.form-group small {
  display: block;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 8px;
  font-style: italic;
}

/* 輸入框樣式 */
.form-group input,
.form-group select {
  width: 100%;
  padding: 15px 20px;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-small);
  font-size: 1rem;
  transition: var(--transition);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  backdrop-filter: blur(10px);
}

.form-group select {
  color: #000000;
  background: rgba(255, 255, 255, 0.9);
}

.form-group select option {
  color: #000000;
  background: #ffffff;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: var(--neon-glow);
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.1);
}

.form-group input:hover,
.form-group select:hover {
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.form-group input::placeholder {
  color: var(--text-secondary);
}

/* 單選按鈕樣式 */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.radio-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 15px;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-small);
  transition: var(--transition);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
}

.radio-label:hover {
  border-color: var(--primary-color);
  background: rgba(0, 212, 255, 0.1);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-custom {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  margin-right: 15px;
  position: relative;
  transition: var(--transition);
}

.radio-label input[type="radio"]:checked + .radio-custom {
  border-color: var(--primary-color);
  background: var(--primary-color);
  box-shadow: var(--neon-glow);
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.radio-label input[type="radio"]:checked ~ span {
  color: var(--primary-color);
  font-weight: 600;
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

/* 目標提示樣式 */
.goal-hint {
  display: block;
  margin-top: 10px;
  padding: 15px;
  background: linear-gradient(135deg, var(--warning-color), var(--accent-color));
  color: var(--bg-dark);
  border-radius: var(--border-radius-small);
  font-weight: 600;
  text-align: center;
  animation: pulse 2s infinite;
  box-shadow: 0 0 20px rgba(255, 230, 109, 0.3);
}

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

/* 按鈕樣式 */
.form-actions {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 30px;
}

.btn-calculate,
.btn-reset {
  padding: 18px 35px;
  border: none;
  border-radius: var(--border-radius-small);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.btn-calculate {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  box-shadow: var(--shadow-light);
}

.btn-calculate::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-calculate:hover::before {
  left: 100%;
}

.btn-calculate:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-medium);
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
}

.btn-reset {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 2px solid var(--border-color);
}

.btn-reset:hover {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
}

/* 結果區域樣式 */
.results-section {
  margin-top: 40px;
  padding: 35px;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(255, 107, 107, 0.1));
  border-radius: var(--border-radius);
  color: var(--text-primary);
  box-shadow: var(--shadow-medium);
  display: none;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}

.results-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 80%, rgba(0, 212, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 107, 107, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.results-section.show {
  display: block;
  animation: slideIn 0.6s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.results-title h3 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.btn-save {
  padding: 12px 25px;
  background: linear-gradient(135deg, var(--success-color), #2dd4bf);
  color: white;
  border: none;
  border-radius: var(--border-radius-small);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-save:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(78, 205, 196, 0.4);
}

.results-grid {
  position: relative;
  z-index: 1;
}

.results-section p {
  margin-bottom: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-small);
  backdrop-filter: blur(10px);
  border-left: 4px solid var(--primary-color);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.results-section p::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.05), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

.results-section p:hover::before {
  transform: translateX(100%);
}

.results-section p:hover {
  transform: translateX(5px);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
}

.results-section .highlight {
  color: var(--warning-color);
  font-weight: 700;
  text-shadow: 0 0 10px rgba(255, 230, 109, 0.5);
}

.calorie-warning {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.1), rgba(255, 230, 109, 0.1));
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: var(--border-radius-small);
  padding: 15px 20px;
  margin: 15px 0;
  color: #ffe66d;
  font-weight: 500;
  position: relative;
  overflow: hidden;
  animation: warningPulse 2s ease-in-out infinite;
}

.calorie-warning::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 230, 109, 0.2), transparent);
  animation: warningShimmer 3s infinite;
}

.calorie-warning i {
  color: #ff6b6b;
  margin-right: 8px;
  animation: warningIcon 1.5s ease-in-out infinite;
}

@keyframes warningPulse {
  0%, 100% { 
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.3);
  }
  50% { 
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
  }
}

@keyframes warningShimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

@keyframes warningIcon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.results-section .progress-timeline {
  margin-top: 30px;
  padding: 25px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-small);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
}

.progress-timeline h4 {
  margin-bottom: 20px;
  color: var(--primary-color);
  font-size: 1.3rem;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.progress-stage {
  margin-bottom: 15px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--border-radius-small);
  border-left: 4px solid var(--success-color);
  transition: var(--transition);
}

.progress-stage:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(5px);
}

/* 頁腳樣式 */
.footer {
  text-align: center;
  padding: 25px;
  background: var(--bg-primary);
  backdrop-filter: blur(20px);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  border: 1px solid var(--border-color);
}

.footer p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.footer i {
  color: var(--primary-color);
  animation: pulse 2s infinite;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }
  
  .main-content {
    padding: 25px;
  }
  
  .header h1 {
    font-size: 2.2rem;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .btn-calculate,
  .btn-reset {
    width: 100%;
    justify-content: center;
  }
  
  .form-section {
    padding: 25px;
  }
  
  .results-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 25px;
  }
  
  .header h1 {
    font-size: 2rem;
  }
  
  .main-content {
    padding: 20px;
  }
  
  .form-section {
    padding: 20px;
  }
}

/* 載入動畫 */
.loading {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

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

/* 錯誤狀態 */
.form-group.error input,
.form-group.error select {
  border-color: var(--error-color);
  box-shadow: 0 0 15px rgba(255, 107, 107, 0.3);
}

.error-message {
  color: var(--error-color);
  font-size: 0.9rem;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-shadow: 0 0 10px rgba(255, 107, 107, 0.3);
}

/* 成功狀態 */
.form-group.success input,
.form-group.success select {
  border-color: var(--success-color);
  box-shadow: 0 0 15px rgba(78, 205, 196, 0.3);
}

/* 工具提示 */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 200px;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  text-align: center;
  border-radius: 8px;
  padding: 10px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}
