@charset "UTF-8";

/* hidden 属性を display 指定付きクラス（.login-view の flex 等）より必ず優先させる。
   これが無いと hidden=true でもログインビューが表示されたままになる */
[hidden] { display: none !important; }
/* =========================================================
   JTIC 管理画面 スタイル
   業務 UI として簡潔に。ネイビー #0a1633 のヘッダー・白背景・14px 基準
   ========================================================= */

:root {
  --navy-900: #0a1633;
  --navy-700: #16294f;
  --navy-600: #1e3560;
  --gold-600: #a37f2c;
  --gold-500: #b8923a;
  --red-600: #c0392b;
  --ink: #1a2333;
  --text: #333a45;
  --muted: #6b7280;
  --line: #e3e6ec;
  --bg-light: #f4f6f9;
  --white: #ffffff;
}

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

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg-light);
}

h1, h2 { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; }
button { font-family: inherit; }

/* ---------- ボタン共通 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.btn-primary {
  background: var(--navy-900);
  color: var(--white);
}
.btn-primary:hover { background: var(--navy-600); }
.btn-outline {
  background: var(--white);
  color: var(--navy-900);
  border-color: var(--line);
}
.btn-outline:hover { background: var(--bg-light); }
.btn-block { width: 100%; }
.btn-small {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 12.5px;
}
.btn-danger {
  background: var(--white);
  color: var(--red-600);
  border-color: var(--red-600);
}
.btn-danger:hover { background: var(--red-600); color: var(--white); }

/* ---------- 認証状態の復元中表示 ---------- */
.auth-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- ログインビュー ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--navy-900);
}
.login-box {
  width: 100%;
  max-width: 360px;
  padding: 40px 32px;
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(10, 22, 51, 0.3);
}
.login-title {
  margin-bottom: 28px;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy-900);
  text-align: center;
}
.login-form .form-row + .form-row { margin-top: 18px; }
/* パスワードの表示/非表示トグル（目のアイコン・フィールド内右寄せ） */
.password-field { position: relative; }
.password-field input { width: 100%; padding-right: 46px; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.password-toggle:hover { color: var(--navy-900); }
/* ログインボタンの上余白は自身に持たせる（直前のエラー表示 p は普段 hidden で
   余白の当てにできないため、兄弟結合子ではなくボタン自体に margin を付ける） */
.login-form .btn-block { margin-top: 22px; }

/* ---------- フォーム共通 ---------- */
.form-row label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-900);
}
.form-row-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.required {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--white);
  background: var(--red-600);
  border-radius: 2px;
  vertical-align: 2px;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid #c9cfda;
  border-radius: 4px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(184, 146, 58, 0.18);
}
textarea { min-height: 140px; resize: vertical; }

.error-message {
  margin: 14px 0 0;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--red-600);
  background: #fbeceb;
  border: 1px solid var(--red-600);
  border-radius: 4px;
}

/* ---------- 管理ビュー: ヘッダー ---------- */
.admin-view {
  min-height: 100vh;
}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  min-height: 60px;
  background: var(--navy-900);
  color: var(--white);
}
.admin-header-title {
  font-size: 16px;
  font-weight: 700;
}
.admin-header-user {
  display: flex;
  align-items: center;
  gap: 16px;
}
.current-user-email {
  font-size: 12.5px;
  color: #c7cddc;
  word-break: break-all;
}
.admin-header .btn-outline {
  background: transparent;
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.4);
}
.admin-header .btn-outline:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- レイアウト（左サイドバー + メイン） ---------- */
.admin-layout {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 60px);
}
.admin-sidebar {
  flex-shrink: 0;
  width: 210px;
  padding: 16px 0;
  background: var(--white);
  border-right: 1px solid var(--line);
}
.sidebar-group-label {
  margin: 0;
  padding: 12px 20px 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy-900);
  letter-spacing: 0.04em;
}
.sidebar-link {
  display: block;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  border-left: 3px solid transparent;
}
/* グループ配下の項目は一段インデントして階層を示す */
.sidebar-link-child {
  padding-left: 34px;
  padding-top: 9px;
  padding-bottom: 9px;
  font-size: 13.5px;
}
.sidebar-link:hover {
  color: var(--navy-900);
  background: var(--bg-light);
}
.sidebar-link.is-active {
  color: var(--navy-900);
  background: var(--bg-light);
  border-left-color: var(--gold-500);
}

/* ---------- メイン領域 ---------- */
.admin-main {
  flex: 1;
  min-width: 0;
  padding: 24px;
  max-width: 1100px;
}
.admin-panel[hidden] { display: none; }

/* ---------- お知らせ編集ページ ---------- */
.text-link {
  color: var(--navy-700);
  text-decoration: underline;
}
.text-link:hover { color: var(--gold-600); }
.editor-back { margin-bottom: 14px; font-size: 13.5px; }
.editor-card {
  max-width: 860px;
  padding: 24px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.editor-card .form-row + .form-row { margin-top: 16px; }
.form-row-inline {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.form-row-inline .form-col { flex: 1; min-width: 200px; }
/* 公開日欄: 日付・時刻を横並びに（select は全幅のまま） */
.form-col input.news-date-pick { width: auto; margin-top: 8px; margin-right: 8px; }
.form-row-inline .form-col label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-900);
}
.editor-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.editor-actions-spacer { flex: 1; }

