/* css/style.css */
/* STREAMING_CHUNK: Defining root variables and cybernetic neon color tokens */
:root {
  --bg-dark: #02050c;
  --bg-panel: rgba(5, 15, 35, 0.85);
  --hud-cyan: #00f3ff;
  --hud-cyan-rgb: 0, 243, 255;
  --hud-blue: #0066ff;
  --hud-red: #ff3e3e;
  --hud-green: #00ff66;
  --hud-yellow: #ffe600;

  --hud-cyan-glow: 0 0 10px rgba(0, 243, 255, 0.35);
  --hud-blue-glow: 0 0 10px rgba(0, 102, 255, 0.35);
  --hud-red-glow: 0 0 10px rgba(255, 62, 62, 0.35);
  --hud-green-glow: 0 0 10px rgba(0, 255, 102, 0.35);

  --hud-panel-border: rgba(0, 243, 255, 0.15);
  --hud-panel-border-active: rgba(0, 243, 255, 0.5);

  --text-primary: #e2f5ff;
  --text-secondary: #7fa8bf;
  --text-muted: #4a6c80;

  --font-mono: 'Share Tech Mono', monospace;
  --font-sans: 'Inter', sans-serif;
}

/* STREAMING_CHUNK: Resetting base browser formatting and setting grid background */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.hud-theme,
body.hud-theme * {
  user-select: none;
  -webkit-user-select: none;
}

/* Keep the root app tied to the browser's current visible viewport. */
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.main {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

body.hud-theme {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-sans);

  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;

  display: flex;
  flex-direction: column;

  background-image:
    linear-gradient(rgba(0, 243, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 243, 255, 0.02) 1px, transparent 1px);

  background-size: 30px 30px;
  background-position: center;
}

#app-container {
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
}

/* 通用狀態顏色 */
.text-green { color: var(--hud-green) !important; text-shadow: var(--hud-green-glow); }
.text-cyan { color: var(--hud-cyan) !important; text-shadow: var(--hud-cyan-glow); }
.text-red { color: var(--hud-red) !important; text-shadow: var(--hud-red-glow); }
.text-yellow { color: var(--hud-yellow) !important; }

/* STREAMING_CHUNK: Structuring primary layout split grids and bars */
.ide-body {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  overflow: hidden;
}

.hud-activity-bar {
  width: 55px;
  background: rgba(3, 10, 25, 0.95);
  border-right: 2px solid var(--hud-panel-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 15px;
  gap: 15px;
  z-index: 15;
  flex-shrink: 0;
}

.activity-settings-btn {
  margin-top: auto;
  margin-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  background: transparent;
  font: inherit;
}

#activity-tabs-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
}

#activity-tabs-container::-webkit-scrollbar {
  display: none;
}

.activity-tab {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  color: var(--hud-cyan);
  opacity: 0.72;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}

.activity-tab:hover {
  color: var(--hud-cyan);
  opacity: 1;
  background: rgba(var(--hud-cyan-rgb), 0.05);
  border-color: rgba(var(--hud-cyan-rgb), 0.15);
}

.activity-tab.active {
  color: var(--hud-cyan);
  opacity: 1;
  background: rgba(var(--hud-cyan-rgb), 0.08);
  border-color: var(--hud-cyan);
  box-shadow: var(--hud-cyan-glow);
}

.activity-tab.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  height: 50%;
  width: 3px;
  background-color: var(--hud-cyan);
  box-shadow: var(--hud-cyan-glow);
  border-radius: 0 3px 3px 0;
}

/* SETTINGS PANEL */
.settings-panel {
  position: fixed;
  left: 67px;
  bottom: 14px;
  width: min(320px, calc(100vw - 82px));
  padding: 14px;
  border: 1px solid var(--hud-panel-border-active);
  border-radius: 6px;
  background: rgba(3, 10, 25, 0.98);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), var(--hud-cyan-glow);
  z-index: 80;
}

.settings-panel[hidden] {
  display: none;
}

.settings-panel-header,
.settings-toggle-row,
.settings-theme-option {
  display: flex;
  align-items: center;
}

