/* ========================================================
   styles.css — ISMSポータル
   本番＝ブルー系。検証（body.is-test）＝オレンジ系で区別。
   ======================================================== */

:root {
  --primary: #1f4e8c;
  --primary-dark: #163a69;
  --primary-light: #e8f0fb;
  --accent: #2c7be5;
  --bg: #f4f6fa;
  --card-bg: #ffffff;
  --text: #1f2733;
  --muted: #6b7280;
  --border: #e2e6ee;
  --danger: #dc3545;
  --success: #198754;
  --warning: #fd7e14;
  --header-h: 56px;
}

/* 検証サイト配色（暖色） */
body.is-test {
  --primary: #d9730d;
  --primary-dark: #b85c00;
  --primary-light: #fdf0e2;
  --accent: #e8830c;
  --bg: #fbf6ef;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* hidden 属性を最優先（.app や .modal-overlay の display 指定に負けないように） */
[hidden] { display: none !important; }
body {
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

/* 検証バッジの帯 */
.test-bar {
  position: sticky; top: 0; z-index: 100;
  background: var(--warning); color: #fff;
  text-align: center; font-weight: 700; font-size: 13px;
  padding: 4px 8px; letter-spacing: .04em;
}
body.is-test { border-top: 0; }
body.is-test .app { box-shadow: inset 0 0 0 3px var(--warning); }

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px; border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer;
  transition: .15s;
}
.btn:hover { background: #f2f4f8; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 6px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

/* ---- ログイン画面 ---- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 32px; max-width: 380px; width: 100%;
  text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.login-logo { font-size: 48px; }
.login-card h1 { font-size: 22px; margin: 8px 0 12px; color: var(--primary); }
.login-desc { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ---- アプリ全体 ---- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  height: var(--header-h); background: var(--primary); color: #fff;
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.app-title { font-weight: 700; font-size: 17px; flex: 1; }
.header-right { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 13px; opacity: .95; }
.app-header .btn-ghost { color: #fff; border-color: rgba(255,255,255,.5); }
.app-header .btn-ghost:hover { background: rgba(255,255,255,.15); }
.menu-toggle { display: none; background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; }

.app-body { display: flex; flex: 1; }
.sidenav { width: 220px; background: #fff; border-right: 1px solid var(--border); padding: 14px 10px; flex-shrink: 0; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-btn {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; color: var(--text); margin-bottom: 2px;
}
.nav-btn:hover { background: var(--primary-light); }
.nav-btn.active { background: var(--primary-light); color: var(--primary); font-weight: 700; }
.nav-section { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .04em; padding: 16px 12px 4px; margin-top: 6px; border-top: 1px solid var(--border); }
.admin-emails { list-style: none; margin: 0; padding: 0; }
.admin-emails li { padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.admin-emails li:last-child { border-bottom: none; }

.app-main { flex: 1; padding: 24px; max-width: 1500px; }
.page-title { font-size: 22px; margin: 0 0 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-head .page-title { margin: 0; }

/* ---- カード ---- */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h2 { font-size: 16px; margin: 0; }

/* ---- ホーム3ペイン（中央＋右） ---- */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px 300px; gap: 18px; align-items: start; }
.home-main { min-width: 0; }
.home-aside .card { position: sticky; top: 16px; }
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-item { border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: none; }
.feed-item a, .feed-noLink { display: block; padding: 10px 4px; text-decoration: none; color: var(--text); }
.feed-item a:hover { background: #f7f9fc; }
.feed-source { display: inline-block; font-size: 10px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 4px; padding: 1px 6px; margin-right: 6px; vertical-align: middle; }
.feed-title { font-size: 13px; }
.feed-date { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.feed-note { font-size: 11px; color: var(--muted); margin-top: 10px; margin-bottom: 0; }
@media (max-width: 1200px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-aside .card { position: static; }
}

/* ---- お知らせ一覧 ---- */
.ann-list { list-style: none; margin: 0; padding: 0; }
.ann-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 8px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.ann-row:last-child { border-bottom: none; }
.ann-row:hover { background: #f7f9fc; }
.ann-main { flex: 1; }
.ann-title { font-weight: 600; }
.ann-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.ann-date { color: var(--muted); font-size: 12px; }
.chev { color: var(--muted); font-size: 20px; }
.ann-detail .ann-body { margin-top: 14px; }

/* ---- バッジ ---- */
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.badge-important { background: #fde8e8; color: var(--danger); }
.badge-cat { background: var(--primary-light); color: var(--primary); }
.badge-pub { background: #e3f5ea; color: var(--success); }
.badge-draft { background: #eef0f3; color: var(--muted); }

/* ---- テーブル ---- */
.doc-table, .admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc-table th, .admin-table th { text-align: left; color: var(--muted); font-size: 12px; padding: 8px; border-bottom: 2px solid var(--border); }
.doc-table td, .admin-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.doc-name { font-weight: 600; }
.doc-actions, .row-actions { white-space: nowrap; display: flex; gap: 6px; }

/* ---- フォーム ---- */
.form label { display: block; font-size: 13px; color: var(--text); margin-bottom: 12px; font-weight: 600; }
.form input[type=text], .form input[type=date], .form input[type=datetime-local],
.form select, .form textarea, .form input[type=file] {
  width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit; font-weight: 400;
}
.form textarea { resize: vertical; }
.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }
.form .checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.form .checkbox input { margin: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.req { color: var(--danger); }

/* ---- モーダル ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; }
.modal-header h2 { font-size: 17px; margin: 0; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px; }

/* ---- 進捗バー ---- */
.progress { height: 8px; background: #eef0f3; border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

/* ---- 通知・状態 ---- */
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.notice-info { background: var(--primary-light); color: var(--primary); }
.notice-success { background: #e3f5ea; color: var(--success); }
.notice-error { background: #fde8e8; color: var(--danger); }
.loading { color: var(--muted); padding: 30px; text-align: center; }
.empty { color: var(--muted); padding: 16px; text-align: center; }
.muted { color: var(--muted); font-size: 13px; }
.error-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px; }

/* ---- レスポンシブ（スマホ） ---- */
@media (max-width: 720px) {
  .menu-toggle { display: block; }
  .sidenav {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .2s; box-shadow: 2px 0 12px rgba(0,0,0,.15);
  }
  .sidenav.open { transform: translateX(0); }
  .app-main { padding: 16px; }
  .form-row { flex-direction: column; gap: 0; }
}