/* Quill エディタの調整（サイトのフォーム部品とトーンを揃える） */
#news-editor {
  min-height: 280px;
  font-size: 14px;
}
.ql-toolbar.ql-snow,
.ql-container.ql-snow {
  border-color: #c9cfda;
}
.ql-toolbar.ql-snow {
  border-radius: 4px 4px 0 0;
  background: var(--bg-light);
}
.ql-container.ql-snow {
  border-radius: 0 0 4px 4px;
  font-family: inherit;
}
.ql-editor {
  min-height: 280px;
  line-height: 1.8;
}
.ql-editor img { max-width: 100%; height: auto; }
/* IME 変換中はプレースホルダーを隠す（admin.js の composition イベントと対） */
#news-editor.is-composing .ql-editor.ql-blank::before { content: none; }

/* ---------- カテゴリ管理 ---------- */
.category-add-form {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  max-width: 480px;
}
.category-add-form input { flex: 1; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy-900);
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-group label {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-900);
}
.filter-group select {
  width: auto;
  min-height: 40px;
}

/* ---------- リスト・テーブル ---------- */
.list-area {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 12px 16px;
  font-size: 13.5px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table th {
  background: var(--bg-light);
  color: var(--navy-900);
  font-weight: 700;
  white-space: nowrap;
  position: relative; /* 絞り込みポップオーバーの基準位置 */
}

/* 公開日の「日付を指定」用 date 入力（モードのセレクトの下に出す） */
.news-date-pick { margin-top: 8px; }

/* 列ヘッダーの並び替え・絞り込みコントロール */
.th-head {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.th-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.th-btn:hover { background: rgba(10, 22, 51, 0.08); color: var(--navy-900); }
.th-btn.is-active { color: var(--gold-700); }
.th-popover {
  /* 位置は開くとき JS が fixed 座標で指定する（.list-area の overflow にクリップされないため） */
  position: fixed;
  z-index: 300;
  min-width: 132px;
  padding: 4px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(10, 22, 51, 0.18);
}
.th-popover button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 4px;
  background: none;
  text-align: left;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}
.th-popover button:hover { background: var(--bg-light); }
.th-popover button.is-selected {
  font-weight: 700;
  color: var(--navy-900);
  background: var(--bg-light);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr.is-clickable { cursor: pointer; }
.data-table tbody tr.is-clickable:hover { background: var(--bg-light); }
.data-table .col-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}
.empty-message {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* バッジ */
.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
}
.badge-published { background: #e3f3ea; color: #1f7a4d; }
.badge-draft { background: #f0f1f4; color: var(--muted); }
.badge-scheduled { background: #e8effa; color: #2d5aa0; }
.badge-handled { background: #e3f3ea; color: #1f7a4d; }
.badge-unhandled { background: #fbeceb; color: var(--red-600); }
.badge-type-join { background: var(--bg-light); color: var(--navy-700); }
.badge-type-contact { background: #f3e9d2; color: var(--gold-600); }

/* ---------- モーダル ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 22, 51, 0.55);
}
.modal[hidden] { display: none; }
.modal-inner {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 28px;
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 20px 48px rgba(10, 22, 51, 0.35);
}
.modal-title {
  margin-bottom: 20px;
  font-size: 16px;
  font-weight: 700;
  color: var(--navy-900);
}
.modal .form-row + .form-row { margin-top: 16px; }
.modal-note { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  flex-shrink: 0;
}

/* 受信詳細の定義リスト（中身だけスクロールし、タイトルとボタンは固定） */
.detail-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.detail-list .detail-row {
  display: flex;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.detail-list .detail-row:last-child { border-bottom: 0; }
.detail-list dt {
  flex-shrink: 0;
  width: 110px;
  font-weight: 700;
  color: var(--navy-900);
}
.detail-list dd {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  white-space: pre-wrap;
}

/* =========================================================
   レスポンシブ（768px 以下）
   ========================================================= */
@media (max-width: 768px) {
  .admin-header { padding: 0 16px; flex-wrap: wrap; min-height: auto; padding-top: 12px; padding-bottom: 12px; gap: 10px; }
  .admin-header-user { flex-wrap: wrap; gap: 10px; }
  .current-user-email { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
  /* サイドバーは上部の横並びメニューに変形（グループ見出しは横並びでは不自然なので隠す。
     「お知らせ編集」「カテゴリ編集」の項目名だけで意味が通る） */
  .admin-layout { flex-direction: column; min-height: auto; }
  .admin-sidebar {
    display: flex;
    width: 100%;
    padding: 0 12px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-group-label { display: none; }
  .sidebar-link,
  .sidebar-link-child {
    padding: 12px 14px;
    font-size: 13px;
    white-space: nowrap;
    border-left: 0;
    border-bottom: 3px solid transparent;
  }
  .sidebar-link.is-active {
    background: transparent;
    border-bottom-color: var(--gold-500);
  }
  .admin-main { padding: 16px 12px; }
  .panel-toolbar { flex-direction: column; align-items: flex-start; }
  .editor-card { padding: 16px; }
  .form-row-inline { flex-direction: column; gap: 16px; }

  /* テーブルをカード表示に変える */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td {
    display: block;
    width: 100%;
  }
  .data-table tr {
    padding: 12px 16px;
    border-bottom: 8px solid var(--bg-light);
  }
  .data-table td {
    padding: 6px 0;
    border-bottom: 0;
  }
  .data-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
  }
  .data-table .col-actions { flex-wrap: wrap; }

  .modal-inner { padding: 20px; }
  .detail-list .detail-row { flex-direction: column; gap: 4px; }
  .detail-list dt { width: auto; }
}

/* ---------- 設定: 通知先メール ---------- */
.settings-block { max-width: 560px; }
.settings-heading { margin-bottom: 6px; font-size: 15px; font-weight: 700; color: var(--navy-900); }
.settings-note { margin-bottom: 14px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.recipients-list { list-style: none; margin: 0 0 18px; padding: 0; }
.recipients-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.recipients-list .recipients-empty { color: var(--muted); font-size: 13px; }
