/* コンプラナビ styles.css
   デザイン原則（benri-navi-ui-shellスキル踏襲・社内標準の好み）:
   角丸なし（浮き要素のログインカード等のみ例外）・背景透過・整数px罫線・
   コントロールは小さくシャープ・見出しは控えめ・色はCSS変数で一元管理。 */

:root {
  --brand: #EB6600;
  --brand-hover: #b35a00;
  --brand-tint: #FBE0CC;
  --ink: #333333;
  --border: #ddd;

  --sig-green: #067d3c;
  --sig-green-bg: #e6f7ec;
  --sig-yellow: #92610a;
  --sig-yellow-bg: #FFF4D6;
  --sig-yellow-border: #E3A008;
  --sig-red: #c0392b;
  --sig-red-bg: #fdecea;
  --sig-none: #888;
  --sig-none-bg: #ececec;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: #F4F4F1;
  color: var(--ink);
  font-family: 'Noto Sans JP', 'Roboto', 'Hiragino Kaku Gothic Pro', 'Meiryo', sans-serif;
}

a { color: var(--brand); }

.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;
  display: flex;
  flex-direction: column;
}

.app-sidebar {
  width: 240px;
  min-width: 240px;
  height: 100vh;
  position: sticky;
  top: 0;
  background: #333333;
  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;
  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-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-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;
}

.nav-toggle-bar {
  display: block;
  width: 12px;
  height: 2px;
  border-radius: 0;
  background: #333333;
  transition: background 0.15s;
}

@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); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 900;
}

body.sidebar-collapsed .app-sidebar { width: 0; min-width: 0; }
body.sidebar-collapsed .page-title-band .page-title { padding-left: 56px; }

/* ===== ページ見出し帯 ===== */
.page-title { font-size: 18px; font-weight: 600; letter-spacing: 0.02em; }
.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; }

/* ===== 常時表示の免責フッター（設計書§5・全画面共通） ===== */
.disclaimer-footer {
  margin-top: auto;
  padding: 10px 1.5rem;
  font-size: 12px;
  color: #888;
  border-top: 1px solid #e5e5e5;
  background: #fff;
}

/* ============================================================
   ダッシュボード
   ============================================================ */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 1.6rem;
}

.summary-card {
  background: #fff;
  border: 0.5px solid var(--border);
  padding: 16px 18px;
}

