/* ============================================================
   社内ツールUIシェル テンプレートCSS（gd-benri-navi styles.css から抽出・汎用化）
   角丸なし・背景透過・整数px罫線・小さくシャープなコントロールという
   デザイン原則に沿っている。SKILL.md の「デザイン原則」を読んだ上で使うこと。
   ============================================================ */

*, *::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）に統一し、サブピクセルレンダリングでの太さのばらつきを防ぐ。
   小数px（1.5px等）を使うと、ズーム率やディスプレイのDPRによって3本線の太さが
   バラバラに見えることがある。整数pxのルールはこの罫線含め全体で徹底する。 */
.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項目名を注入）。main.app-main の直下・.app の外側に置く
   フルブリード要素。帯自体は全幅に伸ばし、内側の .page-title だけ .app と同じ
   max-width/margin/水平paddingを持たせて、帯の下に続く .app のコンテンツと
   文字の左端を揃える（角丸・影は付けないミニマル方針）。 ===== */
.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;
}

/* ============================================================
   共通ボタン（プライマリ・アウトライン系）
   ============================================================ */
.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: 44px;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  padding: 0 14px;
  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 !important;
}

/* ============================================================
   一覧テーブル（利用者管理・マスタ管理などの管理画面共通。角丸12px・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 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-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;
}

.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;
  }
}

/* ============================================================
   コモンナビ固有の追加スタイル（アカウント管理画面）
   ============================================================ */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar-spacer {
  flex: 1;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-bar input[type="text"] {
  height: 38px;
  width: 220px;
}

.filter-select {
  height: 38px;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 14px;
  font-family: inherit;
  background: white;
}

/* 状態バッジ（有効/停止・管理者/一般・要変更） */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-active { background: #E6F4EA; color: #1E7B34; }
.badge-inactive { background: #f0f0f0; color: #888; }
.badge-admin { background: #FBE0CC; color: #b35a00; }
.badge-mustchange { background: #FFF4E9; color: #b35a00; border: 1px solid #EB6600; }

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
  color: #555;
}

/* 招待文（初期PW案内）モーダルのテキストエリア */
.invite-textarea {
  width: 100%;
  min-height: 160px;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: 'Roboto', 'Noto Sans JP', monospace;
  line-height: 1.6;
  resize: vertical;
  margin-bottom: 8px;
}

.invite-copy-status {
  font-size: 12px;
  color: #1E7B34;
  min-height: 16px;
  margin-bottom: 8px;
}

.generated-note {
  font-size: 12px;
  color: #d94040;
  margin-bottom: 12px;
}

.modal-wide {
  max-width: 480px;
}

.csv-table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 0.5px solid #ddd;
  border-radius: 8px;
  margin-bottom: 12px;
}

.csv-row-error td {
  background: #FFF3F0;
  color: #a33;
}

.csv-summary {
  font-size: 13px;
  color: #555;
  margin-bottom: 8px;
}

.csv-file-input {
  display: block;
  margin: 8px 0 4px;
}

.csv-step {
  margin-bottom: 12px;
}

/* 「戻る」リンク（change-password.htmlの?return=許可リスト一致時のみ表示） */
.return-link-banner {
  background: #FFF4E9;
  border-left: 3px solid #EB6600;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  color: #555;
  margin-bottom: 1.25rem;
}

.return-link-banner a {
  color: #EB6600;
  font-weight: 600;
}

/* マイページ（my.html）専用のカードレイアウト */
.mypage-card {
  background: white;
  border-radius: 16px;
  border: 0.5px solid #ddd;
  padding: 2rem 1.75rem;
  max-width: 480px;
  margin: 3rem auto;
}

.mypage-field {
  margin-bottom: 14px;
}

.mypage-field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #888;
  margin-bottom: 4px;
}

.mypage-field-value {
  font-size: 16px;
  color: #333333;
}

.mypage-links {
  margin-top: 20px;
  border-top: 1px solid #eee;
  padding-top: 16px;
}

.mypage-links a {
  display: block;
  padding: 10px 4px;
  color: #333333;
  text-decoration: none;
  font-size: 14px;
  border-bottom: 0.5px solid #eee;
}

.mypage-links a:last-child { border-bottom: none; }
.mypage-links a:hover { color: #EB6600; }
