/* styles.css */
/* ============================= */
/* ======== ベーススタイル ======== */
/* ============================= */

body {
  font-family: sans-serif;
  background: #f0f0f5;
  color: #000000;
  padding: 20px;
  margin: 0;
  transition: background 0.3s, color 0.3s;
}

/* テーマ切替ボタン */
.theme-toggle {
  background: transparent;
  border: none;
  font-size: 1em;
  cursor: pointer;
  padding: 0.3em;
}

/* ── 各セクション共通スタイル ───────────────────────────────────────── */
.section {
  background: #ffffff;
  border-radius: 8px;
  padding: 1em;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: background 0.3s, box-shadow 0.3s;
  height: auto;
  max-height: none;
}

/* details をセクションとして使う場合 */
details.section {
  padding: 1em;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}


/* ── タグ検索入力欄 ───────────────────────────────────────── */
#tag-search-input {
  padding: 0.5em;
  border-radius: 5px;
  border: 1px solid #ccc;
  background: #f9f9ff;
  color: #000;
}

/* ── 補完スペース用スタイル ───────────────────────────────────────── */
.extra-section {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.load-extra-button,
.delete-extra-button {
  background-color: #2563eb;
  color: white;
  border: none;
  padding: 0.4em;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
}

.delete-extra-button {
  background-color: #ef4444;
}

.delete-extra-button:hover {
  background-color: #c53030;
}

/* ── 🛠️ タグ編集欄：表示レイアウト・操作UI ─────────────────────────── */

/* 個々のタグカード */
.tag {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  background: #3b82f6;
  color: #fff;
  font-size: 1.1em;
  padding: 0.6em 1em;
  border-radius: 1em;
  border: 2px solid #ffffff44;
  min-width: 240px;
  max-width: 300px;
  width: 100%;
}

/* 括弧強調（positive） */
.tag.positive {
  background: #c7eaff;
  border-color: #3b82f6;
}

/* 括弧抑制（negative） */
.tag.negative {
  background: #ffe0e0;
  border-color: #dc2626;
}

/* コロン形式 */
.tag.colon {
  background: #e6ffcc;
  border-color: #84cc16;
  color: #000000;
}

/* 上段：☰ ドラッグアイコン */
.tag > .drag-handle {
  display: inline-block;
  vertical-align: middle;
}

/* 下段：weightとボタンを並べる */
.tag::after {
  content: "";
  display: table;
  clear: both;
}

.tag .weight,
.tag .weight-input,
.tag .plus-btn,
.tag .minus-btn,
.tag .remove-btn {
  margin-top: 0.2em;
}

/* weightと入力欄 */
.tag .weight,
.tag .weight-input {
  float: left;
  font-size: 1.1em;
  min-width: 2.6em;
  text-align: right;
}

/* 操作ボタン類 */
.tag .plus-btn,
.tag .minus-btn,
.tag .remove-btn {
  float: right;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 0.6em;
  width: 2.6em;
  height: 2.4em;
  font-size: 1.1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s;
  padding: 0;
  margin-left: 0.3em;
}

/* ボタングループの折返し防止 */
.tag-buttons {
  display: flex;
  gap: 0.4em;
  justify-content: flex-end;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* タグ内の編集入力欄 */
.tag input {
  font-size: 1.05em;
  border: none;
  background: transparent;
  color: inherit;
  width: 100%;
  box-sizing: border-box;
  padding: 0.2em 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 和訳表示欄（tag-translation） */
.tag-translation {
  font-size: 0.75em;
  color: #ddd;
  margin-top: -0.2em;
  margin-left: 0.2em;
}


/* =============================== */
/* 🎚️ ウェイト表示（表示・編集モード） */
/* =============================== */

.tag .weight {
  font-size: 1.1em;              /* タグと揃えたサイズ */
  margin-left: 0.5em;
  color: #ffffffcc;              /* 白に近いグレーで視認性良好 */
  cursor: pointer;
  flex-shrink: 0;
  min-width: 2.6em;
  text-align: right;
}

.tag .weight.editing {
  display: none;
}

.tag .weight-input {
  display: none;
  width: 3em;
  font-size: 1.1em;
  margin-left: 0.5em;
  padding: 0.1em;
  text-align: right;
  border: 1px solid #ccc;
  border-radius: 0.4em;
  background: #fff;
  color: #000;
}

/* ======================== */
/* 🏷️ カテゴリラベル（明示） */
/* ======================== */

.category-label {
  font-weight: bold;
  color: #ffffff;
}

/* 冗長なので body .category-label は不要（上で十分） */

/* ====================== */
/* 🔘 ボタン共通デザイン */
/* ====================== */

button {
  padding: 0.6em 1.2em;
  border-radius: 8px;
  font-weight: bold;
  transition: all 0.2s ease-in-out;
}

button:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

/* ============================= */
/* 🏷️ タグ名表示（extra一覧用） */
/* ============================= */

/* ✅ 修正: タグ名表示の .extra-label を1行制限＆太字に統一 */
.extra-label {
  font-size: 16px;
  line-height: 1.4;
  font-weight: bold;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.extra-top-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-bottom: 0.3em;
}

.extra-check {
  transform: scale(1.2);
  cursor: pointer;
  margin: 0;
}


/* ===================== */
/* ⏬ details要素 summary */
/* ===================== */

details > summary {
  font-weight: bold;
  cursor: pointer;
  margin-bottom: 0.5em;
}


/* タグ内のボタン（+ - ×） */
.tag button {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 0.6em;
  width: 2.6em;
  height: 2.6em;  /* ← 高さも少し大きめに */
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s;
  padding: 0;
}

.tag-buttons {
  display: flex;
  justify-content: space-between;
  gap: 0.6em;
}


.tag button:hover {
  background: #c53030;
}

/* ── ドラッグハンドル用スタイル ───────────────────────────────────────── */
.drag-handle {
  cursor: grab;
  margin-right: 0.4em;
  font-size: 1em;
  color: #666;
}

body .drag-handle {
  color: #aaa;
}

/* コロン形式タグ：ダークモードでも濃い緑背景＋明るい文字色 */
body .tag.colon {
  background: #335533 !important;
  border-color: #84cc16 !important;
  color: #eaffea !important;
}

/* ── 共通ボタン／入力欄スタイル ───────────────────────────────────────── */
button,
select,
input[type="text"],
input[type="file"] {
  width: 100%; /* ← 追加：親要素いっぱいに広げる */
  padding: 0.5em;
  border-radius: 5px;
  border: 1px solid #ccc;
  background: #ffffff;
  color: #000000;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
  box-sizing: border-box; /* ← 追加：paddingも含めて整える */
}


button:hover {
  background: #e2e8f0;
}

/* ============================= */
/* ===== 共通UI配色・装飾スタイル ===== */
/* ============================= */

/* 全体背景・文字色 */
body {
  background: #1e1e2e;
  color: #e5e5e5;
}

/* ボタン・入力・選択 */
body button,
body select,
body input[type="text"],
body input[type="file"],
body input {
  background: #3a3a4a;
  border-color: #555;
  color: #e5e5e5;
}

body button:hover {
  background: #4b4b5b;
}

/* セクション・補完エリアなど */
body .section,
body .extra-section {
  background: #2a2a3a;
  color: #e5e5e5;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

/* タグ編集欄（拡張・ピン欄対応） */
body .tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  padding: 0.8em;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 6px;
  min-height: 250px;
  max-height: 800px;
  overflow-y: auto;
}

/* 📌 専用欄の見た目強調（任意） */
#pinned-prompt {
  border: 2px dashed gold;
  background: #2a2a2a;
}

/* タグの見た目 */
body .tag {
  background: #3a3f5f;
  border-color: transparent;
}

body .tag.positive {
  background: #2b6cb0;
  border-color: #90cdf4;
}

body .tag.negative {
  background: #a94442;
  border-color: #fc8181;
}

body .tag .weight {
  color: #ddd;
}

body .tag button {
  background: #9b2c2c;
}

body .tag button:hover {
  background: #822727;
}

/* プレースホルダー色 */
body input::placeholder,
body input[type="file"]::placeholder {
  color: #aaa;
}

/* チェックボックス色 */
body input[type="checkbox"] {
  accent-color: #90cdf4;
}

/* スクロールバー（Chrome） */
body ::-webkit-scrollbar {
  background: #444;
}
body ::-webkit-scrollbar-thumb {
  background: #888;
}

/* summaryタグの三角非表示（任意） */
details > summary {
  list-style: none;
}
details > summary::-webkit-details-marker {
  display: none;
}


/* === 補完スペース：コンパクトレイアウト === */
.extra-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5em;
  margin-bottom: 0.5em;
}

.extra-row select,
.extra-row button {
  flex: 1;
  padding: 0.4em 0.6em;
  font-size: 0.9em;
}

.checkbox-small label {
  font-size: 0.8em;
  display: flex;
  align-items: center;
  gap: 0.25em;
  margin-left: 0.25em;
}

.checkbox-small input[type="checkbox"] {
  transform: scale(0.85);
}


.extra-scroll-wrapper {
  flex: 1 1 auto;
  overflow-y: auto;
  height: auto;
}

/* === 補完スペース：画面に収まるよう縦スクロール制限 === */
.extra-scroll-wrapper {
  overflow-y: auto;
  max-height: calc(100vh - 200px);
  height: auto;
  box-sizing: border-box;
}

.extra-section {
  display: flex;
  flex-direction: column;
  height: auto;
  overflow: hidden;
}

/* ============================== */
/* 🧩 タグ検索・読み込み 横並びUI */
/* ============================== */
.section-search,
.section-input {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-bottom: 0.5em;
}

#tag-search-input,
#tag-input {
  flex: 1;
  padding: 0.4em;
  font-size: 0.9em;
}

