/* ==========================================================================
   主控台專屬佈局樣式 (host.css)
   ========================================================================== */

/* 通用狀態控制 */
.is-hidden {
  display: none !important;
}

body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* 左側 OBS / 工具顯示畫布 */
#game-container {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  position: relative;
}

#game-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}

/* 右側主控台側邊欄 */
#sidebar {
  width: 320px;
  background-color: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 觀眾操作權限控制按鈕 (現代暗色微光擬態) */
#guest-lock-btn {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.3px;
  outline: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}

/* 開放狀態：翡翠墨綠微光 */
#guest-lock-btn.is-unlocked {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

#guest-lock-btn.is-unlocked:hover {
  background: rgba(16, 185, 129, 0.22);
  border-color: #10b981;
  color: #ecfdf5;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.3);
  transform: translateY(-1px);
}

/* 鎖定狀態：沉穩珊瑚紅微光 */
#guest-lock-btn.is-locked {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.1);
}

#guest-lock-btn.is-locked:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: #ef4444;
  color: #fef2f2;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.3);
  transform: translateY(-1px);
}

#guest-lock-btn:active {
  transform: translateY(0);
}

/* 密碼卡片樣式 */
.pwd-display-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  gap: 8px;
}

.pwd-text-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  overflow: hidden;
  cursor: default;
}

.pwd-text-wrap.clickable {
  cursor: pointer;
}

.pwd-display-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwd-display-text.empty {
  color: var(--text-dim);
  font-family: inherit;
  font-weight: 500;
  font-size: 0.85rem;
}

.pwd-copy-icon {
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.pwd-text-wrap.clickable:hover .pwd-copy-icon {
  transform: scale(1.15);
  color: var(--primary);
}

.pwd-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pwd-set-btn {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #475569;
  background-color: var(--bg-item);
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.pwd-set-btn:hover {
  background-color: #334155;
  color: #ffffff;
}

.pwd-clear-btn {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.pwd-clear-btn:hover {
  background-color: rgba(239, 68, 68, 0.3);
  color: #ffffff;
}

/* 側邊欄連線狀態與管理摘要列 */
.audience-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.btn-manage-audience {
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid #475569;
  background: var(--bg-card);
  color: #cbd5e1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-manage-audience:hover:not(:disabled) {
  background: #334155;
  color: #ffffff;
  border-color: #64748b;
}

.btn-manage-audience:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* QR Code 卡片 */
.qr-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#qrcode {
  background-color: #ffffff;
  padding: 12px;
  border-radius: 8px;
  display: inline-block;
  min-width: 140px;
  min-height: 140px;
}

.room-tag {
  font-family: monospace;
  font-size: 0.8rem;
  color: #cbd5e1;
  background: var(--bg-item);
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-all;
}

.qr-actions {
  display: flex;
  gap: 6px;
  width: 100%;
}

.btn-copy-link {
  flex: 1;
}

.btn-reset-room {
  background-color: #334155;
  color: #94a3b8;
  width: auto;
  padding: 0 10px;
  white-space: nowrap;
}

.btn-reset-room:hover {
  background-color: #475569;
  color: #f8fafc;
}

/* ==========================================================================
   觀眾管理獨立彈窗樣式 (#player-modal)
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.2s ease-out;
}

.modal-overlay.active {
  display: flex;
}

.audience-modal-card {
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.15);
  animation: modalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.audience-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.audience-modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* 搜尋與過濾輸入列 */
.audience-search-wrap {
  position: relative;
  width: 100%;
}

.audience-search-input {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 9px 12px 9px 34px;
  color: #f8fafc;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.audience-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.audience-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* 工具列：人數統計與一鍵清場 */
.audience-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #94a3b8;
  padding: 0 2px;
}

.btn-kick-all {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--danger);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-kick-all:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.3);
  color: #ffffff;
}

.btn-kick-all:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 彈窗內部的獨立捲動觀眾列表 */
.modal-player-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  min-height: 120px;
  overflow-y: auto;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 8px;
}

.modal-player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
}

.modal-player-item:hover {
  background: #253348;
}

.modal-player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  flex: 1;
}

.modal-player-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 觀眾操作按鈕群組 */
.modal-player-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* 單一觀眾權限切換按鈕 */
.modal-player-lock {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  outline: none;
}

.modal-player-lock.is-unlocked {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.modal-player-lock.is-unlocked:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: #10b981;
  color: #ecfdf5;
}

.modal-player-lock.is-locked {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.modal-player-lock.is-locked:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #fef2f2;
}

.modal-player-kick {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.modal-player-kick:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

/* 空狀態提示 */
.empty-player-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  color: #64748b;
  font-size: 0.88rem;
  gap: 6px;
  text-align: center;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalPop {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}