.settings-panel-header {
  justify-content: space-between;
  margin-bottom: 14px;
  color: var(--hud-cyan);
}

.settings-panel-title,
.settings-theme-group legend {
  font: 0.85rem var(--font-mono);
  letter-spacing: 0.08em;
}

.settings-group {
  border: 0;
  padding: 0;
  margin: 0;
}

.settings-toggle-row {
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.settings-toggle-row strong,
.settings-toggle-row small {
  display: block;
}

.settings-toggle-row strong {
  color: var(--text-primary);
  font-size: 0.82rem;
}

.settings-toggle-row small {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.settings-toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.settings-switch {
  width: 38px;
  height: 20px;
  flex-shrink: 0;
  border: 1px solid var(--text-muted);
  border-radius: 10px;
  background: rgba(127, 168, 191, 0.16);
  position: relative;
  transition: 0.2s ease;
}

.settings-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: 0.2s ease;
}

.settings-toggle-row input:checked + .settings-switch {
  border-color: var(--hud-cyan);
  background: rgba(var(--hud-cyan-rgb), 0.18);
  box-shadow: var(--hud-cyan-glow);
}

.settings-toggle-row input:checked + .settings-switch::after {
  transform: translateX(18px);
  background: var(--hud-cyan);
}

.settings-theme-group {
  margin-top: 18px;
}

.settings-theme-group legend {
  margin-bottom: 9px;
  color: var(--text-secondary);
}

.settings-theme-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.settings-theme-option {
  justify-content: center;
  min-height: 34px;
  border: 1px solid rgba(127, 168, 191, 0.2);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.68rem;
  cursor: pointer;
}

.settings-theme-option input {
  position: absolute;
  opacity: 0;
}

.settings-theme-option::before {
  content: '';
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 7px currentColor;
}

.settings-theme-option:has(input:checked) {
  border-color: currentColor;
  color: var(--hud-cyan);
}

.theme-cyan { color: #00f3ff; }
.theme-orange { color: #ff9d3d; }
.theme-green { color: #00ff66; }
.theme-white { color: #f8fafc; }

.settings-status {
  min-height: 1em;
  margin-top: 12px;
  color: var(--text-muted);
  font: 0.66rem var(--font-mono);
}

/* STREAMING_CHUNK: Styling bottom audio drawer panel */
#bottom-audio-drawer {
  position: absolute;
  bottom: 0;
  left: 50%;
  right: 0;
  height: 250px;
  background: rgba(3, 10, 25, 0.95);
  border-top: 2px solid var(--hud-panel-border);
  border-left: 1px solid var(--hud-panel-border);
  transition: height 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 12;
}

#bottom-audio-drawer.collapsed {
  height: 35px;
}

.audio-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: calc(100% - 35px);
  width: 100%;
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden;
}

/* STREAMING_CHUNK: Formulating HUD buttons and user micro-interfaces */
.hud-btn {
  background: rgba(0, 102, 255, 0.1);
  border: 1px solid var(--hud-blue);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.hud-btn:hover {
  background: rgba(0, 102, 255, 0.3);
  box-shadow: var(--hud-blue-glow);
  border-color: var(--hud-cyan);
}

.hud-btn.glow-cyan {
  border-color: var(--hud-cyan);
  background: rgba(0, 243, 255, 0.05);
}
.hud-btn.glow-cyan:hover {
  background: rgba(0, 243, 255, 0.2);
  box-shadow: var(--hud-cyan-glow);
}

.hud-btn.glow-blue {
  border-color: var(--hud-blue);
  background: rgba(0, 102, 255, 0.05);
}
.hud-btn.glow-blue:hover {
  background: rgba(0, 102, 255, 0.25);
  box-shadow: var(--hud-blue-glow);
}

.hud-btn.glow-green {
  border-color: var(--hud-green);
  background: rgba(0, 255, 102, 0.05);
}
.hud-btn.glow-green:hover {
  background: rgba(0, 255, 102, 0.25);
  box-shadow: var(--hud-green-glow);
}

.hud-btn.glow-red {
  border-color: var(--hud-red);
  background: rgba(255, 62, 62, 0.05);
}
.hud-btn.glow-red:hover {
  background: rgba(255, 62, 62, 0.25);
  box-shadow: var(--hud-red-glow);
}

.w-full { width: 100%; }
.text-center { justify-content: center; }
.cursor-pointer { cursor: pointer; }

/* STREAMING_CHUNK: Adjusting split containers in visual panels */
#middle-container {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
  background: rgba(2, 5, 12, 0.5);
  position: relative;
}

/* IFRAME FULLSCREEN MODE */
body.iframe-fullscreen-mode #middle-container {
  overflow: hidden;
}

body.iframe-fullscreen-mode #left-nav-panel {
  width: 100% !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
}

