/* Extracted styles from public/mypage.html
   This file contains the CSS that was previously embedded in <style> blocks in mypage.html.
   Keep in sync if you later edit the HTML-embedded styles.
*/

html, body {
    height: 100%;
}
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

body.embedded-dashboard header {
    display: none !important;
}

body.embedded-dashboard #pageFrame {
    padding: 0;
}

/* ヘッダは固定サイズ（内容に応じる）で伸縮しない */
header {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 12px !important;
  flex: 0 0 auto !important;
}

/* allow flex items to shrink below their content width so they don't force page-wide overflow */
header, #userCard, #pageFrame, #pageFrame > div, .grid, .toolbar, .belowBlockly, .viz {
    min-width: 0;
}
/* 追加: ヘッダーの右寄せ */
.header-right {
    display: flex;
    /*justify-content: flex-end;*/
    align-items: center;
    gap: 12px;
}
/* 内部のフォームやボタンも縦中央に */
.header-right form,
.header-right button,
.header-right #mc_player_info {
    display: inline-flex;
    align-items: center;
}

/* 必要ならボタンの高さや line-height を揃える */
.header-right .btn,
.header-right button {
    height: auto;
    line-height: 1;
    padding: 6px 10px;
}

/* Ensure page frame doesn't create horizontal scroll; child pages may scroll internally */
#pageFrame {
    flex: 1 1 auto;
    min-height: 0; /* 重要: flex 子の内側で正しくスクロールさせるために必要 */
    box-sizing: border-box;
    overflow: hidden; /* 内部要素がスクロールするよう外側は隠す */
    display: block;
    padding: 12px;
}

/* Make child pages fill frame and scroll internally (vertical scroll) */
#pageFrame > div {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}


#pageMain {
    display: flex;
    flex-direction: row; /* 横並び */
    width: 100%;
    height: 100%;
}




.panel {
    border: 1px solid #ddd;
    padding: 5px;
    border-radius: 6px;
    margin: 0 0
}

.grid {
    display: grid;
    grid-template-columns:1fr 1fr;
    gap: 12px
}

#playerInfo pre {
    white-space: pre-wrap;
    margin: 0
}

#eventLog {
    height: 380px;
    width: 100%;
    overflow: auto;
    font-family: monospace;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center
}

a.button {
    display: inline-block;
    padding: 6px 10px;
    background: #1976d2;
    color: #fff;
    border-radius: 4px;
    text-decoration: none
}

/* toolbar: allow wrapping so long lines of buttons don't force horizontal scroll */
.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* Ensure toolbar items do not wrap onto multiple lines; keep them horizontally aligned */
.toolbar {
  flex-wrap: nowrap !important;
  overflow-x: auto; /* allow horizontal scroll if too many buttons */
}

/* Keep toolbar children inline and vertically centered */
.toolbar > * {
  display: inline-flex;
  align-items: center;
  margin: 0 6px 0 0;
}

/* Specific sizing for the course select to avoid forcing line breaks */
.toolbar #courseSelect {
  min-width: 160px;
  max-width: 360px;
  width: auto;
  box-sizing: border-box;
}

/* toolbar label should not introduce line breaks */
.toolbar label[for="courseSelect"] {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
}

/* break long words if needed to avoid forcing width */
.panel, pre, textarea {
    word-break: break-word;
}
#pageBlockly {
    display: none;
    flex-direction: column;
    height: 100%; /* 親が高さを持っている前提 (#pageFrame 等) */
    min-height: 0;
}
#pageBlockly { height: 100%; }
.viz #threeRoot { height: calc(100% - 180px); min-height: 160px; }
/* Clamp common large visual blocks */
#threeRoot, .viz, .belowBlockly {
    max-width: 100%;
    box-sizing: border-box;
}
#blocklyDiv {
    box-sizing: border-box;
    max-width: 100%;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #ddd;
    padding: 8px;
    display: none; /* 表示切替は JS により行う */
    align-items: stretch;
}


/* pageBlocklyBody / 右カラム を flex にして .viz を残り領域へ */
.pageBlocklyBody {
    display: flex !important;
    flex-direction: row !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    align-items: stretch;
}

.pageBlocklyBody > div:last-child {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 0 !important;
    height: 100% !important;
    min-height: 0 !important;
}

/* .viz を残り全部にする */
.pageBlocklyBody > div:last-child .viz {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
}
/* threeRoot を .viz 内で伸ばす（インライン height を上書き） */
.pageBlocklyBody > div:last-child .viz #threeRoot,
.viz #threeRoot {
    flex: 1 1 auto !important;
    height: auto !important;       /* inline の height:300px を無効化 */
    min-height: 160px !important;
    width: 100% !important;
    box-sizing: border-box;
}

/* statusArea を固定高さ 300px にする（スクロールを許可） */
.pageBlocklyBody > div:last-child .statusArea {
    flex: 0 0 300px;
    height: 300px;
    overflow: auto;
}

/* ===== Restore header / userCard / studentField layout and .btn styles ===== */
#userCard {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  gap: 12px !important;
}

#userCard, .profileCard {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
}

#studentInfo {
  display: flex;
  flex-direction: row;
  gap: 12px;
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0;
}

.studentField {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
  min-width: 0;
}

.studentField strong { font-weight: 700; }
.studentField span { display: inline-block; overflow: hidden; text-overflow: ellipsis; }