/* ============================== */
/* 🛠️ タグ編集欄（DeepL風）＋統合修正 */
/* ============================== */
#prompt {
  width: 100%;
  min-height: 250px;
  max-height: 800px;
  overflow-y: auto;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 0.8em;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
}

/* ============================== */
/* 📐 レイアウト共通スタイル */
/* ============================== */
body {
  margin: 0;
  padding: 0;
  background: #1e1e2e;
  color: #e5e5e5;
  font-family: sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

/* ボタンや入力系の文字サイズ統一 */
button,
input,
select {
  font-size: 1em;
}

/* 📦 編集操作ボタン群の並び */
.bulk-controls {
  display: flex;
  gap: 0.5em;
  margin-bottom: 0.5em;
}

/* 任意: チェックボックス横の余白 */
.extra-check {
  margin-right: 0.5em;
}

/* ============================== */
/* 🔘 ボタン共通デザイン */
/* ============================== */
button {
  padding: 0.6em 1.2em;
  border-radius: 8px;
  font-weight: bold;
  transition: all 0.2s ease-in-out;
}
button:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

/* ============================== */
/* 🧱 セクションスタイル（背景＋枠） */
/* ============================== */
.section {
  border: 1px solid #444;
  padding: 1.2em;
  margin-bottom: 1em;
  border-radius: 12px;
  background: #222;
}

/* セクション見出しサイズ（任意） */
.section h2 {
  font-size: 0.8em;
  margin-bottom: 0.6em;
}

/* ✅ 出力ボックス改良：統一済みスタイル */
/* ✅ 修正: 出力ボックスのスタイルを最新版に統一 */
.prompt-output-box {
  font-size: 1.5em;
  line-height: 1.6;
  background: #101c30;
  border: 2px dashed #4a90e2;
  border-radius: 12px;
  color: #e6f0ff;
  padding: 1em;
  box-shadow: 0 0 8px #4a90e280;
  height: 200px;
  overflow-y: auto;
}

/* ✅ 修正: .tag-buttons の定義を一本化し、折返し禁止に統一 */
.tag-buttons {
  display: flex;
  gap: 0.2em;
  justify-content: flex-end;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.tag-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4em;
}

/* ✅ 修正: .weight-wrapper に表示/編集切替用の共通枠を設定 */
.weight-wrapper {
  position: relative;
  width: 3.4em;
  height: 2.4em;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.weight-wrapper .weight,
.weight-wrapper .weight-input {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  font-size: 1em;
  text-align: right;
  padding: 0;
  margin: 0;
  line-height: 1;
  box-sizing: border-box;
}

.weight-wrapper .weight-input {
  display: none;
  border: 1px solid #ccc;
  background: #fff;
  color: #000;
  border-radius: 0.3em;
  font-family: inherit;
  font-weight: normal;
  text-align: left;         /* ← 左寄せ */
  padding: 0 0.4em;         /* ← 左右に余白 */
  box-sizing: border-box;   /* ← パディング込みのサイズ管理 */
}

.weight-wrapper .weight.editing {
  display: none;
}

.weight-wrapper .weight-input.editing {
  display: block;
}


.tag-buttons button {
  width: 2.2em;
  height: 2.2em;
  font-size: 1.05em;
  border-radius: 0.4em;
  padding: 0;
  line-height: 1;
}

/* === 強制反映: 補完スペース改善用CSS === */
#extra-section {
  max-height: 60vh !important;
  overflow-y: auto !important;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  margin-bottom: 1em;
}

.output-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5em;
}

