/* ============================================================
   gd-bank-navi UIシェル styles.css
   （benri-navi-ui-shell スキルの雛形CSSをベースに、ユーザーのUI好みに合わせて調整）
   角丸なし・背景透過・整数px罫線・小さくシャープなコントロールを徹底する。
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ============================================================
   テーマトークン（CSS変数で一元管理する。ここだけ書き換えれば
   ボタン・リンク・ハイライト等の色が全て切り替わる）
   ============================================================ */
:root {
  --brand: #EB6600;        /* 元気でんきオレンジ */
  --brand-hover: #b35a00;  /* hover濃色 */
  --brand-tint: #FBE0CC;   /* 淡色1（バッジ等） */
  --brand-tint-2: #FBE0CC; /* 淡色2（トグルの部分選択状態等） */
  --charcoal: #333333;     /* サイドバー背景・本文色 */
}

body {
  background: #F4F4F1;
  font-family: 'Roboto', 'Noto Sans JP', 'Hiragino Kaku Gothic Pro', 'Meiryo', sans-serif;
  color: var(--charcoal);
  min-height: 100vh;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ============================================================
   アプリ全体レイアウト（サイドバー＋メインコンテンツ）
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

main.app-main {
  flex: 1;
  min-width: 0;
  padding: 0 0 2rem;
}

/* ===== サイドバー本体（nav.js が #app-nav に注入） =====
   position: sticky + height: 100vh でビューポートに固定する（PC）。ページ本体が
   縦に長くなっても、サイドバー自体は常にビューポート内に留まり、footer（利用者名・
   ログアウト等）が画面外へスクロールし去らないようにする。
   モバイル（@media max-width:640px）は position: fixed のオーバーレイに上書きされる。 */
.app-sidebar {
  width: 240px;
  min-width: 240px;
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--charcoal);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  /* 開閉ボタン（固定位置、top:16px、高さ26px）と垂直中心を合わせるため上端19px */
  padding: 19px 20px 24px;
}

.sidebar-logo svg {
  width: 100px;
  height: auto;
  display: block;
  color: #fff;
}

.sidebar-appname {
  width: 180px;
}

.sidebar-appname svg {
  width: 100%;
  height: auto;
  display: block;
  color: #fff;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
}

/* 管理者モードのサイドバー見出し（クリック不可のラベル。ミニマル基調） */
.sidebar-section-label {
  padding: 8px 14px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #888;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  border-radius: 0;
  border-left: 3px solid transparent;
  color: #ccc;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(235, 102, 0, 0.18);
  border-left-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-password-link {
  display: block;
  font-size: 12px;
  color: #999;
  text-decoration: none;
  margin-bottom: 8px;
}

.sidebar-password-link:hover {
  color: #fff;
  text-decoration: underline;
}

.sidebar-admin-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #999;
  text-decoration: none;
}

.sidebar-admin-gear {
  display: inline-flex;
  align-items: center;
  font-size: 17px;
  line-height: 1;
}

.sidebar-admin-link:hover {
  color: #fff;
  text-decoration: underline;
}

.sidebar-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #999;
}

.sidebar-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-row-noname .sidebar-user-name {
  display: none;
}

.sidebar-logout-link {
  color: #999;
  text-decoration: none;
  white-space: nowrap;
}

.sidebar-logout-link:hover {
  color: #fff;
  text-decoration: underline;
}

/* ===== ハンバーガー開閉ボタン（nav.js が注入。常時固定表示。完全透過＝背景なし） ===== */
.nav-toggle-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1100;
  width: 26px;
  height: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

/* 3本線は整数px（2px）に統一し、サブピクセルレンダリングでの太さのばらつきを防ぐ。 */
.nav-toggle-bar {
  display: block;
  width: 12px;
  height: 2px;
  border-radius: 0;
  background: #333333; /* 既定色（モバイル：閉＝明るいメインコンテンツ上）は濃色 */
  transition: background 0.15s;
}

/* PC: サイドバーは既定で開＝ボタンはダークサイドバー上に重なるため白線。
   折りたたみ時（サイドバー非表示＝明るい背景上）は濃色に切り替える。 */
@media (min-width: 641px) {
  .nav-toggle-bar {
    background: #fff;
  }
  body.sidebar-collapsed .nav-toggle-bar {
    background: #333333;
  }
}

.nav-toggle-btn:hover .nav-toggle-bar {
  background: var(--brand);
}

/* ===== モバイル用backdrop（nav.js が注入。PCでは非表示のまま） ===== */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 900;
}

/* PC: サイドバー折りたたみ（幅0へアニメーション） */
body.sidebar-collapsed .app-sidebar {
  width: 0;
  min-width: 0;
}