/* Primary rounded button used across the page */
.btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px 14px !important;
  background: #1976d2 !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 999px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
}
.btn:hover { background: #115aa8 !important; }
.btn[disabled] { opacity: 0.6; cursor: default; }

/* Small variant used in toolbars */
.mini {
  display: inline-flex !important;
  align-items: center !important;
  padding: 6px 8px !important;
  background: transparent !important;
  color: #115aa8 !important;
  border: 1px solid rgba(16,24,40,0.06) !important;
  border-radius: 6px !important;
  cursor: pointer;
  font-weight: 700;
}
.mini:hover { background: rgba(17,90,168,0.04); }

/* Ensure buttons don't shrink weirdly in header */
.header-right .btn, .header-right .mini { flex-shrink: 0; }

/* End of added styles */

/* ------------------- */
.leftBlocklyContent {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0; /* 内部スクロールを有効にするために必須 */
}

/* パネル（非表示時は hidden、表示時は flex コンテナ） */
#blocklyDiv, #scriptDiv, #courseDiv {
  box-sizing: border-box;
  padding: 8px;
  background: white;
  flex: 1 1 auto;
  min-height: 0;      /* 子要素が縮むことを許容 */
  width: 100%;
  overflow: hidden;   /* 内部でスクロールさせる */
  display: none;
}

/* 表示中は flex（縦方向）にして内部をレイアウトできるようにする */
#blocklyDiv.active, #scriptDiv.active, #courseDiv.active {
  display: flex;
  flex-direction: column;
}

/* エディタカードは親パネルの残りを占める flex コンテナにする */
.editorCard {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 8px;
  padding: 0; /* パネル側の padding と重複するなら調整 */
  box-sizing: border-box;
}

/* ヘッダ（ボタン群）は高さを確保して固定化 */
.editorCard .cardHeader {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 4px;
}

/* textarea はヘッダを除いた残りを確実に占める */
#scriptDiv textarea,
#courseDiv textarea,
#scriptDiv .editorBody,
#courseDiv .editorBody {
  flex: 1 1 auto;
  min-height: 0;         /* flex 内で正しく縮むために必須 */
  width: 100%;
  box-sizing: border-box;
  overflow: auto;
  resize: none;
  padding: 8px;
  border: 1px solid #ddd;
  background: transparent;
}

/* Blockly 描画領域も残りを占める（必要に応じて高さ設定） */
#blocklyDiv {
  /* Blockly の描画が伸びるようにする */
  align-items: stretch;
}

/* safety: 親が min-height:0 を持たないと内部スクロールが効かないので確認 */
#pageFrame, #pageBlockly, .pageBlocklyBody {
  min-height: 0;
}
        /* ------------------- */
/* タブのみ（差分）: 非選択は薄い背景、hover は少し濃く、選択はパネルとシームレス接続 */
.headBlockly {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 0 8px;
  margin: 0;
}

/* 全タブを同じ高さに揃える */
.headBlockly .tab {
  -webkit-appearance: none;
    appearance: none;
  background: rgba(25,118,210,0.10);
  border: 1px solid transparent;
  padding: 0 7px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  color: #6b7280;
  font-weight: 700;
  position: relative;
  z-index: 2;
}

/* 非選択タブ hover: 少し濃くする */
.headBlockly .tab:not(.selected):hover {
    background: #e6eef8;
    color: inherit;
}

/* 選択タブ: 影・下バーを消してパネルと密着 */
.headBlockly .tab.selected {
  background: #ffffff;
  color: #115aa8;
  border: 1px solid #e5e7eb;
  border-bottom-color: transparent; /* パネルとつなげる */
  box-shadow: none;
  z-index: 3;
}

/* 念のため既存の疑似要素は無効化 */
.headBlockly .tab.selected::after { display: none; }

/* headBlockly 内の .mini がタブに見えないように */
.headBlockly .mini {
  background: transparent;
  border: 1px solid transparent;
  color: #6b7280;
}
        /* ------------------- */

/* css */
/* statusArea 全体を stretch させ、横スクロール対策も維持 */
.pageBlocklyBody > div:last-child .statusArea {
  display: flex;
  gap: 12px;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden; /* 横スクロールを防ぐ */
}

/* stateCard: 縦方向の flex にして #state を残り全部に */
.pageBlocklyBody > div:last-child .statusArea .stateCard {
  display: flex;
  flex-direction: column;
  flex: 0 0 200px; /* 左カラム幅（必要なら調整） */
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
}

/* #state がカード内で残り高さを占有 */
#state {
    font-size: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  box-sizing: border-box;
  white-space: pre-wrap;

    border: 1px solid #ddd;
    border-radius: 6px;

    padding: 5px;
    margin: 0
}

/* logCard を縦方向の flex にしてヘッダ固定、本文を伸ばす */
.pageBlocklyBody > div:last-child .statusArea .logCard {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
}

/* ログの上部ボタン群は固定 */
.pageBlocklyBody > div:last-child .statusArea .logCard .cardHeader {
  flex: 0 0 auto;
  box-sizing: border-box;
}

/* textarea（.logInput 等）はヘッダを除いた残り全部を占める */
.pageBlocklyBody > div:last-child .statusArea .logCard .logInput,
.pageBlocklyBody > div:last-child .statusArea .logCard textarea {
  flex: 1 1 auto;
  height: auto !important;
  min-height: 0;
  overflow: auto;
  width: 100%;
  box-sizing: border-box;
}

/* safety: flex 内で子が潰れないように */
.pageBlocklyBody > div:last-child .statusArea,
.pageBlocklyBody > div:last-child .statusArea > * {
  min-height: 0;
  min-width: 0;
}

/* Small improvements for index login card */
.card .btn {
  width: 100%;
  justify-content: center;
}
.field input[type="text"], .field input[type="password"] {
  width: 100%;
}

/* Center header text on index page header if it's simple title-only page */
/* But keep mypage header layout unaffected */
body.page-index header, .page-index header { text-align: center; }

/* End small improvements */

/* group for course label + select to keep them inline */
.courseGroup {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.courseGroup label { margin: 0; }
.courseGroup select { flex: 0 0 auto; }
