/* ============================================================
   INDENT — ソースコード整形Webアプリ  スタイルシート
   ============================================================ */

/* ---------- リセット & ベース ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f7fa;
  color: #24292e;
  overflow: hidden;
}

/* ---------- ヘッダー ---------- */
.header {
  background: #ffffff;
  border-bottom: 1px solid #e1e4e8;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

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

.header-logo {
  height: 32px;
  width: auto;
}

.header-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #24292e;
}

/* ---------- モバイルタブ ---------- */
.mobile-tabs {
  display: none;
  background: #ffffff;
  border-bottom: 1px solid #e1e4e8;
  flex-shrink: 0;
}

.mobile-tab {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: #586069;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.mobile-tab.active {
  color: #0366d6;
  border-bottom-color: #0366d6;
}

/* ---------- メインエリア ---------- */
.main {
  display: flex;
  flex: 1;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ---------- ペイン共通 ---------- */
.pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.pane-input {
  border-right: 1px solid #e1e4e8;
}

/* ---------- ツールバー ---------- */
.pane-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fafbfc;
  border-bottom: 1px solid #e1e4e8;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.toolbar-btn {
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid #d1d5da;
  border-radius: 6px;
  background: #ffffff;
  color: #24292e;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.toolbar-btn:hover {
  background: #f3f4f6;
  border-color: #bbb;
}

.btn-primary {
  background: #0366d6;
  color: #fff;
  border-color: #0366d6;
}

.btn-primary:hover {
  background: #0255b3;
}

.toolbar-label {
  font-size: 13px;
  color: #586069;
  margin-right: auto;
}

#language-select {
  padding: 5px 10px;
  font-size: 13px;
  border: 1px solid #d1d5da;
  border-radius: 6px;
  background: #ffffff;
  color: #24292e;
  cursor: pointer;
  max-width: 180px;
}

/* ---------- スクロールエリア ---------- */
.code-scroll-area {
  flex: 1;
  overflow: auto;
  background: #ffffff;
}

/* ---------- コードテーブル（行番号とコードの高さ同期用） ---------- */
.code-table {
  border-collapse: collapse;
  width: 100%;
  min-height: 100%;
}

.code-table td {
  vertical-align: top;
  padding: 0;
}

/* ---------- 行番号 ---------- */
.line-numbers {
  width: 48px;
  min-width: 48px;
  padding: 12px 8px 12px 0;
  text-align: right;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #bbb;
  background: #fafbfc;
  border-right: 1px solid #e1e4e8;
  user-select: none;
  white-space: pre;
}

/* ---------- コードセル ---------- */
.code-cell {
  position: relative;
  width: 100%;
}

/* ---------- レイヤーラッパー（入力ペイン用: textarea + highlight重ね） ---------- */
.code-layer-wrapper {
  position: relative;
  min-height: 100%;
}

/* ---------- textarea（入力） ---------- */
.code-textarea {
  display: block;
  width: 100%;
  min-height: 100%;
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 13px;
  line-height: 1.5;
  border: none;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: #24292e;
  resize: none;
  overflow: hidden;
  white-space: pre;
  tab-size: 2;
  -moz-tab-size: 2;
  position: relative;
  z-index: 2;
}

.code-textarea::placeholder {
  color: #aab0b8;
}

/* ---------- ハイライト表示 (pre > code) ---------- */
.code-highlight {
  margin: 0;
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  overflow: visible;
  background: transparent !important;
  pointer-events: none;
  min-height: 100%;
  word-break: keep-all;
  overflow-wrap: normal;
}

.code-highlight code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  background: transparent !important;
  padding: 0 !important;
}

/* 入力ペインのハイライトは textarea の背後に絶対配置 */
.pane-input .code-highlight {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1;
  pointer-events: none;
}

/* 出力ペインのハイライト */
.output-highlight {
  pointer-events: auto;
}

/* ---------- エラーメッセージ ---------- */
.error-message {
  padding: 16px 20px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 14px;
  border-top: 1px solid #fecaca;
}

.error-message[hidden] {
  display: none;
}

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: #1b1f23;
  color: #ffffff;
  padding: 10px 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- ダウンロードモーダル ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: #ffffff;
  border-radius: 12px;
  padding: 28px 32px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #d1d5da;
  border-radius: 6px;
  outline: none;
  margin-bottom: 20px;
}

.modal-input:focus {
  border-color: #0366d6;
  box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.15);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- ドラッグ＆ドロップ ---------- */
.pane-input.drag-over .code-scroll-area {
  outline: 3px dashed #0366d6;
  outline-offset: -3px;
  background: #f0f7ff;
}

/* ============================================================
   レスポンシブ
   ============================================================ */

/* タブレット */
@media (max-width: 1024px) {
  .pane {
    flex: 1 1 50%;
  }
}

/* スマホ */
@media (max-width: 640px) {
  .main {
    height: calc(100vh - 56px - 44px);
  }

  .mobile-tabs {
    display: flex;
  }

  .main {
    flex-direction: column;
  }

  .pane {
    display: none;
    flex: 1;
  }

  .pane.active {
    display: flex;
  }

  .pane-input {
    border-right: none;
  }
}
