/* =============================================
   打字星球 TypingStar - 主要樣式表
   設計風格：可愛、活潑、護眼大字體
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Noto+Sans+TC:wght@400;500;700;900&display=swap');

:root {
  --primary: #FF6B9D;
  --primary-light: #FFB3CC;
  --secondary: #4ECDC4;
  --accent: #FFE66D;
  --purple: #A78BFA;
  --blue: #60A5FA;
  --orange: #FB923C;
  --green: #34D399;
  --red: #F87171;
  --bg: #FFF5F7;
  --bg2: #F0FFFE;
  --card: #FFFFFF;
  --text: #2D3748;
  --text-light: #718096;
  --border: #FFD6E4;
  --shadow: 0 8px 32px rgba(255, 107, 157, 0.15);
  --shadow-card: 0 4px 20px rgba(0,0,0,0.08);
  --radius: 20px;
  --radius-sm: 12px;
  --font-main: 'Noto Sans TC', 'Nunito', sans-serif;
}

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

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 18px;
}

/* === 背景裝飾 === */
body::before {
  content: '';
  position: fixed;
  top: -100px; right: -100px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(255,107,157,0.12) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}
body::after {
  content: '';
  position: fixed;
  bottom: -100px; left: -100px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(78,205,196,0.12) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* === 導航列 === */
.navbar {
  background: linear-gradient(135deg, #FF6B9D 0%, #FF8CC8 50%, #C77DFF 100%);
  padding: 0 2rem;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(255,107,157,0.4);
  position: sticky; top: 0; z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: white;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.navbar-brand .logo-emoji {
  font-size: 2rem;
  animation: bounce 2s infinite;
}

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

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

.navbar-nav a {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 25px;
  font-weight: 700;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.navbar-nav a:hover, .navbar-nav a.active {
  background: rgba(255,255,255,0.25);
  color: white;
  transform: translateY(-2px);
}

.btn-login-nav {
  background: white !important;
  color: var(--primary) !important;
  font-weight: 800 !important;
  box-shadow: 0 3px 12px rgba(0,0,0,0.15);
}

/* === 容器 === */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  position: relative; z-index: 1;
}

.page-content {
  padding: 2.5rem 0;
}

/* === 卡片 === */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 2rem;
  border: 2px solid transparent;
  transition: all 0.3s;
}

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

.card-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* === 按鈕 === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.8rem;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 800;
  font-family: var(--font-main);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #C77DFF);
  color: white;
  box-shadow: 0 4px 15px rgba(255,107,157,0.4);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(255,107,157,0.6); transform: translateY(-2px); }

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary), #38B2AC);
  color: white;
  box-shadow: 0 4px 15px rgba(78,205,196,0.4);
}
.btn-secondary:hover { box-shadow: 0 6px 20px rgba(78,205,196,0.6); transform: translateY(-2px); }

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #FFB347);
  color: var(--text);
  box-shadow: 0 4px 15px rgba(255,230,109,0.5);
}

