/* main_auto.css — flat & modern UI (2026 refresh)
   配色は body.theme-* で切り替える（tamlab / center / plain） */

/* === Design Tokens =========================================== */
:root {
  /* Surfaces & text */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e8eaee;
  --line-strong: #d9dce2;
  --text: #1b1f27;
  --text-2: #4b5563;
  --text-muted: #79808c;
  --error: #c0392f;

  /* Accent（テーマで上書き。既定は田向研究室のアズールブルー） */
  --accent: #0063B1;
  --accent-dark: #004e8c;
  --accent-soft: #eef4fb;
  --accent-line: #cfe0f0;

  /* 後方互換（既存テンプレートが参照しているトークン） */
  --primary-1: #896CAD;
  --primary-2: var(--accent);
  --p1-rgb: 137, 108, 173;
  --p2-rgb: 0, 99, 177;
  --form-surface: var(--surface);
  --border: var(--line);
  --border-strong: var(--line-strong);
  --label: var(--text-2);
  --chip-bg: var(--surface);
  --focus-ring: rgba(0, 99, 177, 0.16);
  --focus-border: var(--accent);

  /* Shape & depth */
  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .07);
  --shadow: 0 2px 6px rgba(16, 24, 40, .06), 0 12px 28px -18px rgba(16, 24, 40, .30);

  /* Typography */
  --ff: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-base: 16px;

  /* Layout */
  --footerbar-h: 52px;
}

/* フッターバー非表示時は、その分の下余白も取らない */
body.no-footerbar { --footerbar-h: 0px; }

* , *::before, *::after { box-sizing: border-box; }
:root { color-scheme: light; }
html { font-size: var(--fs-base); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--ff);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
}

/* header.ejs の外枠（ヘッダーは flow に乗せて sticky にする） */
.wrapper { flex: 1 0 auto; display: flex; }
.main { flex: 1; min-width: 0; display: flex; }

/* === Page shell ============================================== */
.page-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 26px 18px calc(var(--footerbar-h) + 28px);
  background: var(--bg);
}
.form-shell { width: min(980px, 100%); }

/* カード */
.glass-card,
.glass-card-view,
.glass-card-delete,
.glass-card-success,
.card-soft,
.room-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 26px;
}
.card-soft { border-radius: var(--r); padding: 16px; box-shadow: none; }
.glass-card-success { text-align: center; }
.section { margin-top: 18px; }

/* === Typography ============================================== */
h1 { font-size: 1.5rem; margin: 0 0 1.2rem; color: var(--text); font-weight: 700; }

.home-title,
.title,
.view-title,
.success-title,
.delete-title,
.page-title {
  margin: 0;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--text);
}
.home-title { font-size: 1.3rem; }
.title { font-size: 1.5rem; }
.view-title, .delete-title { font-size: 1.35rem; margin-bottom: 18px; }
.success-title { font-size: 1.5rem; margin-bottom: 14px; color: var(--accent); }
.page-title { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; font-size: 1.35rem; }

.home-hero,
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

/* 小さなラベル系（バッジ） */
.subtitle-badge,
.period-badge,
.title-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; line-height: 1.7;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  white-space: nowrap;
}
.badge-large {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; line-height: 1.7;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-dark);
  white-space: nowrap;
}

/* === Forms =================================================== */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
@media (max-width: 780px) { .grid { grid-template-columns: 1fr; } }

.form-group { display: grid; gap: 7px; margin-bottom: 18px; }
label { display: block; font-weight: 600; font-size: .84rem; color: var(--text-2); }
.form-label { display: block; font-weight: 600; font-size: .84rem; color: var(--text-2); margin-bottom: 6px; }
.control { position: relative; }