body.iframe-fullscreen-mode #canvas-panel {
  flex: 0 0 0 !important;
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  overflow: hidden !important;
  border-right: none !important;
  pointer-events: none !important;
}

body.iframe-fullscreen-mode #canvas-panel .panel-header,
body.iframe-fullscreen-mode #canvas-panel .viewer-content {
  display: none !important;
}

.iframe-fullscreen-control {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
}

.hud-sub-panel {
  transition: width 0.35s cubic-bezier(0.1, 0.9, 0.2, 1), flex 0.35s cubic-bezier(0.1, 0.9, 0.2, 1);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-right: 1px solid var(--hud-panel-border);
}

.hud-sub-panel:last-child {
  border-right: none;
}

.hud-sub-panel.collapsed {
  width: 0% !important;
  min-width: 0 !important;
  flex: 0 0 0 !important;
  border-right: none !important;
}

.viewer-content {
  flex: 1;
  position: relative;
  overflow: auto;
  background: #02050c;
}

/* HUD PANEL COMMON BASE */
.hud-panel {
  background: var(--bg-panel);
  border: 1px solid var(--hud-panel-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: width 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
  position: relative;
  z-index: 10;
}

.panel-header {
  height: 40px;
  background: rgba(3, 10, 25, 0.9);
  border-bottom: 1px solid var(--hud-panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  overflow: hidden;
  white-space: nowrap;
  flex-shrink: 0;
}

.panel-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--hud-cyan);
}

.toggle-btn {
  background: transparent;
  border: none;
  color: var(--hud-cyan);
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.toggle-btn:hover {
  color: #fff;
  text-shadow: var(--hud-cyan-glow);
}

/* HUD ICON BUTTONS */
.hud-icon-btn {
  background: rgba(3, 10, 25, 0.8);
  border: 1px solid var(--hud-panel-border);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.hud-icon-btn:active {
  color: var(--hud-cyan);
  border-color: var(--hud-cyan);
  box-shadow: var(--hud-cyan-glow);
  background: rgba(0, 243, 255, 0.05);
}

.hud-icon-btn.glow-red:hover {
  color: var(--hud-red);
  border-color: var(--hud-red);
  box-shadow: var(--hud-red-glow);
  background: rgba(255, 62, 62, 0.05);
}

.hud-icon-btn *,
.hud-btn * {
  pointer-events: none;
}

.hud-icon-btn.active {
  background: rgba(0, 243, 255, 0.2);
  border-color: var(--hud-cyan, #00f3ff);
  color: var(--hud-cyan, #00f3ff);
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
}

.hud-icon-btn:hover {
  border-color: var(--hud-cyan, #00f3ff);
  color: #ffffff;
}

/* STREAMING_CHUNK: Common alerts and general glowing scrolls */
.hud-toast {
  position: fixed;
  bottom: calc(25px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(2, 5, 12, 0.95);
  border: 1px solid var(--hud-cyan);
  box-shadow: var(--hud-cyan-glow);
  padding: 10px 25px;
  border-radius: 4px;
  z-index: 10000;
  font-size: 0.85rem;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  transition: opacity 0.3s, transform 0.3s;
}

.hud-toast.hidden {
  opacity: 0;
  transform: translate(-50%, 15px);
  pointer-events: none;
}

/* GLOBAL SCROLLBARS */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(2, 5, 12, 0.4);
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 243, 255, 0.25);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--hud-cyan);
}