.summary-card-label { font-size: 12px; color: #777; margin-bottom: 6px; }
.summary-card-value { font-size: 28px; font-weight: 700; }
.summary-card-value small { font-size: 13px; font-weight: 500; color: #777; margin-left: 4px; }

.summary-breakdown { margin-top: 8px; font-size: 12px; color: #555; }
.summary-breakdown-row { display: flex; justify-content: space-between; padding: 2px 0; }

.section-heading {
  font-size: 15px;
  font-weight: 600;
  margin: 1.8rem 0 0.6rem;
}

.section-heading:first-child { margin-top: 0; }

.dashboard-table-wrap {
  background: #fff;
  border: 0.5px solid var(--border);
}

/* ============================================================
   テーブル（カバレッジ一覧・満了間近一覧・契約書一覧 共通）
   ============================================================ */
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table th,
table.data-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

table.data-table th {
  font-size: 11px;
  color: #777;
  font-weight: 600;
  background: #fafafa;
  position: sticky;
  top: 0;
}

table.data-table tbody tr:hover { background: #FBE0CC33; }
table.data-table tbody tr.clickable { cursor: pointer; }

.table-scroll { overflow-x: auto; }

.empty-row td { color: #999; text-align: center; padding: 24px; }

/* ステータスバッジ */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 0;
  white-space: nowrap;
}
.badge-expired { background: var(--sig-red-bg); color: var(--sig-red); }
.badge-soon { background: var(--sig-yellow-bg); color: var(--sig-yellow); border: 1px solid var(--sig-yellow-border); }
.badge-ok { background: var(--sig-green-bg); color: var(--sig-green); }
.badge-none { background: var(--sig-none-bg); color: var(--sig-none); }
.badge-no-contract { background: var(--sig-red-bg); color: var(--sig-red); }
.badge-has-contract { background: #eee; color: #555; }
.badge-excluded { background: #eee; color: #999; }
.badge-auto-renew { background: var(--brand-tint); color: var(--brand); }

/* ============================================================
   フィルタ行（カバレッジ一覧）
   ============================================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 1rem;
}

.filter-bar label { font-size: 12px; color: #555; }

.filter-bar select {
  height: 34px;
  border: 1px solid #ccc;
  border-radius: 0;
  padding: 0 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}

.filter-checkbox { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #555; }

.filter-count { font-size: 12px; color: #777; margin-left: auto; }

/* ============================================================
   取引先詳細
   ============================================================ */
.partner-header {
  background: #fff;
  border: 0.5px solid var(--border);
  padding: 16px 20px;
  margin-bottom: 1.4rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.partner-header-name { font-size: 18px; font-weight: 700; }
.partner-header-code { font-size: 12px; color: #777; }
.partner-header-kubun { font-size: 12px; color: #555; }

.placeholder-box {
  background: #fafafa;
  border: 0.5px dashed var(--border);
  padding: 16px 18px;
  color: #888;
  font-size: 13px;
}

.back-link { display: inline-block; margin-bottom: 1rem; font-size: 13px; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

/* ============================================================
   チャット相談（設計書§5画面4）
   ============================================================ */
.section-heading-action {
  float: right;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}
.section-heading-action:hover { text-decoration: underline; }

.text-input {
  width: 100%;
  max-width: 420px;
  height: 34px;
  border: 1px solid #ccc;
  border-radius: 0;
  padding: 0 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}

.primary-btn {
  height: 34px;
  padding: 0 16px;
  border: none;
  border-radius: 0;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.primary-btn:hover { background: var(--brand-hover); }
.primary-btn:disabled { background: #ccc; cursor: not-allowed; }

.chat-partner-header {
  background: #fff;
  border: 0.5px solid var(--border);
  padding: 12px 16px;
  margin: 0.8rem 0 1.2rem;
}

#new-session-btn { margin-bottom: 1.6rem; }
#new-session-status { margin: 0 0 1.6rem; }

.chat-window {
  background: #fff;
  border: 0.5px solid var(--border);
  padding: 16px;
  height: 55vh;
  min-height: 320px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.6;
  border: 0.5px solid var(--border);
}

.chat-bubble-user {
  margin-left: auto;
  background: var(--brand-tint);
  border-color: var(--brand);
}

.chat-bubble-assistant {
  margin-right: auto;
  background: #fafafa;
}

.chat-bubble ul { margin: 4px 0; padding-left: 18px; }
.chat-bubble li { margin: 2px 0; }
.chat-md-heading { font-weight: 700; margin: 6px 0 2px; }
.chat-typing { color: #999; font-style: italic; }
.chat-error { color: var(--sig-red); }

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-textarea {
  flex: 1;
  resize: none;
  border: 1px solid #ccc;
  border-radius: 0;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  max-height: 160px;
}

/* ============================================================
   リーガルチェック（設計書§5画面5）
   ============================================================ */
.check-form-box {
  background: #fff;
  border: 0.5px solid var(--border);
  padding: 16px 20px;
  margin-bottom: 1rem;
}

.check-target-tabs {
  display: flex;
  gap: 20px;
  margin-bottom: 12px;
  font-size: 13px;
}
.check-target-tabs label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.check-target-panel { margin-bottom: 12px; }
.check-target-panel.hidden { display: none; }

.check-field-label {
  display: block;
  font-size: 12px;
  color: #555;
  margin: 10px 0 4px;
}

.check-kintone-picker { max-height: 240px; margin-top: 6px; }
.check-selected-box {
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--brand-tint);
  font-size: 12px;
  color: var(--brand-hover);
}

.check-form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  margin-top: 14px;
}
.check-form-row select {
  height: 34px;
  border: 1px solid #ccc;
  border-radius: 0;
  padding: 0 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  min-width: 160px;
}

.check-template-hint { font-size: 12px; color: var(--sig-green); }
.check-template-hint-warn { color: var(--sig-yellow); }

#run-check-btn { margin-top: 16px; }
#run-status { display: inline-block; margin-left: 12px; }

.check-fallback-notice {
  background: var(--sig-yellow-bg);
  border: 1px solid var(--sig-yellow-border);
  color: var(--sig-yellow);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 1rem;
}

.check-result-box {
  background: #fff;
  border: 0.5px solid var(--border);
  padding: 18px 20px;
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 1.2rem;
}
.check-result-md ul { margin: 4px 0; padding-left: 18px; }
.check-result-md li { margin: 2px 0; }

/* ============================================================
   ひな形管理（設計書§5画面6・admin専用）
   ============================================================ */
.secondary-btn {
  height: 30px;
  padding: 0 12px;
  border: 1px solid #ccc;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.secondary-btn:hover { border-color: var(--brand); color: var(--brand); }
.secondary-btn:disabled { color: #ccc; border-color: #eee; cursor: not-allowed; }

.template-version-history {
  background: #fafafa;
  border: 0.5px solid var(--border);
  padding: 10px 14px;
  margin-bottom: 1rem;
  font-size: 12px;
}
.template-version-row { padding: 4px 0; cursor: pointer; }
.template-version-row:hover { color: var(--brand); }

.template-draft-box {
  background: #fff;
  border: 0.5px dashed var(--brand);
  padding: 14px 16px;
  margin-bottom: 1.2rem;
}
.template-draft-notice { font-size: 12px; color: #555; margin-bottom: 8px; }
#draft-generate-btn { margin-top: 8px; }
#draft-status { margin-left: 10px; }

.template-textarea {
  width: 100%;
  min-height: 320px;
  border: 1px solid #ccc;
  border-radius: 0;
  padding: 10px;
  font-size: 13px;
  font-family: 'Roboto Mono', monospace;
  line-height: 1.6;
  resize: vertical;
}
.template-textarea-small { min-height: 70px; font-family: inherit; }

.clause-notes-list { margin-bottom: 8px; }
.clause-note-row {
  display: grid;
  grid-template-columns: 120px 160px 1fr auto;
  gap: 8px;
  margin-bottom: 6px;
}
.clause-note-row .text-input { max-width: none; height: 30px; }

.template-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 1rem 0;
}
.template-file-row .check-field-label { margin: 0; }

.template-save-row { margin-top: 1.2rem; display: flex; align-items: center; gap: 12px; }

@media (max-width: 640px) {
  .clause-note-row { grid-template-columns: 1fr; }
  .check-form-row { flex-direction: column; align-items: stretch; }
}

/* ============================================================
   方針ナレッジ（設計書§5画面7）
   ============================================================ */
.policy-meta { font-size: 12px; color: #555; margin: 10px 0; }

.policy-suggestion-card {
  background: var(--brand-tint);
  border: 0.5px solid var(--brand);
  padding: 12px 16px;
  margin: 8px 0;
  font-size: 13px;
}
.policy-suggestion-heading { font-weight: 700; margin-bottom: 6px; }
.policy-suggestion-body { margin-bottom: 10px; }
.policy-suggestion-text { color: #555; margin-top: 4px; white-space: pre-wrap; }
.policy-suggestion-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   管理（利用量・監査、設計書§5画面8）
   ============================================================ */
.usage-limit-box {
  background: #fff;
  border: 0.5px solid var(--border);
  padding: 14px 18px;
  margin-bottom: 1rem;
}
.usage-limit-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 13px;
  margin-bottom: 8px;
}
.usage-bar-track { height: 10px; background: #eee; }
.usage-bar-fill { height: 100%; transition: width 0.2s ease; }
.usage-bar-ok { background: var(--sig-green); }
.usage-bar-warn { background: var(--sig-yellow-border); }
.usage-bar-danger { background: var(--sig-red); }

.usage-total-row { font-weight: 700; background: #f7f7f5; }

.usage-help-box {
  font-size: 12px;
  color: #555;
  background: #f7f7f5;
  border: 0.5px solid var(--border);
  padding: 10px 14px;
  margin: 1rem 0 1.6rem;
  line-height: 1.6;
}
.usage-help-box code {
  display: inline-block;
  background: #fff;
  border: 1px solid var(--border);
  padding: 1px 6px;
  margin: 2px 0;
  font-size: 11px;
}

.audit-pager { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 12px; }

/* ============================================================
   ユーティリティ・エラー表示
   ============================================================ */
.hidden { display: none; }
.loading-row { color: #999; font-size: 13px; padding: 12px 0; }
.error-msg { color: #d94040; font-size: 13px; margin: 8px 0; }

/* ============================================================
   モバイル
   ============================================================ */
@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のみで開閉制御する */
  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; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-count { margin-left: 0; }
}
