/* ==========================================================================
   基本スタイル
   ========================================================================== */

/* 基本レイアウトの設定 */
html,
body {
  font-family: "Noto Sans JP", sans-serif;
  height: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* リンクとファイル項目のスタイル */
li a,
li.my-file,
li.other-file,
li.admin-file {
  display: block;
  color: #175f40;
}

code {
  border-radius: 10px;
  font-size: 12px;
  font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
}

/* ==========================================================================
   エディタコンテナ
   ========================================================================== */

.editor_container {
  overflow-y: scroll;
  -ms-overflow-style: none; /* IE, Edge 対応 */
  scrollbar-width: none; /* Firefox 対応 */
}

.editor_container::-webkit-scrollbar {
  /* Chrome, Safari 対応 */
  display: none;
}

/* ==========================================================================
   ボタンスタイル
   ========================================================================== */

.btn-save-new {
  position: absolute;
  right: 75px;
  top: 5px;
}

.btn-save {
  position: absolute;
  right: 78px;
  top: 5px;
}

.btn-new {
  position: absolute;
  right: 145px;
  top: 5px;
}

.btn-reload {
  position: absolute;
  right: 10px;
  bottom: 5px;
}

.btn-stop {
  position: absolute;
  right: 48px;
  bottom: 5px;
}

.btn-run {
  position: absolute;
  right: 10px;
  top: 5px;
  z-index: 10;
}

/* ==========================================================================
   メニューシステム
   ========================================================================== */

.menu__item {
  font-size: small;
  background: #21885c;
  color: #fff;
  cursor: pointer;
  display: block;
  margin-bottom: 1px;
  position: relative;
}

.menu__item__link {
  color: #fff;
  display: block;
  padding: 3px;
}

.submenu {
  background: #fff;
  display: none;
}

.submenu__item {
  border-bottom: 1px solid #5200b7;
  color: #222;
  padding: 3px;
}

.my-file:hover,
.other-file:hover,
.admin-file:hover,
.currently-showing-menu {
  background: rgba(255, 0, 0, 0.1);
}

/* ==========================================================================
   エディタレイアウト
   ========================================================================== */

.editor-container {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.editor-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: #1e1e1e;
  transition: width 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-panel.with-result {
  width: 50%;
}

/* Ace Editor */
#editor {
  margin: 0;
  position: absolute;
  top: 35px;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: calc(100vh - 35px);
  line-height: 1.2em;
  font-size: 12px;
  border: none;
  outline: none;
  overflow: hidden; /* Ace Editor 内部でスクロールを管理 */
}

.ace-editor {
  border-radius: 0;
  width: 100% !important;
  height: 100% !important;
  overflow: hidden !important; /* 重要: Ace Editor 自体のオーバーフロー */
}

.ace-editor .ace_content {
  /* Ace Editor のコンテンツ部分 */
  pointer-events: auto;
}

.ace-editor .ace_scrollbar {
  /* スクロールバーの表示 */
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.ace-editor .ace_scrollbar .ace_scrollbar-inner {
  background: rgba(121, 121, 121, 0.4);
  border-radius: 3px;
}

.ace-editor .ace_scrollbar-v {
  /* 縦スクロールバー */
  width: 12px;
  right: 0;
}

.ace-editor .ace_scrollbar-h {
  /* 横スクロールバー */
  height: 12px;
  bottom: 0;
}

/* ==========================================================================
   結果パネル
   ========================================================================== */

.result-panel {
  position: fixed;
  top: 0;
  right: -50%;
  width: 50%;
  height: 100vh;
  background: #ffffff;
  transition: right 0.3s ease;
  z-index: 100;
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3);
}

.result-panel.active {
  right: 0;
}

.result-header {
  position: relative;
  height: 35px;
  background: #5d5d5d;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
}

.result-header span {
  color: white;
  font-size: 14px;
  font-weight: bold;
  margin: 0;
  position: relative;
}

.close-result-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
  position: relative;
}

