/* ==========================================================
   Petoi Bittle Koding — Styles
   仿 NUWA codelab 深色主題
   ========================================================== */

:root {
  --bg-primary: #1a1d24;
  --bg-secondary: #232730;
  --bg-tertiary: #2c313c;
  --border: #3a3f4b;
  --text-primary: #e0e6ef;
  --text-secondary: #9ba5b4;
  --accent: #5fa9e8;
  --accent-hover: #7bb9ee;
  --success: #4caf50;
  --warning: #ffa726;
  --danger: #ef5350;
}

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

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  overflow: hidden;
}

/* ===== Header ===== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .logo {
  font-size: 24px;
}

.brand .title {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

.brand .version {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.actions {
  display: flex;
  gap: 8px;
}

.btn-primary, .btn-secondary {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border);
}

/* ===== Main 三欄布局 ===== */
main {
  display: flex;
  height: calc(100vh - 56px);
}

/* Blockly Workspace（中央） */
.workspace {
  flex: 1;
  background: var(--bg-primary);
}

/* Blockly 內部樣式調整 */
.blocklyMainBackground {
  stroke: none !important;
}

/* 右側面板 */
.right-panel {
  width: 500px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s ease;
}

/* v0.5.1：放大模式 — 右側面板加寬、模擬器區占大部分高度 */
.right-panel.expanded {
  width: 760px;
}
.right-panel.expanded .panel-section:first-child {
  flex: 4;  /* 模擬器區占 80% */
}
.right-panel.expanded .panel-section:last-child {
  flex: 1;  /* log 區縮成 20% */
}
.right-panel.expanded #simulator-3d-area {
  min-height: 560px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  padding: 12px;
}

.panel-section:first-child {
  flex: 1;
  min-height: 50%;
}

.panel-section:last-child {
  flex: 1;
  min-height: 0;
}

.panel-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.panel-header h3 {
  margin-bottom: 0;
}

.btn-mini {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-mini:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

#simulator-3d-area {
  width: 100%;
  min-height: 380px;  /* v0.5.1：從 280 拉大到 380 */
  flex: 1;            /* 讓它填滿可用空間 */
  background: var(--bg-tertiary);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  transition: min-height 0.3s ease;
}

#simulator-3d-area canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* v0.5.1：移除 #simulator-area 與 #bittle-svg 規則（2D SVG 已下線）*/

#status-line {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-family: "Menlo", monospace;
}

/* ===== 事件觸發列 v0.5.0 ===== */
.event-trigger-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-top: 6px;
  padding: 6px;
  background: rgba(255, 235, 100, 0.06);
  border: 1px solid rgba(255, 235, 100, 0.2);
  border-radius: 4px;
}

.event-label {
  font-size: 11px;
  color: #ffd966;
  margin-right: 4px;
}

.btn-event {
  font-size: 11px;
  padding: 3px 8px;
  background: rgba(255, 235, 100, 0.12);
  color: #ffd966;
  border: 1px solid rgba(255, 235, 100, 0.4);
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}

.btn-event:hover {
  background: rgba(255, 235, 100, 0.3);
  color: white;
}

#log {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-family: "Menlo", "Consolas", monospace;
  font-size: 12px;
  overflow-y: auto;
  color: var(--text-secondary);
}

#log div {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

#log div:last-child {
  border-bottom: none;
}

#log div.log-error {
  color: var(--danger);
}

#log div.log-success {
  color: var(--success);
}

#log div.log-warn {
  color: var(--warning);
}

/* ===== Blockly Toolbox 字色 override（修對比不足）===== */
.blocklyToolboxDiv {
  background-color: var(--bg-secondary) !important;
  border-right: 1px solid var(--border) !important;
  padding-top: 8px !important;
}

.blocklyTreeRow {
  height: 36px !important;
  line-height: 36px !important;
  padding-right: 16px !important;
  margin-bottom: 2px !important;
}

.blocklyTreeLabel {
  color: var(--text-primary) !important;
  font-size: 14px !important;
  font-family: -apple-system, "Microsoft JhengHei", "Noto Sans TC", sans-serif !important;
  font-weight: 500 !important;
}

.blocklyTreeRow:hover {
  background-color: var(--bg-tertiary) !important;
}

.blocklyTreeRow:hover .blocklyTreeLabel {
  color: var(--accent) !important;
}

.blocklyTreeSelected {
  background-color: var(--accent) !important;
}

.blocklyTreeSelected .blocklyTreeLabel {
  color: white !important;
  font-weight: 600 !important;
}

.blocklyFlyoutBackground {
  fill: var(--bg-tertiary) !important;
}

.blocklyFlyoutLabelText {
  fill: var(--text-secondary) !important;
}

/* 分類前的小圓點 colour indicator 加大易看 */
.blocklyTreeIcon {
  width: 16px !important;
}

/* v0.5.1：移除 SVG 模擬器動畫過渡規則（2D 已下線）*/
