/*
  トータスグローブ AI電話受付 ― 管理画面

  ■ 受付履歴（/admin/calls）
    使う場面: 島田が、通知メールの後や一日の終わりに、PC かスマホで開き、折り返しが要る着信を片付ける。
    主役    : 折り返しが必要な着信（誰から・何の件か）
    主行動  : 着信を開く（行を押す）
    準主役  : 件数、受付日時、結果の札（要折り返し／取次済み など）
    脇役    : 取次できるかの一行（小さく上に）、そのほかの受付（文字を一段細く小さく）
    出さない: エンジン名・内部の番号・会話の全文

  ■ 着信の詳細（/admin/calls/:id）
    使う場面: 通知メールのリンクから開き（主にスマホ）、要約を読んで折り返す。
    主役    : 誰から・何の件か（名前と用件）と要約
    主行動  : 折り返し済みにする（塗りのボタンはこれだけ）
    準主役  : 折り返し先の電話番号（押すと電話がかかる）、結果と日時
    脇役    : 取次・通知・通話時間（小さい表）、会話の記録（下に、一段小さく）
    出さない: AI のセッション番号、出来事の生の記録

  ■ 設定（/admin/settings/*）
    使う場面: ときどき、第一声・取次先・受付時間などを変える。
    主役    : いま開いている設定の入力欄
    主行動  : 保存する
    準主役  : 保存できたか／入力の誤り
    脇役    : 項目の短い説明（小さく薄く）、試聴
    出さない: 使わない項目の説明・既定値の一覧

  色は 基調（白・薄い灰）・文字・アクセント（森の緑）1色と、状態色（要折り返し=琥珀、障害=赤）だけ。
  文字の大きさは 13 / 14 / 16 / 20 の4段。余白は4の倍数。
*/

:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --line: #e2e5e1;
  --line-strong: #cfd4ce;
  --text: #1f2422;
  --sub: #58625d;
  --accent: #1d6b55;
  --accent-dark: #155442;
  --accent-weak: #e5f0eb;
  --warn: #8a4a0b;
  --warn-weak: #fcefd8;
  --danger: #a3261c;
  --danger-weak: #fbe7e5;
  --radius: 6px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* ---- 上の帯 ---- */
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand small { font-weight: 400; color: var(--sub); margin-right: 4px; font-size: 13px; }
.nav { display: flex; gap: 4px; height: 100%; }
.nav a {
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--sub);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.nav a[aria-current="page"] { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.top form { margin-left: auto; }
.linkish {
  background: none;
  border: 0;
  padding: 8px;
  color: var(--sub);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* ---- 本文 ---- */
main { max-width: 1040px; margin: 0 auto; padding: 32px 24px 64px; }
h1 { font-size: 20px; line-height: 1.4; margin: 0; }
h2 { font-size: 16px; line-height: 1.4; margin: 40px 0 12px; }
.lead { color: var(--sub); font-size: 13px; margin: 4px 0 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); display: inline-block; }
.dot.on { background: var(--accent); }
.notice { margin: 16px 0 0; padding: 12px 16px; border-radius: var(--radius); background: var(--warn-weak); color: var(--warn); }
.saved { margin: 16px 0 0; color: var(--accent); font-weight: 700; }

/* ---- 一覧 ---- */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.list li + li { border-top: 1px solid var(--line); }
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 24px;
  padding: 12px 16px;
  min-height: 64px;
  color: inherit;
  text-decoration: none;
  align-items: center;
}
.row:hover { background: #fafbfa; }
.row .name { font-weight: 700; }
.row .what { color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { grid-row: span 2; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row .when { color: var(--sub); font-size: 13px; }
.pending .row .name { font-size: 16px; }
.history .row { min-height: 56px; }
.history .row .name { font-weight: 500; }
.empty { color: var(--sub); margin: 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.count { color: var(--sub); font-weight: 400; margin-left: 8px; }
.pager { display: flex; gap: 16px; justify-content: center; margin-top: 16px; }

.tag {
  display: inline-block;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 22px;
  white-space: nowrap;
  background: #eef0ee;
  color: var(--sub);
}
.tag.warn { background: var(--warn-weak); color: var(--warn); font-weight: 700; }
.tag.danger { background: var(--danger-weak); color: var(--danger); font-weight: 700; }
.tag.ok { background: var(--accent-weak); color: var(--accent-dark); }
.tag.live { background: var(--accent); color: #fff; }

/* ---- 着信の詳細 ---- */
.back { font-size: 13px; color: var(--sub); text-decoration: none; display: inline-block; padding: 8px 0; }
.detail { max-width: 720px; }
.detail .head { display: flex; gap: 8px; align-items: center; color: var(--sub); font-size: 13px; margin: 8px 0 8px; flex-wrap: wrap; }
.detail .purpose { font-size: 16px; margin: 4px 0 0; }
.callback { margin: 24px 0 0; display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.callback .label { color: var(--sub); font-size: 13px; }
.callback a { font-size: 20px; font-weight: 700; text-decoration: none; }
.summary { font-size: 16px; line-height: 1.8; margin: 16px 0 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.actions { margin: 24px 0 0; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.facts { margin: 40px 0 0; display: grid; grid-template-columns: 8em 1fr; gap: 8px 16px; font-size: 13px; }
.facts dt { color: var(--sub); }
.facts dd { margin: 0; }
.talk { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.talk li { display: grid; grid-template-columns: 3em 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.talk .who { color: var(--sub); font-size: 13px; }
.talk .note { color: var(--sub); font-size: 13px; grid-template-columns: 1fr; padding-left: calc(3em + 12px); }
.fine { color: var(--sub); font-size: 13px; margin: 12px 0 0; }

/* ---- ボタン ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: #f7f8f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.small { height: 36px; padding: 0 12px; font-weight: 400; font-size: 13px; }

/* ---- 設定 ---- */
.tabs { display: flex; gap: 4px; margin: 24px 0 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--sub); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.form { max-width: 680px; }
.form h2:first-child { margin-top: 32px; }
.field { margin: 24px 0 0; }
.field > label, .field > .label { display: block; font-weight: 700; margin-bottom: 4px; }
.help { color: var(--sub); font-size: 13px; margin: 0 0 8px; }
input[type="text"], input[type="tel"], input[type="number"], input[type="time"], input[type="password"], textarea, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 12px;
  min-height: 40px;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.6; }
input.short { width: 8em; }
.bad input, .bad textarea { border-color: var(--danger); }
.error { color: var(--danger); font-size: 13px; margin: 4px 0 0; }
.errors { margin: 16px 0 0; padding: 12px 16px; border-radius: var(--radius); background: var(--danger-weak); color: var(--danger); }
.check, .field > label.check { display: flex; align-items: center; gap: 8px; min-height: 40px; font-weight: 400; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.choices { display: grid; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.choice input { width: 20px; height: 20px; accent-color: var(--accent); }
.choice span { flex: 1; }
.hours { display: grid; grid-template-columns: 3em auto 1fr; gap: 8px 12px; align-items: center; }
.hours .times { display: flex; gap: 8px; align-items: center; }
.hours .times input { width: 8em; }
.faq { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-top: 8px; }
.faq textarea { min-height: 64px; }
.save { margin: 40px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); display: flex; gap: 16px; align-items: center; }
details.more { margin: 24px 0 0; }
details.more summary { cursor: pointer; color: var(--sub); min-height: 40px; display: flex; align-items: center; }

/* ---- ログイン ---- */
.login { max-width: 360px; margin: 96px auto; padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.login h1 { margin-bottom: 8px; }
.login .btn { width: 100%; margin-top: 24px; }

@media (max-width: 640px) {
  .top-inner { padding: 0 16px; gap: 16px; }
  .brand small { display: none; }
  main { padding: 20px 16px 48px; }
  .row { grid-template-columns: 1fr; }
  .row .meta { grid-row: auto; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; order: -1; }
  .facts { grid-template-columns: 6em 1fr; }
  .hours { grid-template-columns: 2em auto; }
  .hours .times { grid-column: 1 / -1; padding-left: calc(2em + 12px); }
  .actions .btn.primary { width: 100%; }
  .login { margin: 40px 16px; padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