.close-result-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.result-controls {
  position: absolute;
  top: 40px;
  right: 10px;
  z-index: 10;
}

.result-controls .btn {
  margin: 2px;
  font-size: 12px;
  padding: 4px 8px;
}

#preview {
  margin: 0;
  padding: 0;
  position: absolute;
  top: 35px;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: calc(100% - 35px);
  border: 0;
}

/* ==========================================================================
   フローティングボタン
   ========================================================================== */

/* ヒントボタン（左下固定） */
.hint-btn-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  transition: transform 0.3s ease;
}

.hint-btn-container.hidden {
  transform: translateY(100px);
}

.btn-hint-floating {
  background: #ff6d00;
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
}

.btn-hint-floating:hover {
  background: #e65100;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.floating-command-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: #007bff;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1002;
  transition: all 0.3s ease;
  color: white;
}

.floating-command-btn:hover {
  background: #0056b3;
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 123, 255, 0.6);
}

.floating-command-btn.panel-open {
  background: #28a745;
}

.floating-command-btn.panel-open:hover {
  background: #1e7e34;
}

.floating-command-btn i {
  font-size: 24px;
}

/* アプリ公開ボタン */
.app-publish-btn-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  transition: transform 0.3s ease;
}

.app-publish-btn-container.hidden {
  transform: translateY(100px);
}

.btn-copy {
  background: #3f9642;
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
}

.btn-copy:hover {
  background: #317935;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.insert-btn,
.clear-btn {
  padding: 4px 8px;
  font-size: 10px;
}

/* ==========================================================================
   モバイル対応
   ========================================================================== */

@media screen and (max-width: 768px) {
  /* エディタパネル */
  .editor-panel {
    height: 100vh;
  }

  .result-panel {
    width: 100%;
    right: -100%;
    height: 100vh;
  }

  .editor-panel.with-result {
    width: 100%;
    transform: translateX(-100%);
  }

  /* ボタン */
  .btn-run {
    width: 50px;
    height: 50px;
    right: 8px;
    top: 3px;
  }

  .btn-run i {
    font-size: 3rem !important;
  }

  .hint-btn-container {
    bottom: 15px;
    left: 15px;
  }

  .btn-hint-floating {
    padding: 10px 14px;
    font-size: 12px;
  }

  .app-publish-btn-container {
    bottom: 15px;
    right: 15px;
  }

  .btn-copy {
    padding: 10px 14px;
    font-size: 12px;
  }

  .btn-hint {
    padding: 3px 6px;
    font-size: 10px;
  }

  .mode-toggle-btn {
    width: 28px;
    height: 18px;
    font-size: 10px;
    margin-right: 3px;
  }

  .insert-btn,
  .clear-btn {
    padding: 4px 8px;
    font-size: 10px;
  }

  /* Ace Editor モバイル対応 */
  .ace_editor {
    touch-action: manipulation;
    overflow: hidden !important;
  }

  .ace_text-input {
    font-size: 16px !important; /* iOSでズームを防ぐ */
  }

  .ace_content {
    touch-action: pan-y pan-x !important; /* スクロールを有効化 */
  }

  .ace_layer {
    touch-action: pan-y pan-x !important; /* コード行でのスクロールを有効化 */
  }

  #editor {
    cursor: text;
    -webkit-user-select: text;
    user-select: text;
    position: relative;
    touch-action: pan-y pan-x; /* モバイルでのスクロールを許可 */
  }

  /* テキスト選択の制御 */
  body {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }

  /* エディタ部分だけテキスト選択可能 */
  #editor,
  #editor * {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
  }

  .modal {
    width: 90%;
  }

  h3 {
    font-size: 2rem;
  }

  h5 {
    font-size: 1.4rem;
  }
}

.ace_editor.ace_autocomplete {
  left: 50px !important;
  /* width: 100% !important; */
  max-height: 300px !important;
}

.collapsible-body {
  padding: 10px;
}

.ace_mobile-menu {
  /* display: none !important; */
}
