/* =========================================================
   PedalPlay - 現場踏板演出專屬極簡樣式 (Pedal Stage CSS)
   ========================================================= */

:root {
  --bg-stage: #0c0d10;
  --bg-card: #16181f;
  --bg-card-hover: #212530;
  --border-stage: #2d3342;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-green: #10b981;
  --accent-purple: #8b5cf6;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
}

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

body, html {
  width: 100%;
  height: 100%;
  background: var(--bg-stage);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 主體視窗格局 */
.pedal-app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* 頂部極簡工具列 */
.pedal-header {
  height: 52px;
  background: rgba(16, 18, 24, 0.96);
  border-bottom: 1px solid var(--border-stage);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  flex-shrink: 0;
  transition: all 0.25s ease;
}

/* 演奏中全螢幕沉浸：頂部工具列完全隱藏，不占用任何高度空間 */
body.pedal-playing-active .pedal-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

/* 當滑鼠移至頂部感應區時喚起浮現 */
body.pedal-playing-active .pedal-header.header-revealed {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.85);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  font-size: 1.05rem;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  overflow: hidden;
  padding: 0 16px;
}

.current-song-badge {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 通用按鈕 */
.btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-stage);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: #475569;
}

.btn-primary {
  background: #2563eb;
  border-color: #1d4ed8;
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-purple {
  background: #7c3aed;
  border-color: #6d28d9;
  color: #fff;
}

.btn-purple:hover {
  background: #6d28d9;
}

.btn-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  justify-content: center;
  font-size: 1.15rem;
}

/* 樂譜容器 (自適應寬度長條，支援滑順滾動) */
.sheet-viewport {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 80px 0; /* 平時緊貼 Header，無突兀黑橫幅 */
  scroll-behavior: smooth;
  position: relative;
}

/* 演奏中全螢幕沉浸時：頂部保有 16px 舒適呼吸區 */
body.pedal-playing-active .sheet-viewport {
  padding-top: 16px;
}

/* 空狀態歡迎畫面 */
.empty-hero {
  margin-top: 14vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 520px;
  padding: 32px;
  background: var(--bg-card);
  border: 1.5px dashed #475569;
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.7);
}

.empty-icon {
  font-size: 3.6rem;
  margin-bottom: 16px;
}

.empty-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

/* 樂譜長條與小節框 */
.sheet-strip-wrapper {
  position: relative;
  background: #ffffff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.75);
  border-radius: 2px;
  user-select: none;
  flex-shrink: 0;
  margin-bottom: 24px;
}

.sheet-strip-wrapper:last-child {
  margin-bottom: 90px;
}

.sheet-strip-image {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  filter: contrast(1.15) brightness(0.97);
}

.sheet-measure-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.line-block {
  position: absolute;
  box-sizing: border-box;
  pointer-events: none;
}

.measure-box {
  position: absolute;
  box-sizing: border-box;
  pointer-events: none;
}

/* 踏板演奏四大視覺標註 */
/* 1. 待命起點常駐紅框 */
.measure-box.pedal-standby-target {
  background: rgba(239, 68, 68, 0.12) !important;
  border: 4px solid #ef4444 !important;
  box-sizing: border-box !important;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.9) !important;
  border-radius: 4px !important;
  z-index: 99999 !important;
}

/* 2. 翻譜落點紅色閃爍 (1.2s 淡出) */
.measure-box.pedal-landing-flash {
  background: rgba(239, 68, 68, 0.15) !important;
  border: 4.5px solid #ef4444 !important;
  box-sizing: border-box !important;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.95), inset 0 0 10px rgba(239, 68, 68, 0.4) !important;
  border-radius: 4px !important;
  z-index: 99999 !important;
  animation: pedalLandingFade 1.2s forwards cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

@keyframes pedalLandingFade {
  0% { opacity: 1; transform: scale(1.02); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

/* 3. 翻譜臨界點常駐翡翠綠框 */
.measure-box.pedal-turn-target {
  background: transparent !important;
  border: 3.5px solid #10b981 !important;
  box-sizing: border-box !important;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.7) !important;
  border-radius: 4px !important;
  z-index: 9998 !important;
}

/* 翻譜箭頭 */
.pedal-turn-arrow {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: #10b981;
  font-size: 28px;
  line-height: 1;
  z-index: 10000 !important;
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.95), 0 2px 5px rgba(0, 0, 0, 0.9);
  filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.85));
}

.pedal-turn-arrow.arrow-down {
  bottom: -32px;
  animation: pedalArrowBounceDown 0.6s infinite alternate ease-in-out;
}

.pedal-turn-arrow.arrow-up {
  top: -32px;
  animation: pedalArrowBounceUp 0.6s infinite alternate ease-in-out;
}

@keyframes pedalArrowBounceDown {
  0% { transform: translateX(-50%) translateY(0); opacity: 0.4; }
  100% { transform: translateX(-50%) translateY(6px); opacity: 1; }
}

@keyframes pedalArrowBounceUp {
  0% { transform: translateX(-50%) translateY(0); opacity: 0.4; }
  100% { transform: translateX(-50%) translateY(-6px); opacity: 1; }
}

/* 4. 🏁 終點徽章 */
.pedal-turn-finish {
  position: absolute;
  left: 50%;
  bottom: -32px;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fbbf24;
  border: 1.5px solid #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.8), 0 2px 6px rgba(0,0,0,0.8);
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  z-index: 10000 !important;
  letter-spacing: 1px;
  animation: pedalFinishPulse 1.2s infinite alternate ease-in-out;
}

@keyframes pedalFinishPulse {
  0% { transform: translateX(-50%) scale(0.96); box-shadow: 0 0 8px rgba(245, 158, 11, 0.5); }
  100% { transform: translateX(-50%) scale(1.04); box-shadow: 0 0 16px rgba(245, 158, 11, 0.95); }
}

/* 底部極簡 HUD */
.pedal-hud {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background: rgba(12, 14, 18, 0.92);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border-stage);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* 演奏中全螢幕沉浸：底部控制列向下收合隱藏 */
body.pedal-playing-active .pedal-hud {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

/* 當滑鼠移至底部感應區時喚起浮現 */
body.pedal-playing-active .pedal-hud.hud-revealed {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.hud-left {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

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

.hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 舞台歌單管理浮層 (Setlist Modal) */
.stage-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-modal-box {
  background: #161820;
  border: 1.5px solid #8b5cf6;
  border-radius: 12px;
  padding: 20px 24px;
  width: 480px;
  max-width: 92vw;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0,0,0,0.9);
  color: #fff;
}

.stage-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid #334155;
  padding-bottom: 8px;
}

.stage-modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #c4b5fd;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-playlist-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
  min-height: 180px;
  max-height: 380px;
}

.setlist-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #20242f;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 12px;
  transition: all 0.15s ease;
}

.setlist-item-card:hover {
  background: #282e3c;
  border-color: #8b5cf6;
}

.setlist-item-card.active-playing-song {
  border-color: #10b981 !important;
  background: rgba(16, 185, 129, 0.14) !important;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.45);
}

.setlist-item-card.disabled-song {
  opacity: 0.4;
  background: #14161d;
}

.setlist-song-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f1f5f9;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.setlist-reorder-btn {
  background: transparent;
  border: 1px solid #475569;
  color: #94a3b8;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s;
}

.setlist-reorder-btn:hover {
  background: #334155;
  color: #fff;
}