/* PC・サイドバー折りたたみ時: ハンバーガーボタンがヘッダーバンド帯の上に乗るため、
   タイトル文字の開始位置をボタンの右端より外側まで下げて重ならないようにする */
body.sidebar-collapsed .page-title-band .page-title {
  padding-left: 56px;
}

/* ===== メインコンテンツ最上部のヘッダーバンド（nav.js が #page-title へ
   サイドメニューのactive項目名を注入）。角丸・影は付けないミニマル方針。 ===== */
.page-title-band {
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
}

.page-title-band .page-title {
  display: block;
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 1.5rem;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ============================================================
   共通ボタン（プライマリ・アウトライン系）
   ベンリナビ（gd-benri-navi）の角丸ボタン意匠に統一（radius 8px・1.5px罫線）。
   ============================================================ */
.btn-primary {
  height: 38px;
  padding: 0 20px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--brand-hover);
}

.btn-primary:disabled {
  background: #aaa;
  cursor: not-allowed;
}

.btn-outline {
  height: 38px;
  padding: 0 20px;
  background: white;
  color: var(--brand);
  border: 1.5px solid var(--brand);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-outline:hover {
  background: var(--brand);
  color: white;
}

/* テキスト入力・パスワード入力の共通スタイル */
input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"] {
  height: 40px;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 15px;
  font-family: inherit;
  background: white;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="number"]:focus {
  border-color: var(--brand);
}

.error-msg {
  color: #d94040;
  font-size: 14px;
  margin-top: 8px;
}

.hidden {
  display: none;
}

/* ============================================================
   一覧テーブル（マスタ管理・台帳などの管理画面共通）
   ベンリナビの .dm-table に合わせ、外枠を角丸+overflow:hiddenで丸める。
   内部の行区切りは0.5px罫線のまま（薄い区切り線として意図的に使用）。
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 0.5px solid #ddd;
  border-radius: 12px;
  overflow: hidden;
  font-size: 14px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 0.5px solid #eee;
  vertical-align: middle;
}

/* ============================================================
   横スクロールラッパー（幅広テーブルのモバイル対応・標準解）
   外枠の角丸・線をラッパー側へ寄せ、内側の.data-tableは素の矩形にする
   （ベンリナビ .ua-table-wrap と同じ考え方）。
   デスクトップ／タブレット幅では従来どおり折り返しに任せて100%幅に収める
   （幅に余裕がありnowrapにする必要が無いため、既存の見え方を変えない）。
   狭い画面（640px以下）だけ white-space:nowrap にして、CJKテキストが
   コンテナ幅に押し潰されて1文字ずつ縦に折り返す不具合を防ぎ、代わりに
   横スクロールで内容幅ぶん見られるようにする。
   長文セル（対応メモの概要等）は個別に white-space: normal で
   上書きすること（correspondence.html の .summary-cell 参照）。
   ============================================================ */
.table-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 0.5px solid #ddd;
  border-radius: 12px;
}

.table-scroll-wrap .data-table {
  border: none;
  border-radius: 0;
}

@media (max-width: 640px) {
  .table-scroll-wrap .data-table {
    width: auto;
    min-width: 100%;
  }

  .table-scroll-wrap .data-table th,
  .table-scroll-wrap .data-table td {
    white-space: nowrap;
  }
}

