/* ==========================================================================
   教學用抽籤程式 - 核心設計系統 (Design System & Layout)
   專為教室投影機、電子白板、筆電與隨身碟離線使用設計
   ========================================================================== */

:root {
  /* 色彩系統 - 科技現代感 Indigo / Violet / Emerald */
  --bg-primary: #0a0e1a;
  --bg-secondary: #121829;
  --bg-tertiary: #1b233a;
  --bg-card: rgba(23, 31, 53, 0.85);
  --bg-card-hover: rgba(33, 44, 75, 0.95);
  --bg-glass: rgba(18, 24, 41, 0.75);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(99, 102, 241, 0.4);
  --border-glow: rgba(99, 102, 241, 0.6);

  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-highlight: #38bdf8;

  --accent-primary: #6366f1;       /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #ec4899;     /* Pink */
  --accent-emerald: #10b981;       /* Success */
  --accent-amber: #f59e0b;         /* Warning / Gold */
  --accent-rose: #f43f5e;          /* Danger / Absent */
  --accent-cyan: #06b6d4;          /* Cyan / Info */

  --gradient-brand: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --gradient-gold: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #fef08a 100%);
  --gradient-cyber: linear-gradient(135deg, #06b6d4 0%, #3b82f6 50%, #6366f1 100%);
  --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%);

  /* 投影機與白板特化陰影與外光暈 */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --glow-primary: 0 0 25px rgba(99, 102, 241, 0.4);
  --glow-gold: 0 0 35px rgba(245, 158, 11, 0.5);

  /* 圓角 */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* 字體 */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

/* ==========================================================================
   明亮模式色彩系統 (Light Theme for well-lit classrooms)
   ========================================================================== */
body.theme-light {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-hover: rgba(241, 245, 249, 0.98);
  --bg-glass: rgba(255, 255, 255, 0.88);

  --border-color: rgba(0, 0, 0, 0.1);
  --border-hover: rgba(99, 102, 241, 0.5);
  --border-glow: rgba(99, 102, 241, 0.4);

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-highlight: #0284c7;

  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-secondary: #db2777;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --accent-cyan: #0891b2;

  --gradient-brand: linear-gradient(135deg, #4f46e5 0%, #9333ea 50%, #db2777 100%);
  --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.4) 100%);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.12);
  --glow-primary: 0 0 20px rgba(99, 102, 241, 0.25);
  --glow-gold: 0 0 25px rgba(217, 119, 6, 0.3);
}

body.theme-light .app-header {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

body.theme-light .nav-mode-tabs {
  background: rgba(241, 245, 249, 0.9);
  border-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .stats-bar {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

body.theme-light .draw-controls-toolbar {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

body.theme-light .form-select,
body.theme-light .form-input {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}

body.theme-light .form-select option {
  background: #ffffff;
  color: #0f172a;
}

body.theme-light .modal-box {
  background: #ffffff;
  color: #0f172a;
  border-color: #e2e8f0;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2), 0 0 30px rgba(99, 102, 241, 0.1);
}

body.theme-light .modal-title {
  color: #0f172a;
}

body.theme-light .modal-header,
body.theme-light .modal-footer {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-light .btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

body.theme-light .btn-secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
}

body.theme-light .slot-card-box {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border-color: #cbd5e1;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

body.theme-light .slot-name {
  color: #0f172a;
}

body.theme-light .slot-card-box.winner {
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #f59e0b;
}

body.theme-light .slot-card-box.winner .slot-name {
  color: #b45309;
  text-shadow: none;
}

body.theme-light .matrix-grid {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-light .matrix-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

body.theme-light .flash-big-display {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-color: #cbd5e1;
}

body.theme-light .flash-big-name {
  color: #0f172a;
}

body.theme-light .group-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

body.theme-light .group-title {
  color: #0f172a;
}

body.theme-light .member-tag {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #e2e8f0;
}

body.theme-light .mystery-box-card {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border-color: #cbd5e1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

body.theme-light .mystery-box-label {
  color: #0f172a;
}

body.theme-light .mystery-box-card.opened {
  background: #f0fdf4;
  border-color: #86efac;
}

body.theme-light .mystery-box-revealed-topic {
  color: #15803d;
}

body.theme-light .assignment-results-table th {
  background: #f8fafc;
  color: #475569;
}

body.theme-light .assignment-results-table td {
  color: #1e293b;
  border-color: #e2e8f0;
}

body.theme-light .winner-banner-box {
  background: linear-gradient(180deg, #ffffff 0%, #fef3c7 100%);
  border-color: #f59e0b;
}

body.theme-light .winner-person-name {
  color: #0f172a;
  text-shadow: none;
}

body.theme-light .winner-single-card {
  background: #ffffff;
  border-color: #f59e0b;
}

body.theme-light .toast {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  border: 1px solid #e2e8f0;
}

body.theme-light .app-footer {
  border-color: #e2e8f0;
  color: #64748b;
}

body.theme-light .glow-orb-1,
body.theme-light .glow-orb-2 {
  opacity: 0.25;
}


/* 全域重置與基礎樣式 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  user-select: none;
}

/* 背景光暈氛圍特效 */
.app-bg-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.glow-orb-1 {
  position: absolute;
  top: -10%;
  left: 15%;
  width: 50vw;
  height: 50vw;
  max-width: 600px;
  max-height: 600px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0) 70%);
  filter: blur(60px);
}

.glow-orb-2 {
  position: absolute;
  bottom: -10%;
  right: 10%;
  width: 45vw;
  height: 45vw;
  max-width: 550px;
  max-height: 550px;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.12) 0%, rgba(236, 72, 153, 0) 70%);
  filter: blur(60px);
}

/* 主容器排版 */
.app-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 16px 24px;
  max-width: 1600px;
  margin: 0 auto;
}

/* 頂部導航列 (Navbar) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--glow-primary);
  color: #fff;
}

.brand-info h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
  border-radius: var(--radius-full);
  display: inline-block;
  font-weight: 600;
}

/* 模式導航切換 (Nav Tabs) */
.nav-mode-tabs {
  display: flex;
  align-items: center;
  background: rgba(10, 14, 26, 0.6);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 4px;
}

.mode-tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.mode-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.mode-tab-btn.active {
  color: #ffffff;
  background: var(--accent-primary);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
}

.mode-tab-btn .tab-icon {
  font-size: 1.15rem;
}

/* 右側工具操作按鈕群 */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 模式內容區塊 */
.main-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.mode-view {
  display: none;
  flex-direction: column;
  flex: 1;
  animation: fadeInView 0.35s ease-out forwards;
}

.mode-view.active {
  display: flex;
}

@keyframes fadeInView {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 底部狀態列 / 快捷鍵提示 */
.app-footer {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}

.shortcut-hints {
  display: flex;
  align-items: center;
  gap: 16px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kbd-key {
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* 響應式微調 */
@media (max-width: 960px) {
  .app-header {
    flex-wrap: wrap;
    gap: 12px;
  }
  .nav-mode-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}