.btn-danger {
  background: linear-gradient(135deg, var(--red), #E53E3E);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 2.5px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }

.btn-sm { padding: 0.45rem 1.1rem; font-size: 0.88rem; }
.btn-lg { padding: 1rem 2.5rem; font-size: 1.15rem; }
.btn-xl { padding: 1.2rem 3rem; font-size: 1.3rem; }

/* === 表單 === */
.form-group { margin-bottom: 1.5rem; }

.form-label {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.form-control {
  width: 100%;
  padding: 0.9rem 1.2rem;
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font-main);
  color: var(--text);
  background: white;
  transition: all 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255,107,157,0.15);
}

select.form-control { cursor: pointer; }

textarea.form-control {
  resize: vertical;
  min-height: 120px;
  line-height: 1.7;
}

/* === 標籤/徽章 === */
.badge {
  display: inline-block;
  padding: 0.25rem 0.8rem;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 800;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-secondary { background: rgba(78,205,196,0.2); color: #2C7A7B; }
.badge-easy { background: rgba(52,211,153,0.2); color: #065F46; }
.badge-medium { background: rgba(251,191,36,0.2); color: #92400E; }
.badge-hard { background: rgba(248,113,113,0.2); color: #991B1B; }
.badge-exam { background: rgba(167,139,250,0.2); color: #5B21B6; }

/* === 網格系統 === */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* === 頁面標題 === */
.page-header {
  text-align: center;
  padding: 2rem 0 1.5rem;
}

.page-title {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.page-subtitle {
  font-size: 1.1rem;
  color: var(--text-light);
  font-weight: 600;
}

/* === 統計方塊 === */
.stat-box {
  background: white;
  border-radius: var(--radius-sm);
  padding: 1.2rem;
  text-align: center;
  border: 2px solid var(--border);
}

.stat-num {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-light);
  margin-top: 0.3rem;
}

/* === 打字練習介面 === */
.typing-container {
  max-width: 900px;
  margin: 0 auto;
}

.typing-stats-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr) auto;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
  background: white;
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-card);
  border: 2px solid var(--border);
}

.typing-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.typing-stat-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: white;
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.typing-stat-value {
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1.1;
}

.stat-time .typing-stat-label { background: var(--blue); }
.stat-time .typing-stat-value { color: var(--orange); }
.stat-correct .typing-stat-label { background: var(--green); }
.stat-correct .typing-stat-value { color: var(--green); }
.stat-wrong .typing-stat-label { background: var(--red); }
.stat-wrong .typing-stat-value { color: var(--red); }
.stat-untyped .typing-stat-label { background: var(--text-light); }
.stat-untyped .typing-stat-value { color: var(--text-light); }
.stat-speed .typing-stat-label { background: var(--purple); }
.stat-speed .typing-stat-value { color: var(--purple); }

.typing-hint {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* 準備區 */
.prep-area {
  background: linear-gradient(135deg, #E9D5FF, #D8B4FE);
  border: 3px dashed var(--purple);
  border-radius: var(--radius-sm);
  padding: 1rem 1.4rem;
  margin-bottom: 1.2rem;
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 600;
}

.prep-area input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1.1rem;
  font-family: var(--font-main);
  color: var(--text);
  font-weight: 600;
}

/* 打字區域 */
.typing-area {
  background: linear-gradient(135deg, #FFFDE7, #FFF9C4);
  border: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.typing-area::before {
  content: '✨';
  position: absolute;
  top: 10px; right: 15px;
  font-size: 1.5rem;
  opacity: 0.3;
}

.text-line-group {
  margin-bottom: 1.5rem;
}

.text-line-display {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.7rem;
  line-height: 1.6;
  letter-spacing: 2px;
}

.text-line-display .char-correct { color: var(--green); }
.text-line-display .char-wrong {
  color: var(--red);
  background: rgba(248,113,113,0.15);
  border-radius: 3px;
  text-decoration: underline;
}
.text-line-display .char-current {
  background: var(--primary-light);
  border-radius: 4px;
  padding: 0 2px;
  animation: blink 1s infinite;
}
.text-line-display .char-untyped { color: var(--text-light); }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.typing-input {
  width: 100%;
  border: 2.5px dashed var(--accent);
  background: rgba(255,255,255,0.7);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.2rem;
  font-size: 1.4rem;
  font-family: var(--font-main);
  font-weight: 700;
  color: var(--text);
  outline: none;
  transition: all 0.2s;
  letter-spacing: 2px;
}

.typing-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255,107,157,0.15);
  background: white;
}

.typing-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
}

/* 結果彈窗 */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: white;
  border-radius: 28px;
  padding: 2.5rem;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(255,107,157,0.3);
  animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
}

.modal-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--primary), var(--purple), var(--secondary));
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(50px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-emoji { font-size: 4rem; margin-bottom: 0.5rem; }
.result-title { font-size: 2rem; font-weight: 900; color: var(--primary); margin-bottom: 1.5rem; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.result-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.result-item-val { font-size: 2rem; font-weight: 900; color: var(--primary); }
.result-item-label { font-size: 0.85rem; font-weight: 700; color: var(--text-light); }

/* === 文字列表 === */
.text-list { display: flex; flex-direction: column; gap: 1rem; }

.text-list-item {
  background: white;
  border-radius: var(--radius-sm);
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 2px solid var(--border);
  transition: all 0.2s;
  cursor: pointer;
}

.text-list-item:hover {
  border-color: var(--primary);
  transform: translateX(5px);
  box-shadow: var(--shadow-card);
}

.text-list-item .text-icon {
  font-size: 2rem;
  width: 55px;
  height: 55px;
  background: linear-gradient(135deg, var(--primary-light), #E9D5FF);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.text-list-item .text-info { flex: 1; }
.text-list-item .text-title { font-size: 1.1rem; font-weight: 800; }
.text-list-item .text-meta { font-size: 0.85rem; color: var(--text-light); margin-top: 0.3rem; display: flex; gap: 0.8rem; align-items: center; }

/* === 表格 === */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-sm); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

thead th {
  background: linear-gradient(135deg, var(--primary), #C77DFF);
  color: white;
  padding: 1rem 1.2rem;
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
}

thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

tbody tr:hover { background: #FFF5F7; }

tbody td {
  padding: 1rem 1.2rem;
  font-weight: 600;
}

/* === 登入/註冊頁 === */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FFF5F7 0%, #F0FFFE 50%, #F5F0FF 100%);
  padding: 2rem;
}

.auth-card {
  background: white;
  border-radius: 28px;
  padding: 3rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(255,107,157,0.2);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--primary), var(--purple), var(--secondary));
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo .emoji { font-size: 3.5rem; }
.auth-logo h1 { font-size: 1.8rem; font-weight: 900; color: var(--primary); }

/* === 響應式 === */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .typing-stats-bar { grid-template-columns: repeat(3, 1fr); }
  .page-title { font-size: 1.8rem; }
  .text-line-display { font-size: 1.4rem; }
  .typing-input { font-size: 1.1rem; }
  .navbar { padding: 0 1rem; }
  .typing-stat-value { font-size: 2rem; }
}

/* === 後台樣式 === */
.admin-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: calc(100vh - 70px);
}

.admin-sidebar {
  background: linear-gradient(180deg, #2D3748 0%, #1A202C 100%);
  padding: 1.5rem 0;
}

.admin-sidebar .sidebar-title {
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0 1.5rem;
  margin-bottom: 0.5rem;
}

.admin-sidebar .sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1.5rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.admin-sidebar .sidebar-link:hover,
.admin-sidebar .sidebar-link.active {
  background: rgba(255,107,157,0.15);
  color: var(--primary-light);
  padding-left: 2rem;
}

.admin-content { padding: 2rem; background: #F7FAFC; }

/* === 動畫 === */
.floating {
  animation: floating 3s ease-in-out infinite;
}
@keyframes floating {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.pulse-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* 訊息提示 */
.alert {
  padding: 1rem 1.3rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.alert-success { background: rgba(52,211,153,0.15); color: #065F46; border: 1.5px solid rgba(52,211,153,0.4); }
.alert-error { background: rgba(248,113,113,0.15); color: #991B1B; border: 1.5px solid rgba(248,113,113,0.4); }
.alert-info { background: rgba(96,165,250,0.15); color: #1E40AF; border: 1.5px solid rgba(96,165,250,0.4); }
