/* public/index.css */

:root {
  /* HSL 顏色系統 */
  --primary: 220 90% 60%;      /* #3b82f6 - 活潑天藍 */
  --primary-hover: 220 90% 50%;
  --secondary: 200 12% 45%;    /* 莫蘭迪灰 */
  --success: 142 70% 45%;      /* #22c55e - 薄荷綠 */
  --warning: 38 92% 50%;       /* #f59e0b - 芒果黃 */
  --danger: 350 89% 60%;       /* #ef4444 - 珊瑚紅 */
  --text-main: 220 23% 16%;    /* 深藍灰，非死黑 */
  --text-muted: 220 9% 45%;
  --border-color: 220 13% 91%;
  
  /* 字型 */
  --font-family: 'Fredoka', 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  
  /* 陰影與圓角 */
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 30px rgba(31, 38, 135, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.1);
  
  /* 漸層背景 */
  --bg-gradient: linear-gradient(135deg, #eef2f7 0%, #e0e6ed 100%);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.4);
}

/* 全域重設 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: hsl(var(--text-main));
  min-height: 100vh;
  overflow-x: hidden;
}

/* 應用程式容器 */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* 側邊導覽列 */
.sidebar {
  width: 260px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.02);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 35px;
  padding-left: 8px;
}

.logo-emoji {
  font-size: 32px;
}

.logo-title {
  font-size: 22px;
  font-weight: 700;
  color: hsl(var(--primary));
  letter-spacing: 1px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 600;
  color: hsl(var(--text-muted));
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: left;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.6);
  color: hsl(var(--text-main));
  transform: translateX(4px);
}

.nav-btn.active {
  background: hsl(var(--primary));
  color: white;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

.nav-icon {
  width: 20px;
  height: 20px;
  transition: transform 0.25s ease;
}

.nav-btn.active .nav-icon {
  transform: scale(1.1);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* 同步狀態指示燈 */
.sync-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.03);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background 0.3s;
}

.sync-status.online .status-dot {
  background: hsl(var(--success));
  box-shadow: 0 0 8px hsl(var(--success) / 0.5);
}

.sync-status.offline .status-dot {
  background: hsl(var(--danger));
  box-shadow: 0 0 8px hsl(var(--danger) / 0.5);
}

.sync-status.syncing .status-dot {
  background: hsl(var(--warning));
  box-shadow: 0 0 8px hsl(var(--warning) / 0.5);
  animation: pulse 1s infinite alternate;
}

/* 主要內容區 */
.main-content {
  flex: 1;
  padding: 40px;
  margin-left: 260px;
  max-width: 1200px;
  width: calc(100% - 260px);
}

.mobile-header {
  display: none;
}

/* Glassmorphism 卡片樣式 */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(15px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  transition: transform 0.3s, box-shadow 0.3s;
}

.glass-card:hover {
  box-shadow: var(--shadow-lg);
}

.title-card {
  border-left: 6px solid hsl(var(--primary));
}

.title-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  color: hsl(var(--text-main));
}

.title-card p {
  color: hsl(var(--text-muted));
  font-size: 14px;
}

/* Tab 顯示/隱藏 */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.4s ease-out;
}

/* 按鈕樣式 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: hsl(var(--primary));
  color: white;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover {
  background: hsl(var(--primary-hover));
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.35);
}

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

.btn-secondary {
  background: white;
  color: hsl(var(--text-main));
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: #f8fafc;
  transform: translateY(-2px);
}

.btn-danger {
  background: hsl(var(--danger));
  color: white;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: hsl(var(--danger) / 0.9);
  transform: translateY(-2px);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ==========================================================================
   TAB 1: 隨機抽籤 (Lucky Picker)
   ========================================================================== */
.picker-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.picker-visual-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.lottery-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}

/* 拉霸機樣式 */
.slot-machine {
  width: 100%;
  max-width: 450px;
  height: 140px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 6px solid #ffd43b;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 25px rgba(0,0,0,0.2), inset 0 2px 10px rgba(0,0,0,0.5);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-window {
  width: 85%;
  height: 90px;
  background: white;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 5px 15px rgba(0,0,0,0.15);
}

.slot-reel {
  display: flex;
  flex-direction: column;
  position: absolute;
  width: 100%;
  top: 0;
  left: 0;
  transition: transform 0.1s ease-out;
}

.slot-item {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
  color: #1e293b;
  text-shadow: 0 2px 4px rgba(0,0,0,0.05);
  text-align: center;
  padding: 0 20px;
}

