/*
 * 授業パネルの画面と印刷の CSS（docs/control-design.md 8.1、7.7）。
 *
 * - タブレット（iPad の縦 768・横 1024、Android 800 程度）とパソコン。幅 600px 以下は 1 列、それより広いと最大 720px の中央寄せ。
 * - ボタンと入力欄は高さ 44px 以上。文字は 16px 以上（iPad の Safari で入力時に拡大されないため）。
 * - ホバーに頼らない（押せることは形と色で分かるようにする）。
 */

:root {
  --text: #1a1a1a;
  --muted: #555;
  --bg: #f4f5f7;
  --card: #fff;
  --line: #d0d4da;
  --primary: #0b5cad;
  --primary-text: #fff;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --warn: #9a3412;
  --ok: #166534;
  --focus: #f59e0b;
  --radius: 10px;
  --tap: 48px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 18px;
  line-height: 1.6;
}

/* ---- 上部 ---- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  font-size: 22px;
}

.account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
}

.account .email {
  color: var(--muted);
  font-size: 16px;
  overflow-wrap: anywhere;
}

/* ---- 本体 ---- */

.main,
.error-band {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.main {
  padding: 16px;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px 20px;
}

.card-title {
  margin: 0 0 8px;
  font-size: 22px;
}

.card p {
  margin: 8px 0;
}

.note {
  color: var(--muted);
  font-size: 16px;
}

.small {
  font-size: 16px;
  overflow-wrap: anywhere;
}

.warn {
  color: var(--warn);
  font-weight: 600;
}

.warn:empty,
.note:empty,
.ok:empty {
  display: none;
}

.ok {
  color: var(--ok);
  font-weight: 600;
}

.danger-box {
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-weight: 700;
  padding: 12px 16px;
}

.confirm {
  font-size: 20px;
}

.label {
  display: block;
  margin: 12px 0 4px;
  font-weight: 600;
}

/* ---- ボタンと入力欄 ---- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 2px solid var(--primary);
  background: var(--card);
  color: var(--primary);
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
}

.btn-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.btn:disabled {
  border-color: var(--line);
  background: #e5e7eb;
  color: #6b7280;
  cursor: not-allowed;
}

.btn:focus-visible,
.input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn-wide {
  width: 100%;
}

.topbar .btn {
  font-size: 16px;
  padding: 8px 14px;
}

.input {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 18px;
}

.time-input {
  max-width: 220px;
  font-size: 24px;
}

.file-input {
  padding: 10px 12px;
}

/* WebKit の標準の見た目（appearance: auto）の選択欄は高さの指定が効かず 28px ほどになる（Playwright の WebKit で確認）。
   標準の見た目を外し、矢印は背景の画像で描く（img-src の data: で読める） */
select.input {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M3 6l5 5 5-5' fill='none' stroke='%231a1a1a' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
}

/* ---- 状態 ---- */

.progress progress {
  width: 100%;
  height: 24px;
}

.progress-count {
  font-size: 24px;
  font-weight: 700;
}

.entry {
  margin: 8px 0;
}

.entry-url {
  margin: 4px 0;
  padding: 12px;
  background: #eef4fb;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 22px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
}

.stop-at {
  font-size: 20px;
  font-weight: 600;
}

/* 準備中の段階（1/3 準備をしています・2/3 作っています・3/3 入口を用意しています。8.3） */

.stage-now {
  font-size: 20px;
  font-weight: 700;
}

.stage-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin: 4px 0 8px;
  padding: 0;
  list-style: none;
  counter-reset: stage;
}

.stage-list li {
  counter-increment: stage;
  padding: 4px 12px;
  border: 2px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 16px;
}

.stage-list li::before {
  content: counter(stage) ". ";
}

.stage-list .stage-done {
  border-color: var(--ok);
  color: var(--ok);
}

.stage-list .stage-done::before {
  content: "✓ ";
}

.stage-list .stage-current {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
}

/* 管理者の設定の入口 URL（ホームより小さく出す。8.7） */
#admin-entry-url {
  font-size: 18px;
}

.admin-link .actions {
  margin-top: 0;
}

/* ---- エラーの帯 ---- */

.error-band {
  padding: 12px 16px 0;
}

.error-band > * {
  margin: 0;
}

.error-band .error-message {
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
  color: var(--danger);
  font-weight: 700;
  padding: 12px 16px 4px;
}

.error-band .actions {
  margin: 0;
  padding: 8px 16px 12px;
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---- 入口 URL の大きな表示 ---- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: 32px;
  background: #fff;
  overflow: auto;
}

.overlay[hidden] {
  display: none;
}

