/* 基本設定 & フォント */
body {
  font-family: "Plus Jakarta Sans", "Noto Sans JP", sans-serif;
  background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
  background-size: 24px 24px;
}
.dark body {
  background-image: radial-gradient(#1e293b 1px, transparent 1px);
}

/* レイアウト制御 */
#workspace-container {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
}

#blocklyDiv {
  flex-grow: 1;
  height: 100%;
  position: relative;
  z-index: 10;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

#liveCodeArea {
  width: 0;
  height: 100%;
  background-color: #0f172a; /* Slate 900 */
  color: #e2e8f0;
  overflow: hidden;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  opacity: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

/* 分割モード時のスタイル */
.split-view #blocklyDiv {
  width: 55%;
  flex-grow: 0;
  flex-shrink: 0;
  border-right: 1px solid rgba(0, 0, 0, 0.05);
}
.dark .split-view #blocklyDiv {
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}
.split-view #liveCodeArea {
  width: 45%;
  opacity: 1;
  flex-grow: 1;
  box-shadow: inset 10px 0 20px -10px rgba(0, 0, 0, 0.5);
}

#codePreviewContent {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 1.5rem;
  overflow-y: auto;
  height: 100%;
  background: transparent !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
.dark ::-webkit-scrollbar-thumb {
  background: #475569;
}

#liveCodeArea ::-webkit-scrollbar-track {
  background: transparent;
}
#liveCodeArea ::-webkit-scrollbar-thumb {
  background: #334155;
}
#liveCodeArea ::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* --- Blockly Toolbox Styling Fixes --- */

/* ツールボックス全体の背景など */
.blocklyToolboxDiv {
  background-color: rgba(248, 250, 252, 0.95) !important;
  backdrop-filter: blur(10px);
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  padding-top: 1rem;
}
.dark .blocklyToolboxDiv {
  background-color: rgba(15, 23, 42, 0.95) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* カテゴリ行のレイアウト修正 (Flexbox化) */
.blocklyTreeRow {
  height: 48px !important;
  padding-left: 12px !important; /* 左側の余白 */
  border-left: 4px solid transparent;
  margin-bottom: 4px;
  transition: all 0.2s ease;
  margin-right: 12px;
  border-radius: 0 8px 8px 0;
  
  /* Flexboxで垂直中央揃えを強制 */
  display: flex !important;
  align-items: center !important;
  line-height: normal !important; /* line-height固定を解除 */
}

/* デフォルトの四角い色アイコンを非表示にする（border-leftで色を表現するため） */
.blocklyTreeIcon {
  display: none !important;
}

/* カテゴリラベルのスタイル */
.blocklyTreeLabel {
  font-family: "Plus Jakarta Sans", "Noto Sans JP", sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: #475569;
  padding: 0 !important; /* パディングは親要素で管理 */
  margin-left: 8px; /* 左のボーダーとの距離 */
}

/* ホバー時のスタイル */
.blocklyTreeRow:not(.blocklyTreeSelected):hover {
  background-color: #f1f5f9;
  border-left-color: #cbd5e1;
}

/* 選択時のスタイル */
.blocklyTreeSelected {
  background-color: #e0e7ff !important;
  border-left-color: #6366f1 !important;
}
.blocklyTreeSelected .blocklyTreeLabel {
  color: #4f46e5 !important;
}

/* ダークモード対応 */
.dark .blocklyTreeLabel {
  color: #94a3b8;
}
.dark .blocklyTreeRow:not(.blocklyTreeSelected):hover {
  background-color: #1e293b;
  border-left-color: #475569;
}
.dark .blocklyTreeSelected {
  background-color: #1e1b4b !important;
  border-left-color: #818cf8 !important;
}
.dark .blocklyTreeSelected .blocklyTreeLabel {
  color: #c7d2fe !important;
}

/* セパレーター（区切り線）のスタイル */
.blocklyTreeSeparator {
  border-bottom: 1px solid rgba(0,0,0,0.05) !important;
  margin: 8px 16px 8px 0 !important;
  height: 0 !important;
  background: transparent !important;
}
.dark .blocklyTreeSeparator {
  border-bottom: 1px solid rgba(255,255,255,0.05) !important;
}

/* フライアウト（パレット）の背景 */
.blocklyFlyoutBackground {
  fill: #ffffff !important;
  fill-opacity: 0.98;
}
.dark .blocklyFlyoutBackground {
  fill: #0f172a !important;
  fill-opacity: 0.98;
}

/* モーダルアニメーション */
.modal-backdrop {
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-backdrop.show-modal {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  transform: scale(0.95) translateY(10px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.show-modal .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Utility */
.glass-header {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.dark .glass-header {
  background: rgba(15, 23, 42, 0.8);
}

/* Code Block Styling in Modal */
.hljs {
  background: transparent !important;
  padding: 0 !important;
}