.form-control,
select,
input[type="text"],
input[type="password"],
input[type="datetime-local"] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  accent-color: var(--accent);
}
.form-control:focus,
select:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="datetime-local"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
::placeholder { color: #a3a9b4; }

/* チップ（ラジオ / チェックボックス） */
.radio-group, .checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; }
.radio-group { border: 0; padding: 0; background: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: .92rem; font-weight: 600; color: var(--text-2);
  cursor: pointer;
  margin-bottom: 0;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.chip input { accent-color: var(--accent); margin: 0; }
.checkbox-wrapper { display: inline-flex; }

.sections-container {
  margin-top: 10px; padding: 14px; border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.hidden { display: none; }

/* === Buttons ================================================= */
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 20px; }

.btn-primary,
.btn-outline,
.btn-danger,
.link-ghost {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .95rem; font-weight: 600; letter-spacing: .01em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .04s ease;
}
.btn-primary { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-primary:active { transform: translateY(1px); }

.btn-outline, .link-ghost {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-2);
}
.btn-outline:hover, .link-ghost:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-soft); }

.btn-danger { border: 1px solid #c0392f; background: #c0392f; color: #fff; }
.btn-danger:hover { background: #a32f26; border-color: #a32f26; }

/* 取消などの破壊的操作を控えめに見せたいとき */
.btn-outline.is-danger { color: #a32f26; border-color: #eccbc7; }
.btn-outline.is-danger:hover { background: #fdf1f0; border-color: #e0a9a3; color: #8c241c; }

.error {
  margin-top: 14px; padding: 10px 12px; border-radius: var(--r-sm);
  color: #8c241c; background: #fdf1f0; border: 1px solid #f3d2ce;
  font-size: .92rem;
}

/* === Home（施設一覧） ======================================== */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}
.room-card {
  padding: 18px;
  border-radius: var(--r);
  box-shadow: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.room-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.room-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.room-name { font-weight: 700; font-size: 1.06rem; color: var(--text); line-height: 1.4; }
.room-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.room-actions .btn-primary,
.room-actions .btn-outline { padding: 8px 14px; font-size: .9rem; }

/* === 予約詳細テーブル ======================================== */
table.booking-detail {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  font-size: .95rem;
}
.booking-detail th, .booking-detail td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.booking-detail th {
  width: 32%;
  white-space: nowrap;
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-2);
  font-size: .88rem;
}
.booking-detail tr:first-child th,
.booking-detail tr:first-child td { border-top: none; }
.booking-detail td.detail-content { white-space: pre-wrap; word-break: break-word; }
.detail-empty { color: var(--text-muted); }

.booking-info { margin-top: 10px; font-size: .96rem; color: var(--text-2); line-height: 1.9; }
.warning-text { margin: 0 0 18px; color: #a32f26; font-weight: 600; }

/* === テーマ配色 ============================================== */
/* 田向研究室：アズールブルー */
body.theme-tamlab {
  --accent: #0063B1;
  --accent-dark: #004e8c;
  --accent-soft: #eef4fb;
  --accent-line: #cfe0f0;
  --focus-ring: rgba(0, 99, 177, .16);
}
/* 研究センター：白基調＋赤アクセント */
body.theme-center {
  --accent: #c0303f;
  --accent-dark: #9b1f2e;
  --accent-soft: #fdf2f3;
  --accent-line: #f0d5d8;
  --focus-ring: rgba(192, 48, 63, .14);
  --primary-1: #1c1c1c;
  --p1-rgb: 28, 28, 28;
  --p2-rgb: 192, 48, 63;
}
body.theme-center .view-title,
body.theme-center .delete-title,
body.theme-center .title { color: var(--accent); }
/* シンプル（ホーム・管理）：ブルーアクセント */
body.theme-plain {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff5ff;
  --accent-line: #d5e3fd;
  --focus-ring: rgba(37, 99, 235, .14);
  --p2-rgb: 37, 99, 235;
}

/* === Motion preferences ====================================== */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* === スマホ最適化 ============================================ */
@media (max-width: 640px) {
  .page-wrap { padding: 16px 12px calc(var(--footerbar-h) + 20px); }
  .glass-card,
  .glass-card-view,
  .glass-card-delete,
  .glass-card-success { padding: 18px 16px; }
  .card-soft { padding: 12px; }
  .title { font-size: 1.3rem; }
  .home-title { font-size: 1.15rem; }
  .home-hero, .header-row { gap: 10px; }
  .rooms-grid { grid-template-columns: 1fr; }
  .booking-detail th { width: 36%; font-size: .84rem; }
}
