/* ========================================================
   styles.css — 社内申請ポータル
   ※ 検証サイトの見た目の違い（オレンジ系）は config.js の isTestSite で
      body に .is-test が付いたときだけ適用される。
   ======================================================== */

:root {
  --brand: #2f5c9e;
  --brand-dark: #24487c;
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e3e6ec;
  --text: #232730;
  --muted: #6b7280;
  --ok: #1f8a4c;
  --warn: #c77700;
  --ng: #c0392b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}

.hidden { display: none !important; }

/* ---------- ログイン画面 ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  background: var(--card);
  border-radius: 14px;
  padding: 44px 36px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  max-width: 440px;
  width: 100%;
}
.login-icon { font-size: 44px; }
.login-box h1 { font-size: 22px; margin: 8px 0 16px; }
.login-desc { color: var(--muted); margin-bottom: 24px; }
.login-note { color: var(--muted); font-size: 12px; margin-top: 16px; }

/* ---------- ヘッダー ---------- */
.test-banner {
  background: #b35c00;
  color: #fff;
  text-align: center;
  padding: 6px;
  font-weight: bold;
  font-size: 13px;
}
.header {
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-title { font-weight: bold; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 13px; opacity: .95; }
.btn-menu {
  background: none; border: none; color: #fff; font-size: 20px;
  cursor: pointer; display: none; padding: 4px 8px;
}

/* ---------- レイアウト ---------- */
.layout { display: flex; min-height: calc(100vh - 52px); }
.sidebar {
  width: 232px;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 12px 8px;
  flex-shrink: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
}
.nav-item:hover { background: #eef2f8; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: bold; }
.nav-group { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.nav-group-title { font-size: 11px; color: var(--muted); padding: 4px 12px; }
.badge {
  background: var(--ng); color: #fff; border-radius: 10px;
  font-size: 11px; padding: 1px 7px; margin-left: auto; font-weight: bold;
}
.nav-item.active .badge { background: #fff; color: var(--ng); }

.main { flex: 1; padding: 20px; max-width: 1100px; }
.view-title { font-size: 20px; margin: 0 0 16px; }

/* ---------- カード ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 10px; font-size: 16px; }
.card h4 { margin: 16px 0 6px; font-size: 14px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
/* 最初のボタンだけを右へ寄せる（複数ボタンがまとまって右に並ぶ） */
.card-head .btn:first-of-type { margin-left: auto; }

.empty { color: var(--muted); text-align: center; padding: 28px; }
.note { color: var(--muted); font-size: 13px; }

/* ---------- 申請メニュー ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.form-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}
.form-card:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.form-card-icon { font-size: 26px; }
.form-card-name { font-weight: bold; margin: 6px 0 4px; }
.form-card-desc { color: var(--muted); font-size: 12px; }
.cat-title { font-size: 13px; color: var(--muted); margin: 18px 0 8px; font-weight: bold; }

/* ---------- 申請入力（フォーム＋承認フローの2ペイン） ---------- */
.apply-layout { display: flex; gap: 16px; align-items: flex-start; }
.apply-main { flex: 1; min-width: 0; }
.apply-side { width: 260px; flex-shrink: 0; position: sticky; top: 68px; }
.flow-pane h3 { margin-bottom: 14px; }

.flow { list-style: none; padding: 0; margin: 0; }
.flow-step { position: relative; display: flex; gap: 10px; padding-bottom: 18px; }
.flow-step:last-child { padding-bottom: 0; }
/* ステップ同士をつなぐ縦線 */
.flow-step:not(:last-child)::before {
  content: ""; position: absolute; left: 12px; top: 26px; bottom: 0;
  width: 2px; background: var(--line);
}
.flow-ic {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: bold; flex-shrink: 0; z-index: 1;
}
.flow-you .flow-ic { background: #6b7280; }
.flow-done .flow-ic { background: var(--ok); }
.flow-title { font-weight: bold; line-height: 1.4; }
.flow-sub { color: var(--muted); font-size: 12px; }

body.is-test .flow-ic { background: #b35c00; }
body.is-test .flow-you .flow-ic { background: #6b7280; }
body.is-test .flow-done .flow-ic { background: #1f8a4c; }

@media (max-width: 860px) {
  .apply-layout { flex-direction: column; }
  .apply-side { width: 100%; position: static; }
}

/* ---------- 入力フォーム ---------- */
/* 注意書き（field-hint）は order で「入力枠の下」に回す。
   これにより、2列レイアウトでも左右の入力枠の高さが揃う（注意書きが枠の上に挟まらない）。 */
.field { margin-bottom: 16px; display: flex; flex-direction: column; }
.field-label { font-weight: bold; margin-bottom: 4px; order: 0; }
.req { color: var(--ng); font-size: 11px; margin-left: 4px; }
.field-hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; order: 8; }
.field-error { order: 9; }
input[type=text], input[type=email], input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cfd5df;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
input[readonly] { background: #f1f3f6; color: var(--muted); }
.opt { display: block; margin: 4px 0; }
.opt input { margin-right: 6px; }
.field-error { color: var(--ng); font-size: 12px; margin-top: 4px; }

/* ---------- ボタン ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  background: #eef1f5;
  color: var(--text);
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ng { background: var(--ng); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-ghost { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.4); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.btn-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); }

/* ---------- テーブル ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.table th { background: #f7f9fc; font-weight: bold; white-space: nowrap; }
.table tr:hover td { background: #fafbfd; }

/* ---------- ステータス ---------- */
.status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}
.status-submitted { background: #e6f0fb; color: var(--brand); }
.status-approved  { background: #e4f5ea; color: var(--ok); }
.status-rejected  { background: #fbe8e6; color: var(--ng); }
.status-remanded  { background: #fdf0dc; color: var(--warn); }
.status-withdrawn { background: #eceef1; color: var(--muted); }

/* ---------- 確認画面・履歴 ---------- */
.confirm-list { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.confirm-row { display: flex; border-bottom: 1px solid var(--line); }
.confirm-row:last-child { border-bottom: none; }
.confirm-key { width: 220px; background: #f7f9fc; padding: 8px 12px; font-weight: bold; flex-shrink: 0; }
.confirm-val { padding: 8px 12px; white-space: pre-wrap; word-break: break-word; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 12px 14px; margin-left: 6px; position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 6px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--brand);
}
.timeline .tl-head { font-weight: bold; }
.timeline .tl-meta { color: var(--muted); font-size: 12px; }
.timeline .tl-comment { background: #f7f9fc; border-radius: 6px; padding: 6px 10px; margin-top: 4px; white-space: pre-wrap; }

/* ---------- モーダル ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-box {
  position: relative;
  background: var(--card);
  border-radius: 12px;
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- トースト・読み込み ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #232730; color: #fff; padding: 10px 20px; border-radius: 8px;
  z-index: 80; box-shadow: 0 4px 16px rgba(0,0,0,.25); max-width: 90vw;
}
.toast.toast-ng { background: var(--ng); }
.toast.toast-ok { background: var(--ok); }

.loading { position: fixed; inset: 0; background: rgba(255,255,255,.6); z-index: 90; display: flex; align-items: center; justify-content: center; }
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--line);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ヘルプ ---------- */
.toc { margin: 0; padding-left: 20px; }
.toc a { color: var(--brand); }

/* ---------- 申請フォーム管理（編集画面） ---------- */
.builder-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fbfcfe;
}
.builder-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.builder-head strong { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline { display: flex; align-items: center; gap: 6px; }

/* ---------- 検証サイトの見た目 ---------- */
body.is-test { background: #fdf7f0; }
body.is-test .header { background: #b35c00; }
body.is-test .nav-item.active { background: #b35c00; }
body.is-test .card,
body.is-test .form-card { border-color: #eccfa6; }
body.is-test .btn-primary { background: #b35c00; }
body.is-test .form-card:hover { border-color: #b35c00; }
body.is-test :root { --brand: #b35c00; }

/* ---------- スマホ ---------- */
@media (max-width: 860px) {
  .btn-menu { display: block; }
  .sidebar {
    position: fixed; top: 52px; left: 0; bottom: 0; z-index: 30;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: 2px 0 12px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 14px; }
  .confirm-row { flex-direction: column; }
  .confirm-key { width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
  .user-name { display: none; }
}