.tooltip {
  position: absolute;
  top: -2em;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75em;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

/* ✅ タグカードの統合済みスタイル（常時スクロール・固定高さ） */
#extra-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  justify-content: flex-start;
  align-items: flex-start;
  height: 60vh;           /* ← ✅ 高さを固定 */
  overflow-y: scroll;     /* ← ✅ 常に縦スクロールを表示 */
  padding: 0.5em;
  box-sizing: border-box;
}


/* ✅ 補完スペースのタグカード（サイズ完全固定・折り返し防止） */
.extra-item {
  width: 240px;
  height: 100px;
  flex: 0 0 240px;
  min-width: 240px;
  max-width: 240px;
  box-sizing: border-box;
  background-color: #2b2b2b;
  border: 1px solid #3c3c3c;
  border-radius: 8px;
  padding: 0.8em;
  margin: 0.2em;
  transition: background-color 0.3s, box-shadow 0.3s;
  box-shadow: 0 0 6px #00000033;
  font-size: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
}

/* ✅ タグ名：1行制限・フォント固定 */
/* ✅ 修正: タグ名表示の .extra-label を1行制限＆太字に統一 */
.extra-label {
  font-size: 16px !important;
  line-height: 1.4;
  font-weight: bold;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ✅ 補足：説明やカテゴリも1行制限 */
.description-text,
.category-label {
  font-size: 0.8em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ✅ ホバー時の視覚強調 */
.extra-item:hover {
  background-color: #3a3a3a;
  box-shadow: 0 0 8px #00ffccaa;
  cursor: pointer;
}

/* ✅ 一時的な追加アニメーション効果（クリック時の点滅） */
.extra-item.clicked {
  animation: flash-bg 0.4s ease-out;
}

@keyframes flash-bg {
  0% {
    background-color: #00ffcc55;
  }
  100% {
    background-color: transparent;
  }
}

/* ✅ 説明テキストがある場合の補足スタイル */
body .extra-item .description-text {
  font-size: 0.85em !important;
  color: #ffffff !important;
}

.file-input-group {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-bottom: 0.6em;
}

.file-input-group input[type="file"] {
  flex: 1;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.section-load-tags {
  display: flex;
  flex-direction: column;
  gap: 0.8em;
  align-items: center;
}

.tag-load-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  align-items: stretch;
}


#tag-input {
  width: 100%;
  padding: 0.5em;
  border-radius: 6px;
  border: 1px solid #ccc;
  box-sizing: border-box;
}

#load-tags-btn {
  width: 100%;
  padding: 0.5em 1.2em;
  white-space: nowrap;
}

