/* ============================================================
   meister 公開ページ スタイル（入口 / 申請フォーム 共通）
   nyusha アプリの public/style.css の流儀に合わせる
   ============================================================ */

:root {
  --primary: #1c64f2;
  --primary-dark: #164fc2;
  --bg: #f7f8fa;
  --card-bg: #ffffff;
  --border: #dde2ea;
  --text: #1f2937;
  --text-sub: #6b7280;
  --error: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --muted: #6b7280;
  --radius: 10px;
}

/* display を持つ要素（.btn など）でも hidden 属性を確実に効かせる */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

#app { min-height: 100vh; }

.screen { min-height: 100vh; }
.screen[hidden] { display: none !important; }

button { font-family: inherit; }

input, select, textarea {
  font-family: inherit;
  font-size: 16px;
}

/* ---------- 共通ボタン ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:active:not(:disabled) { background: var(--primary-dark); }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  min-height: 44px;
  padding: 8px 4px;
  cursor: pointer;
  text-decoration: underline;
}

.btn-block { width: 100%; }

/* ---------- 入口ページ ---------- */

#screen-entry {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.entry-card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 36px 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.entry-title {
  font-size: 20px;
  margin: 0 0 8px;
}

.entry-desc {
  color: var(--text-sub);
  font-size: 14px;
  margin: 0 0 28px;
}

/* ---------- カード型の画面（申請者情報・フォーム未提供・状況確認） ---------- */

#screen-loading,
#screen-notfound,
#screen-applicant,
#screen-status {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.card {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 28px 22px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.card-title {
  font-size: 19px;
  margin: 0 0 8px;
  text-align: center;
}

.card-desc {
  color: var(--text-sub);
  font-size: 14px;
  text-align: center;
  margin: 0 0 20px;
  white-space: pre-wrap;
}

.card-loading {
  text-align: center;
  color: var(--text-sub);
  padding: 40px 0;
}

.card-error {
  color: var(--error);
  font-size: 14px;
  text-align: center;
  margin: 4px 0 12px;
  min-height: 0;
}

.status-link-row {
  text-align: center;
  margin-top: 18px;
}

/* ---------- フォームヘッダー / 進捗（申請内容ステップ） ---------- */

.form-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card-bg);
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  margin-bottom: 8px;
}

#step-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

#step-count {
  color: var(--text-sub);
}

.progress-bar-track {
  height: 6px;
  background: #e5e9f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.25s ease;
}

.form-desc {
  font-size: 13px;
  color: var(--text-sub);
  padding: 10px 16px 0;
  max-width: 640px;
  margin: 0 auto;
  white-space: pre-wrap;
}

/* ---------- ステップ本体 ---------- */

.step-content {
  padding: 20px 16px 120px;
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- フォーム項目 ---------- */

.form-field {
  margin-bottom: 18px;
}

.form-field > label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text);
}

.req-badge {
  display: inline-block;
  background: #fde8e8;
  color: var(--error);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: middle;
}

.form-field input[type="text"],
.form-field input[type="tel"],
.form-field input[type="date"],
.form-field input[type="number"],
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 16px;
}

.form-field textarea {
  min-height: 88px;
  resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(28, 100, 242, 0.15);
}

.form-field input.invalid,
.form-field select.invalid,
.form-field textarea.invalid {
  border-color: var(--error);
}

.field-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 4px;
  min-height: 0;
}

.field-help {
  color: var(--text-sub);
  font-size: 12px;
  margin-top: 4px;
}

.field-caution {
  color: var(--warning);
  font-size: 12px;
  margin-top: 4px;
}

.form-field > label.checkbox-row,
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 400;
  margin-bottom: 0;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.radio-grid,
.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
}

.choice-chip input {
  width: 18px;
  height: 18px;
}

/* ---------- フッターナビ ---------- */

.form-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  z-index: 20;
}

.saving-indicator {
  text-align: center;
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.footer-buttons {
  display: flex;
  gap: 10px;
}

.footer-buttons .btn {
  flex: 1;
}

/* ---------- 完了画面 ---------- */

#screen-complete {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.complete-card {
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.complete-icon {
  width: 64px;
  height: 64px;
  line-height: 64px;
  border-radius: 50%;
  background: #e8f7ec;
  color: var(--success);
  font-size: 32px;
  font-weight: 700;
  margin: 0 auto 20px;
}

.complete-card h1 {
  font-size: 20px;
  margin: 0 0 12px;
}

.complete-card p {
  color: var(--text-sub);
  font-size: 14px;
}

.receipt-box {
  background: #eef4ff;
  border: 1px solid #cfe0fb;
  border-radius: var(--radius);
  padding: 20px 16px;
  margin: 20px 0;
}

.receipt-label {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.receipt-no {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
  word-break: break-all;
}

.receipt-note {
  font-size: 13px;
  color: var(--error);
  font-weight: 600;
  margin-top: 10px;
}

.copy-btn {
  margin-top: 14px;
}

.copy-feedback {
  font-size: 13px;
  color: var(--success);
  margin-top: 8px;
  min-height: 18px;
}

/* ---------- 状況確認 ---------- */

.status-result {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed #edf0f4;
  font-size: 14px;
}

.status-row:last-of-type { border-bottom: none; }

.status-row-label {
  color: var(--text-sub);
  flex-shrink: 0;
  min-width: 34%;
}

.status-row-value {
  text-align: right;
  word-break: break-word;
}

.status-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.status-badge.status-申請中 { background: #fff2e0; color: var(--warning); }
.status-badge.status-承認 { background: #e8f7ec; color: var(--success); }
.status-badge.status-却下 { background: #fde8e8; color: var(--error); }
.status-badge.status-差戻し { background: #eceff2; color: var(--muted); }

.status-comment {
  margin-top: 12px;
  background: #f7f8fa;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
}

/* ---------- 全体エラー ---------- */

.global-error {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  background: #fde8e8;
  color: var(--error);
  border: 1px solid #f5b5b5;
  padding: 12px 16px;
  border-radius: var(--radius);
  z-index: 100;
  font-size: 14px;
  text-align: center;
}

/* ---------- ある程度広い画面でも中央寄せで読みやすく ---------- */

@media (min-width: 640px) {
  .form-footer .footer-buttons,
  .step-content {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
  }
  .form-footer {
    padding-left: calc(50% - 320px);
    padding-right: calc(50% - 320px);
  }
}
@media (min-width: 640px) and (max-width: 719px) {
  .form-footer { padding-left: 16px; padding-right: 16px; }
}
