/**
 * Main CSS - 客製化樣式
 * 處理 Tailwind 無法覆蓋的特效與動畫
 */

:root {
  --primary-navy: #0F172A;
  --accent-gold: #D97706;
  --bg-light: #F1F5F9;
}

* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Noto Sans TC', sans-serif;
  background-color: var(--bg-light);
  padding-bottom: 90px;
}

/* ==================== Google 登入按鈕 ==================== */
.google-btn {
  display: flex;
  align-items: center;
  background-color: white;
  border: 1px solid #dadce0;
  border-radius: 20px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  transition: background-color .3s, box-shadow .3s;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  font-size: 13px;
  color: #3c4043;
}

.google-btn:hover {
  background-color: #f7fafe;
  border-color: #d2e3fc;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3);
}

.google-icon {
  width: 20px;
  height: 20px;
  margin-right: 8px;
}

/* ==================== 分頁切換動畫 ==================== */
.view-section {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== 導航列 Active 狀態 ==================== */
.nav-item {
  transition: all 0.2s ease;
}

.nav-item.active {
  color: var(--accent-gold);
  font-weight: 700;
}

.nav-item.active svg {
  fill: currentColor;
}

/* ==================== 快速情境按鈕 ==================== */
.quick-btn {
  text-align: left;
  transition: all 0.2s;
}

.quick-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border-color: #D97706;
}

.quick-btn:active {
  transform: translateY(0);
}

/* ==================== Toast 通知 ==================== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translate(-50%, -20px);
  padding: 12px 24px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.toast-success {
  background-color: #10b981;
}

.toast-error {
  background-color: #ef4444;
}

.toast-warning {
  background-color: #f59e0b;
}

/* ==================== Modal 彈窗 ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background-color: white;
  width: 100%;
  max-width: 28rem;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  transform: scale(1);
  transition: transform 0.3s ease;
  margin: auto;
}

@media (max-width: 640px) {
  .modal-content {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    margin: 0;
  }
}

/* ==================== 知識卡片 Hover ==================== */
.knowledge-card {
  transition: all 0.2s ease;
  cursor: pointer;
}

.knowledge-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ==================== 捲軸美化 ==================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==================== 響應式修正 ==================== */
@media (min-width: 1024px) {
  nav {
    display: none !important;
  }
  
  body {
    padding-bottom: 40px;
  }
}

/* 桌面版顯示導航 (臨時方案) */
@media (min-width: 1024px) {
  .view-section {
    min-height: 400px;
  }
}

/* ==================== 表單元素美化 ==================== */
select:focus,
textarea:focus,
input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ==================== 載入動畫 ==================== */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

.animate-pulse {
  animation: pulse 2s infinite;
}

/* ==================== 按鈕按壓效果 ==================== */
button:active {
  transform: scale(0.98);
}

/* ==================== 漸層背景動畫 ==================== */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.bg-gradient-animated {
  background-size: 200% 200%;
  animation: gradientShift 15s ease infinite;
}

/* ==================== 卡片陰影層次 ==================== */
.card-shadow {
  box-shadow: 
    0 1px 3px 0 rgba(0, 0, 0, 0.1),
    0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.card-shadow-lg {
  box-shadow: 
    0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ==================== 文字選取顏色 ==================== */
::selection {
  background-color: #fbbf24;
  color: #1f2937;
}

/* ==================== 防止文字被選取 (特定元素) ==================== */
.nav-item,
.quick-btn,
.knowledge-card {
  user-select: none;
  -webkit-user-select: none;
}

/* ==================== Safe Area (iOS) ==================== */
@supports (padding: env(safe-area-inset-bottom)) {
  nav {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}

/* ==================== 載入骨架屏 ==================== */
.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ==================== 打字機效果 (備用) ==================== */
@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

.typewriter {
  overflow: hidden;
  white-space: nowrap;
  animation: typing 3s steps(40, end);
}

/* ==================== 淡入淡出通用 ==================== */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

.fade-out {
  animation: fadeOut 0.5s ease-out;
}

.animate-fadeIn {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ==================== Toggle Switch (趕時間模式) ==================== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #D97706;
}

input:checked + .slider:before {
  transform: translateX(20px);
}