.overlay-label {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

.overlay-url {
  margin: 0;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(28px, 5.5vw, 72px);
  font-weight: 700;
  line-height: 1.3;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.overlay .actions {
  justify-content: center;
}

/* ---- 名簿 ---- */

.others {
  margin-top: 12px;
}

.disabled-list,
.issue-list {
  margin: 4px 0;
  padding-left: 20px;
}

.disabled-list li {
  color: #6b7280;
  margin: 4px 0;
}

.disabled-list .name {
  display: block;
}

.issue-list {
  max-height: 240px;
  overflow: auto;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.table-wrap {
  margin-top: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.table th,
.table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  background: #f0f2f5;
  white-space: nowrap;
}

.table .email {
  overflow-wrap: anywhere;
  word-break: break-all;
  min-width: 10em;
}

.table .password {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 18px;
  white-space: nowrap;
}

.table .status {
  white-space: nowrap;
}

.table .memo {
  min-width: 10em;
}

.status-invalid td,
.status-failed td,
.status-unknown td {
  background: #fff7ed;
}

.steps summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  margin-top: 16px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.steps ol {
  padding-left: 24px;
  font-size: 16px;
}

.steps li {
  margin: 6px 0;
  overflow-wrap: anywhere;
}

.print-only {
  display: none;
}

/* ---- 幅 ---- */

/* 600px 以下は 1 列。ボタンは横幅いっぱい */
@media (max-width: 600px) {
  .main {
    padding: 12px;
  }

  .card {
    padding: 12px 14px 16px;
  }

  .actions .btn {
    flex: 1 1 100%;
  }

  .actions.quick .btn {
    flex: 1 1 0;
    padding-left: 8px;
    padding-right: 8px;
  }

  .entry-url {
    font-size: 18px;
  }
}

/* ---- 印刷（1 人 1 行、切り取り線つき。ナビゲーションを隠す） ---- */

@media print {
  body {
    background: #fff;
    font-size: 12pt;
  }

  .topbar,
  .error-band,
  .overlay,
  .screen-only,
  .actions {
    display: none !important;
  }

  .main {
    max-width: none;
    padding: 0;
  }

  .print-only {
    display: block;
  }

  .print-title {
    margin: 0 0 8pt;
    font-size: 12pt;
    font-weight: 700;
  }

  .slip {
    padding: 8pt 4pt;
    border-bottom: 1px dashed #000;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .slip p {
    margin: 2pt 0;
  }

  .slip-name {
    font-size: 14pt;
    font-weight: 700;
  }

  .slip-memo {
    font-size: 10pt;
  }
}

/* ---- 受け取り待ちの初期パスワード（W3） ---- */

.pending-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
}

.pending-item {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.pending-group {
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* ---- 授業の予約（19.9） ---- */

/* 最後の予約の起動の結果の帯（started は情報、それ以外は注意） */
.notice {
  border-radius: var(--radius);
  border: 2px solid var(--primary);
  background: #eef4fb;
  padding: 12px 16px;
}

.notice p {
  margin: 4px 0;
}

.notice-title {
  font-weight: 700;
}

.notice-warn {
  border-color: var(--warn);
  background: #fff7ed;
}

.notice-warn .notice-title {
  color: var(--warn);
}

.reservation-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
}

/* 1 件 1 行。狭い幅（タブレットの縦など）では「取り消す」が下に折り返す */
.reservation-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.reservation-text {
  flex: 1 1 320px;
  min-width: 0;
}

.card .reservation-text p {
  margin: 2px 0;
}

.reservation-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.reservation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
}

.reservation-action {
  flex: 0 0 auto;
}

/* ---- 学校とクラス（docs/class-reservations-design.md） ---- */

/* チェックボックスとラジオボタンの 1 行（文字も含めて押せる） */
.choices {
  margin: 8px 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 4px 0;
  cursor: pointer;
}

.choice input {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 0;
}

.choice span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.choice input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.bulk-dates {
  margin: 8px 0;
  padding-left: 1.5em;
}

.reservation-class {
  overflow-wrap: anywhere;
}

.filter-input {
  max-width: 480px;
}

.class-school-name {
  margin: 16px 0 4px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.card .class-name {
  flex: 1 1 200px;
  min-width: 0;
  margin: 2px 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.class-item .class-actions {
  margin: 0;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
}

.field {
  flex: 0 1 auto;
  min-width: 0;
}

.date-input {
  max-width: 260px;
  font-size: 22px;
}

.minutes-input {
  max-width: 160px;
  font-size: 24px;
}

.plan {
  margin: 8px 0;
}

.plan-end {
  font-size: 20px;
  font-weight: 600;
}

@media (max-width: 600px) {
  .field {
    flex: 1 1 100%;
  }

  .reservation-action {
    flex: 1 1 100%;
  }

  .reservation-action .btn {
    width: 100%;
  }
}