.slot-pointer {
  position: absolute;
  right: -5px;
  font-size: 24px;
  color: #ffd43b;
  z-index: 10;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.picker-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  width: 100%;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--text-muted));
}

/* Switch 滑桿切換鈕 */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.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: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
}

input:checked + .slider {
  background-color: hsl(var(--primary));
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* 抽籤歷程側欄 */
.picker-sidebar-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: hsl(var(--text-main));
}

.picker-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 15px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-val {
  font-size: 24px;
  font-weight: 700;
  color: hsl(var(--primary));
}

.stat-lbl {
  font-size: 12px;
  color: hsl(var(--text-muted));
}

.drawn-list-container {
  height: 200px;
  overflow-y: auto;
  border: 1px solid hsl(var(--border-color));
  border-radius: var(--radius-md);
  padding: 10px;
  background: rgba(255, 255, 255, 0.4);
}

.drawn-list {
  list-style: none;
}

.drawn-list li {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideIn 0.2s ease-out;
}

.drawn-list li:last-child {
  border-bottom: none;
}

.drawn-list .index {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: hsl(var(--text-muted));
  margin-right: 8px;
}

.drawn-list .empty-msg {
  color: hsl(var(--text-muted));
  text-align: center;
  border: none;
  display: block;
  padding-top: 80px;
}

/* ==========================================================================
   TAB 2: 小組計分板 (Scoreboard)
   ========================================================================== */
.scoreboard-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.team-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  transition: transform 0.2s, box-shadow 0.2s;
}

.team-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.team-header-stripe {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
}

.team-delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.3;
  transition: opacity 0.2s;
}

.team-card:hover .team-delete-btn {
  opacity: 0.7;
}

.team-delete-btn:hover {
  opacity: 1 !important;
  color: hsl(var(--danger));
}

.team-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  margin-top: 10px;
  border: none;
  text-align: center;
  width: 90%;
  font-family: var(--font-family);
  background: transparent;
}

.team-name:focus {
  outline: none;
  background: #f8fafc;
  border-radius: 4px;
}

.team-score {
  font-size: 48px;
  font-weight: 900;
  margin-bottom: 20px;
  transition: transform 0.1s ease;
}

.score-controls {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn-score-adjust {
  flex: 1;
  height: 42px;
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

.btn-score-add {
  background: #e6fcf5;
  color: #0ca678;
}

.btn-score-add:hover {
  background: #c3fae8;
  transform: scale(1.05);
}

.btn-score-sub {
  background: #fff5f5;
  color: #f03e3e;
}

.btn-score-sub:hover {
  background: #ffe3e3;
  transform: scale(1.05);
}

/* 加分時震動與動畫 */
@keyframes pop-score {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); color: hsl(var(--success)); }
  100% { transform: scale(1); }
}

.pop-animation {
  animation: pop-score 0.3s ease-out;
}

/* ==========================================================================
   TAB 3: 課堂計時器 (Timer)
   ========================================================================== */
.timer-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 24px;
}

.timer-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.timer-display-container {
  position: relative;
  width: 250px;
  height: 250px;
  margin-bottom: 30px;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: rgba(0, 0, 0, 0.04);
  stroke-width: 6px;
}

.timer-progress {
  fill: none;
  stroke: hsl(var(--primary));
  stroke-width: 6px;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 44px;
  font-weight: 700;
  color: hsl(var(--text-main));
  letter-spacing: 1px;
}

.timer-buttons {
  display: flex;
  gap: 15px;
  width: 100%;
  max-width: 400px;
}

.timer-buttons .btn {
  flex: 1;
}

.timer-presets {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.preset-btn {
  padding: 12px;
  font-size: 14px;
}

.custom-timer-input {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.custom-timer-input input {
  width: 60px;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 14px;
  text-align: center;
  font-family: var(--font-family);
}

.custom-timer-input label {
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--text-muted));
}

/* ==========================================================================
   TAB 4: 隨機分組器 (Random Group Maker)
   ========================================================================== */
.grouper-layout {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
}

