/* ==========================================================================
   Master Theme Stylesheet - Fullscreen Layout with Draggable Pill Navigation
   ========================================================================== */

:root {
  --bg-dark: #090a0f;
  --panel-bg: rgba(18, 20, 29, 0.82);
  --panel-border: rgba(255, 255, 255, 0.15);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --pill-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.85), rgba(168, 85, 247, 0.85));
  --pill-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  --accent-glow: rgba(99, 102, 241, 0.25);
  --radius-full: 9999px;
  --radius-xl: 16px;
  --font-family: 'Inter', 'Noto Sans TC', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-family);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Iframe Viewport Container
   ========================================================================== */

.view-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.iframe-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.985);
  transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.45s;
  z-index: 1;
}

.iframe-wrapper.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
  z-index: 2;
}

.iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* 拖動期間在全螢幕 overlay 防止 iframe 攔截滑鼠事件 */
.drag-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9998;
  display: none;
  cursor: grabbing !important;
}

.drag-overlay.active {
  display: block;
}

/* ==========================================================================
   Draggable Floating Controls & Navigation Bar
   ========================================================================== */

.floating-controls {
  position: fixed;
  top: 18px;
  right: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  transition: box-shadow 0.3s ease, opacity 0.2s ease;
}

.floating-controls.is-dragging {
  cursor: grabbing !important;
  opacity: 0.92;
  transition: none !important; /* 拖動時停用平滑位移過渡，保持即時跟隨 */
}

.controls-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 10px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px) saturate(190%);
  -webkit-backdrop-filter: blur(20px) saturate(190%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-full);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.controls-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65),
              0 0 24px var(--accent-glow);
}

/* 拖動手把 (Drag Handle) 樣式 */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px 6px 6px;
  color: var(--text-muted);
  cursor: grab;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.drag-handle:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.floating-controls.is-dragging .drag-handle {
  cursor: grabbing;
  color: #ffffff;
}

/* Status Indicator Tag */
.brand-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  cursor: grab;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.page-indicator {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  user-select: none;
}

/* ==========================================================================
   Tab Navigation & Mandatory Pill Style
   ========================================================================== */

.tab-group {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-full);
  padding: 3px;
}

/* 嚴格遵循使用者指定之 .pill 樣式 */
.pill {
  position: absolute;
  transition: left 0.4s cubic-bezier(0.65, 0, 0.35, 1),
              width 0.4s cubic-bezier(0.65, 0, 0.35, 1);
  top: 3px;
  bottom: 3px;
  height: calc(100% - 6px);
  background: var(--pill-bg);
  border-radius: var(--radius-full);
  box-shadow: var(--pill-shadow);
  z-index: 1;
  pointer-events: none;
}

.tab-btn {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: color 0.3s ease;
  white-space: nowrap;
  outline: none;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.tab-icon {
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.tab-btn:hover .tab-icon {
  transform: translateY(-1px);
}

/* ==========================================================================
   Right Navigation Arrows (Prev / Next Buttons)
   ========================================================================== */

.nav-arrows {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.arrow-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.arrow-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}

.arrow-btn:active {
  transform: scale(0.95);
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 768px) {
  .controls-card {
    gap: 6px;
    padding: 6px 8px 6px 8px;
  }

  .brand-tag {
    display: none;
  }

  .tab-btn {
    padding: 7px 12px;
    font-size: 0.78rem;
  }

  .tab-btn span {
    display: none;
  }

  .tab-btn .tab-icon {
    margin: 0;
  }
}
