/* style.css */

/* ===== 全域設定 ===== */
div { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  background-color: black;
}

/* ===== 視訊背景 (最底層) ===== */
#video-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.output_canvas {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
}

/* ===== UI 操控層 (浮在視訊上) ===== */
#root {
  position: relative;
  z-index: 10;
  width: 100%; height: 100%;
  pointer-events: none;
}

button, input, label, select, .settings-panel {
  pointer-events: auto;
}

/* ===== 1. 左上角設定按鈕 (紅色) ===== */
#settings-toggle-btn {
  position: absolute;
  top: 40px;
  left: 20px;
  font-size: 18px;
  padding: 10px 20px;
  background-color: rgba(211, 47, 47, 0.9); 
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: transform 0.2s;
  backdrop-filter: blur(5px);
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
}

#settings-toggle-btn:hover {
  background-color: rgba(183, 28, 28, 1);
  transform: scale(1.05);
}

/* ===== 2. 主要功能列 (右下角) ===== */
.main-actions {
  position: absolute;
  right: 20px;       
  bottom: 20px;      
  top: auto;         
  transform: none;   
  
  display: flex;
  flex-direction: column; 
  gap: 10px;         

  background-color: rgba(0, 0, 0, 0.6);
  padding: 15px;     
  border-radius: 20px; 
  backdrop-filter: blur(10px);
  box-shadow: -5px 5px 20px rgba(0,0,0,0.4);
}

.main-btn {
  font-size: 14px;   
  padding: 8px 16px; 
  border: none;
  border-radius: 20px; 
  cursor: pointer;
  font-weight: bold;
  color: white;
  transition: all 0.2s;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
  white-space: nowrap; 
  text-align: center;
}

#restart-btn { background-color: #f39c12; }
#music-play-btn { background-color: #3498db; }
#toggle-vision-btn { background-color: #555; }

.main-btn:hover {
  transform: translateX(-5px); 
  filter: brightness(1.1);
}

#music-play-btn.active-mode,
#music-play-btn-2.active-mode,
#music-play-btn-3.active-mode {
  background-color: #2ecc71;
  box-shadow: 0 0 15px rgba(46, 204, 113, 0.6);
}

/* 其他模式按鈕底色 */
#music-play-btn-2 { background-color: #3498db; }
#music-play-btn-3 { background-color: #3498db; }

/* ===== 3. 設定面板 (彈窗) ===== */
.settings-panel {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 500px;
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  padding: 25px;
  display: none;
  flex-direction: column;
  gap: 20px;
  text-align: left;
  max-height: 80vh;
  overflow-y: auto;
}

.settings-panel.show {
  display: flex;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -60%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #ddd;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.panel-header h2 { margin: 0; font-size: 1.5em; color: #333; }
.close-btn {
  background: none; border: none; font-size: 24px; cursor: pointer; color: #666;
}
.close-btn:hover { color: #000; }

.control-group {
  background: #f9f9f9;
  padding: 15px;
  border-radius: 10px;
  border: 1px solid #eee;
}
.control-group h3 { margin-top: 0; font-size: 1.1em; color: #555; margin-bottom: 10px; }

.btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-btn {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  background: white;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
  white-space: nowrap;
}
.panel-btn:hover { background: #eee; }

.panel-btn.active-mode {
  background-color: #4caf50;
  color: white;
  border-color: #388e3c;
}

.file-label {
  display: block;
  padding: 10px;
  background: #e0e0e0;
  text-align: center;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
}
.file-label:hover { background: #d0d0d0; }

.panel-select {
    width: 100%;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-size: 16px;
}

/* 加載動畫 */
.loading-spinner {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border: 8px solid rgba(255,255,255,0.3);
  border-top: 8px solid #3498db;
  border-radius: 50%; width: 60px; height: 60px;
  animation: spin 1s linear infinite;
  z-index: 50; display: none;
}
@keyframes spin { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }

/* ===== 進度條樣式 (懸浮、短版、置中、加粗) ===== */
#progress-container {
  position: fixed;
  bottom: 50px;       
  left: 50%;          
  transform: translateX(-50%); 
  width: 50%;         
  height: 15px;       
  background-color: rgba(255, 255, 255, 0.2);
  z-index: 9999;
  pointer-events: auto;
  cursor: pointer; /* 滑鼠移上去變成手指 */
  border-radius: 10px; 
  overflow: hidden;    
}

#progress-fill {
  height: 100%;
  width: 0%; 
  background: linear-gradient(90deg, #f39c12, #e74c3c);
  transition: width 0.1s linear; 
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.8);
}

/* 🔥🔥🔥 歌詞顯示區域 🔥🔥🔥 */
#lyrics-container {
  position: fixed;
  bottom: 80px; /* 在進度條 (bottom: 50px) 上方 30px */
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  text-align: center;
  pointer-events: none; /* 讓滑鼠點擊穿透 */
  z-index: 9998;
}

.lyric-text {
  font-size: 36px;
  font-weight: bold;
  color: #df1414;
  text-shadow: 
    2px 2px 0 #000, 
    -1px -1px 0 #000,  
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
  font-family: "Microsoft JhengHei", sans-serif;
  transition: opacity 0.3s;
}
.search-input {
  width: 100%;
  padding: 10px;
  border-radius: 5px;
  border: 1px solid #ccc;
  font-size: 16px;
  margin-bottom: 10px; /* 與下方選單保持距離 */
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}