.grouper-config {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: hsl(var(--text-main));
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-group label {
  font-weight: 500;
  color: hsl(var(--text-muted));
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.grouper-config input[type="number"] {
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
}

.grouper-result {
  min-height: 300px;
}

.groups-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.group-box {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.group-box h4 {
  font-size: 15px;
  font-weight: 700;
  color: hsl(var(--primary));
  margin-bottom: 10px;
  border-bottom: 2px solid rgba(59, 130, 246, 0.1);
  padding-bottom: 6px;
}

.group-members {
  list-style: none;
}

.group-members li {
  padding: 4px 0;
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--text-main));
}

/* ==========================================================================
   TAB 5: 互動音效板 (Soundboard)
   ========================================================================== */
.soundboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.sound-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  transition: transform 0.2s, box-shadow 0.2s;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.4);
}

.sound-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
  border-color: hsl(var(--primary) / 0.3);
}

.sound-card:active {
  transform: scale(0.98);
}

.sound-emoji {
  font-size: 40px;
  margin-bottom: 12px;
}

.sound-name {
  font-size: 15px;
  font-weight: 700;
  color: hsl(var(--text-main));
}

/* ==========================================================================
   TAB 6: 雲端與名單設定 (Settings)
   ========================================================================== */
.settings-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.settings-layout input[type="text"],
.settings-layout textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 14px;
  background: white;
}

.settings-layout textarea {
  resize: vertical;
}

.help-text {
  font-size: 12px;
  color: hsl(var(--text-muted));
  margin-top: 4px;
}

.settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.settings-actions .btn {
  flex: 1;
}

.connection-result-box {
  margin-top: 15px;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
}

.connection-result-box.success {
  background: #e6fcf5;
  color: #0ca678;
  border: 1px solid #c3fae8;
}

.connection-result-box.error {
  background: #fff5f5;
  color: #f03e3e;
  border: 1px solid #ffe3e3;
}

/* ==========================================================================
   全域提示 (Toast) 與 動態效果
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: white;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.empty-msg {
  color: hsl(var(--text-muted));
  font-size: 14px;
  text-align: center;
  grid-column: 1 / -1;
  padding: 40px 0;
}

/* 動畫細節 */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-15px); }
  to { opacity: 1; transform: translateX(0); }
}

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

/* ==========================================================================
   響應式設計 (RWD)
   ========================================================================== */
@media (max-width: 992px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    position: relative;
    padding: 15px 20px;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  
  .sidebar-header {
    margin-bottom: 15px;
  }
  
  .nav-menu {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .nav-btn {
    padding: 10px 14px;
    font-size: 13px;
    width: auto;
  }
  
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 20px;
  }
  
  .picker-layout,
  .timer-layout,
  .grouper-layout,
  .settings-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

@media (max-width: 600px) {
  .nav-menu {
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    flex-wrap: nowrap;
    padding-bottom: 8px;
  }
  
  .nav-btn {
    flex-shrink: 0;
  }
}

/* ==========================================================================
   TAB 7: 趣味音量計 (Noise Meter)
   ========================================================================== */
.noise-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 24px;
}

.noise-main {
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.noise-unauthorized-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.noise-large-emoji {
  font-size: 80px;
  animation: pulse 1.5s infinite alternate;
}

.noise-unauthorized-box p {
  font-size: 16px;
  font-weight: 600;
  color: hsl(var(--text-muted));
}

.noise-monitor-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  padding: 10px 0;
}

.noise-status-header {
  display: flex;
  align-items: center;
  gap: 24px;
  background: white;
  padding: 20px 30px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 500px;
}

.noise-emoji-display {
  font-size: 64px;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.noise-status-info h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
  color: hsl(var(--text-main));
}

.noise-status-info p {
  font-size: 14px;
  color: hsl(var(--text-muted));
  font-weight: 500;
}

/* 音量指示條 */
.noise-meter-container {
  width: 100%;
  max-width: 500px;
}

.noise-meter-bg {
  width: 100%;
  height: 28px;
  background: #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.08);
}

.noise-meter-bar {
  height: 100%;
  background: linear-gradient(90deg, #22c55e 0%, #eab308 60%, #ef4444 90%);
  border-radius: 14px;
  transition: width 0.1s ease-out;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

.noise-threshold-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: #1e293b;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
  z-index: 10;
}

.noise-threshold-marker::after {
  content: "⚠️";
  position: absolute;
  top: -20px;
  left: -8px;
  font-size: 12px;
}

.noise-meter-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: hsl(var(--text-muted));
}