/* ▼ 折りたたみセクション枠（セクションの囲み） */
.collapsible-section {
  border: 1px solid #444;
  border-radius: 8px;
  margin-bottom: 1em;
  overflow: hidden;
}

/* 📦 目次アイコン + メニューを右上に表示し、スクロール中も追尾 */
.bookmark-wrapper {
  position: sticky;
  top: 1.2em;
  z-index: 300;
  display: flex;
  justify-content: flex-end;
}

/* 🔘 目次アイコン */
.bookmark-toggle {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 1.4em;
  padding: 0.3em 0.4em;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  width: auto;
  height: auto;
  box-shadow: none;
  transition: background 0.3s ease;
}

.bookmark-toggle:hover {
  background: #333;
}

/* 📑 メニュー（アイコンの真下に展開） */
.bookmark-menu {
  position: absolute;
  top: 100%;
  right: 0;
  width: 10em;
  padding: 1em;
  background: #1e1e1e;
  border-left: 1px solid #444;
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.bookmark-menu.open {
  opacity: 1;
  visibility: visible;
}

/* ============================= */
/* 📌 ピン留めタグスタイル（主張を抑えたロック枠風） */
/* ============================= */
.tag.pinned {
  border: 2px dashed gold;
  box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.3); /* やわらかい縁取り */
  background: #2e2e2e; /* 通常と同じ背景色で自然に */
}