.data-table thead th {
  background: #f5f5f0;
  color: #555;
  font-size: 12px;
  font-weight: 600;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.op-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1.5px solid #ccc;
  background: white;
  color: #555;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  margin-right: 6px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.op-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.op-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   モーダル（確認ダイアログ・追加/編集ポップアップ共通）
   ベンリナビの .modal / .pt-modal に合わせ、12px角丸に統一。
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

/* .hidden単体（詳細度0,1,0）は.modal-overlayのdisplay:flex（同詳細度・後勝ち）に
   打ち消されてしまうため、.modal-overlay.hiddenとして詳細度を上げて確実に非表示にする。
   これが無いと、開いていないはずのモーダルも常時表示され続け、複数モーダルが
   重なって見える／背面のボタンが操作不能になる不具合が発生する。 */
.modal-overlay.hidden {
  display: none;
}

.modal {
  background: white;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.modal-title {
  font-size: 13px;
  color: var(--charcoal);
  line-height: 1.5;
  margin-bottom: 14px;
}

.modal-error {
  font-size: 12px;
  color: #d94040;
  min-height: 16px;
  margin-bottom: 8px;
}

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

.modal-actions .btn-primary,
.modal-actions .btn-outline {
  width: auto;
}

/* フォームラベル（値との視認差をつけるための控えめな見出しスタイル） */
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #888;
  margin: 12px 0 4px;
}

.form-label:first-child {
  margin-top: 0;
}

/* ============================================================
   モバイル対応（640px以下）
   ============================================================ */
@media (max-width: 640px) {
  .app {
    padding: 1.5rem 1rem;
  }

  /* サイドバーはオーバーレイ表示（既定は閉＝画面外） */
  .app-layout {
    display: block;
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    min-width: 240px;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  /* モバイル: サイドバー開時はボタンがダークオーバーレイ上に重なるため白線 */
  body.sidebar-open .nav-toggle-bar {
    background: #fff;
  }

  /* PC由来の sidebar-collapsed クラスが残っていても、モバイルでは
     transform による開閉のみを表示制御に使う（width:0 との競合を断つ） */
  body.sidebar-collapsed .app-sidebar {
    width: 240px;
    min-width: 240px;
  }

  main.app-main {
    padding: 0 0 1.5rem;
  }

  .page-title-band .page-title {
    padding-left: 56px;
  }

  /* モーダル: 画面幅いっぱい（左右マージンを詰める）・高さは内部スクロールに任せる。
     各ページ固有の .modal-wide / .modal-detail / .modal-medium（840/760/560px等）は
     max-widthを上書きしてモバイルでは常に画面幅基準にする。 */
  .modal-overlay {
    padding: 10px;
  }

  .modal,
  .modal-wide,
  .modal-detail,
  .modal-medium {
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }

  /* .modal（基底）は元々max-height指定が無く、縦の狭い端末では保存ボタンが
     画面外に出ることがあった。.modal-detail/.modal-medium と同じ85vh基準に揃え、
     内部スクロールで保存ボタンまで届くようにする。 */
  .modal,
  .modal-detail,
  .modal-medium {
    max-height: 85vh;
    overflow-y: auto;
  }

  /* フォームの2/3カラムグリッド（各ページ固有 .two-col/.three-col）は
     1カラムに積む。grid-template-columnsで1frを複数並べる指定は、
     内包するinput/select等の最小コンテンツ幅ぶんモーダル自体を
     画面幅より広げてしまう（横溢れ）ため、ここで一括して1列に潰す。 */
  .two-col,
  .three-col {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   モバイル対応（480px以下・より狭い画面向けの追加調整）
   ============================================================ */
@media (max-width: 480px) {
  .modal-overlay {
    padding: 8px;
  }
}

/* ============================================================
   プレースホルダー（S1-1: UIシェルのみ。各画面の実装は以降のフェーズ）
   ============================================================ */
.placeholder-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  padding: 32px 24px;
  color: #888;
  font-size: 14px;
  text-align: center;
}

/* ============================================================
   メニュー設定画面（menu-settings.html。ネイティブHTML5 Drag and Dropで並べ替え。
   外部ライブラリ不使用・gd-benri-navi の menu-settings.js（コミット549d832）と同方式。
   角丸なし・1px罫線で既存管理画面のトーンに揃える）
   ============================================================ */
.ms-note {
  font-size: 12px;
  color: #777;
  line-height: 1.6;
  margin-bottom: 14px;
}

.ms-list {
  border: 1px solid #ddd;
  background: white;
}

.ms-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
}

.ms-row:last-child {
  border-bottom: none;
}

.ms-row-label {
  font-size: 14px;
  color: var(--charcoal);
}

/* ドラッグハンドル（gd-benri-navi の .ms-drag-handle/.rb-item-drag-handle と同型）。
   ドラッグ起点をこのハンドルに限定し、行本体はdraggableにしない。 */
.ms-drag-handle {
  display: inline-block;
  width: 24px;
  height: 24px;
  line-height: 24px;
  border: 1px solid #ccc;
  background: #fff;
  color: #999;
  font-size: 14px;
  text-align: center;
  cursor: grab;
  user-select: none;
  flex: none;
}

.ms-drag-handle:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.ms-drag-handle:active {
  cursor: grabbing;
}

/* ドラッグ中の行本体は半透明にして、ドラッグ操作中であることを分かりやすくする。 */
.ms-row.dragging {
  opacity: 0.4;
}

/* ドロップ先の挿入位置インジケータ（対象行の上端/下端に太い枠線を出す）。 */
.ms-row.ms-drop-before {
  box-shadow: inset 0 2px 0 0 var(--brand);
}

.ms-row.ms-drop-after {
  box-shadow: inset 0 -2px 0 0 var(--brand);
}

.ms-empty {
  font-size: 13px;
  color: #999;
  padding: 12px 0;
  text-align: center;
}

.ms-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.ms-status {
  font-size: 13px;
  color: var(--brand);
}