.noise-wave-canvas {
  width: 100%;
  max-width: 500px;
  height: 200px;
  background: #000000;
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.08), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.noise-config {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 全域警示紅閃光效果 */
@keyframes flash-red {
  0% { box-shadow: inset 0 0 0px rgba(239, 68, 68, 0); }
  50% { box-shadow: inset 0 0 80px rgba(239, 68, 68, 0.25); background-color: rgba(239, 68, 68, 0.02); }
  100% { box-shadow: inset 0 0 0px rgba(239, 68, 68, 0); }
}

.flash-alert {
  animation: flash-red 0.5s infinite;
}

/* 開關的容器樣式 */
.switch-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--text-muted));
  cursor: pointer;
}

.switch-container input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

@media (max-width: 992px) {
  .noise-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* ==========================================================================
   段考成績單系統樣式
   ========================================================================== */

.report-card-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1200px) {
  .report-card-layout {
    grid-template-columns: 1fr;
  }
}

.report-card-editor {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.editor-header, .preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.editor-actions, .preview-actions {
  display: flex;
  gap: 8px;
}

.table-scroll-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.report-table th, .report-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.report-table th {
  background: rgba(0, 0, 0, 0.02);
  font-weight: 600;
  color: hsl(var(--text-main));
}

.report-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.01);
}

.report-input-score {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s;
}

.report-input-score:focus {
  border-color: hsl(var(--primary));
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.report-input-comment {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all 0.2s;
}

.report-input-comment:focus {
  border-color: hsl(var(--primary));
  outline: none;
}

.select-attitude {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background-color: #ffffff;
}

.report-card-preview-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.select-student-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select-preview {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  background-color: #ffffff;
}

/* 成績單 A4 模擬紙張樣式 */
.paper-preview-container {
  width: 100%;
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  justify-content: center;
  overflow: hidden;
  border: 1px dashed rgba(0, 0, 0, 0.08);
}

.report-card-paper {
  width: 100%;
  max-width: 595px; /* A4 比例 */
  min-height: 800px;
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 30px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 20px;
  color: #1e293b;
  position: relative;
}

.empty-preview-msg {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 300px;
  color: hsl(var(--text-muted));
  font-size: 15px;
  font-weight: 500;
}

/* 紙張成績單內部元素樣式 */
.paper-header {
  text-align: center;
  border-bottom: 2px double #475569;
  padding-bottom: 10px;
}

.paper-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #0f172a;
  margin: 0 0 5px 0;
}

.paper-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin: 0;
}

.paper-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  font-size: 13px;
  font-weight: 600;
  background: #f8fafc;
  padding: 10px 15px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.paper-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 10px;
}

.paper-table th, .paper-table td {
  border: 1px solid #94a3b8;
  padding: 8px 10px;
  text-align: center;
}

.paper-table th {
  background: #f1f5f9;
  font-weight: 700;
}

.paper-chart-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 5px 0;
  padding: 15px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.paper-chart-title {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 5px;
}

.paper-comment-box {
  border: 1px solid #94a3b8;
  border-radius: 4px;
  padding: 12px 15px;
  min-height: 80px;
  font-size: 13px;
  line-height: 1.6;
}

.paper-comment-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: #334155;
  border-bottom: 1px dashed #cbd5e1;
  padding-bottom: 4px;
  text-align: left;
}

.paper-comment-text {
  text-align: left;
  min-height: 40px;
  color: #1e293b;
}

.paper-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-top: auto;
  padding-top: 30px;
  font-size: 13px;
  font-weight: 700;
}

.signature-line {
  border-bottom: 1px solid #64748b;
  height: 35px;
  margin-top: 5px;
}

/* ==========================================================================
   列印媒體樣式規則
   ========================================================================== */
@media print {
  /* 隱藏整個前端網頁版面與多餘物件 */
  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12pt !important;
  }

  .app-container,
  #toast,
  .btn,
  .editor-actions,
  .preview-header,
  .select-student-group,
  .paper-preview-container,
  .title-card,
  header,
  aside,
  .mobile-header {
    display: none !important;
  }

  /* 顯示列印容器 */
  .print-only-container {
    display: block !important;
    width: 100% !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
  }

  /* 列印成績單紙張格式 */
  .print-card {
    width: 100% !important;
    min-height: 297mm !important; /* A4標準高度 */
    box-shadow: none !important;
    border: none !important;
    padding: 20mm !important; /* 符合 A4 標準邊界 */
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 25px !important;
    page-break-after: always !important; /* 每位學生自動強制分頁 */
    background: #ffffff !important;
  }

  .print-card:last-child {
    page-break-after: avoid !important;
  }
}