/* ============================= */
/* 🙈 非表示タグスタイル（ランプアイコン化） */
/* ============================= */
.tag.hidden {
  opacity: 0.5;
  filter: grayscale(80%);
  position: relative;
}

.tag.hidden::after {
  content: "🔴";
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 1.2em;
  opacity: 0.7;
  pointer-events: none;
}

/* 表示中タグにも🟢を表示したい場合（任意） */
/*
.tag:not(.hidden)::after {
  content: "🟢";
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 1.2em;
  opacity: 0.6;
  pointer-events: none;
}
*/

/* ============================= */
/* ピン／非表示トグルボタンデザイン（☰の横） - 小型版 */
/* ============================= */
.tag-top-bar {
  display: flex;
  align-items: center;
  gap: 0.3em;
  margin-bottom: 0.2em;
}

.tag .pin-toggle,
.tag .hide-toggle {
  background: transparent !important;
  border: none !important;
  font-size: 0.7em !important;
  color: #ccc !important;
  cursor: pointer;
  padding: 0 !important;
  width: 0.9em !important;
  height: 0.9em !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.tag .pin-toggle:hover,
.tag .hide-toggle:hover {
  opacity: 0.75 !important;
}

.site-wrapper {
  display: flex;
  justify-content: center;
  padding: 1em;
}

.addon-layout {
  max-width: 960px;
  width: 100%;
  box-sizing: border-box;
  position: relative;  /* ← 追加：アイコン配置の基準とする */
}

.site-header {
  text-align: center;
  margin: 1.5em auto 1em auto;
  max-width: 960px;
}

.site-header h1 {
  font-size: 1.6em;
  font-weight: bold;
  margin: 0;
  color: #ffffff;
}



/* オプション：折りたたみ時の背景色変化など必要なら追加可 */

.page-container {
  display: flex;
  flex-direction: row;
  max-width: 1280px;
  margin: 0 auto;
  gap: 1.5em;
  padding: 1em;
  box-sizing: border-box;
}

.left-sidebar {
  width: 250px;
  flex-shrink: 0;
  padding: 1em;
  background: #1a1a2a;
  color: #e5e5e5;
  border-right: 1px solid #444;
  position: sticky;
  top: 1em;
  height: calc(100vh - 2em);
  overflow-y: auto;
  font-size: 0.9em;
  line-height: 1.5;
}

.sidebar-section {
  margin-bottom: 1.5em;
}

.sidebar-section h3 {
  font-size: 1em;
  margin-bottom: 0.5em;
  border-bottom: 1px solid #555;
  padding-bottom: 0.3em;
  color: #f0f0f0;
}

.tips-card {
  background: #222;
  padding: 1.2em;
  border-radius: 10px;
  margin-bottom: 1.5em;
  box-shadow: 0 0 6px rgba(0,0,0,0.3);
}

.tips-card h2 {
  color: #fff;
  margin-top: 0;
}

.tips-card p {
  color: #ddd;
  font-size: 0.95em;
}

.tips-card a {
  color: #ffd966;
  font-weight: bold;
  text-decoration: none;
}

.tips-card a:hover {
  text-decoration: underline;
}

