/* =====================================================
   日本バプテスト連盟 登録者確認システム
   スタイルシート（モバイルファースト）
   ===================================================== */

/* ----- リセット・基本設定 ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:      #1a56c4;
  --primary-dark: #143e96;
  --primary-light:#e8effe;
  --success:      #1a7f3c;
  --success-bg:   #e8f5ed;
  --danger:       #b91c1c;
  --danger-bg:    #fef2f2;
  --gray:         #6b7280;
  --gray-light:   #f3f4f6;
  --gray-border:  #d1d5db;
  --text:         #1f2937;
  --text-muted:   #6b7280;
  --white:        #ffffff;
  --shadow:       0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md:    0 4px 6px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.08);
  --radius:       8px;
  --radius-sm:    4px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
               "Noto Sans JP", "Yu Gothic", sans-serif;
  background: #f0f4f8;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ----- レイアウト ----- */
.page-wrapper {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
}

.page-wrapper.wide {
  max-width: 1000px;
}

/* ----- ヘッダー ----- */
.site-header {
  background: var(--primary);
  color: var(--white);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.site-header h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.site-header .header-sub {
  font-size: .8rem;
  opacity: .85;
}

.header-nav a {
  color: var(--white);
  text-decoration: none;
  font-size: .85rem;
  opacity: .9;
}

.header-nav a:hover { opacity: 1; text-decoration: underline; }

/* ----- カード ----- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-light);
}

/* ----- 教会名バナー ----- */
.church-banner {
  background: var(--primary);
  color: var(--white);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-md);
}

.church-banner .church-name {
  font-size: 1.3rem;
  font-weight: 700;
}

.church-banner .change-link {
  color: rgba(255,255,255,.85);
  font-size: .82rem;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,.5);
  padding: 4px 10px;
  border-radius: 20px;
}

.church-banner .change-link:hover {
  background: rgba(255,255,255,.15);
}

/* ----- フォーム ----- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,196,.15);
}

.form-control::placeholder { color: var(--text-muted); }

/* ----- ボタン ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
  background: var(--success);
  color: var(--white);
  box-shadow: var(--shadow);
}
.btn-success:hover { background: #166534; }

.btn-danger {
  background: var(--danger);
  color: var(--white);
  box-shadow: var(--shadow);
}
.btn-danger:hover { background: #991b1b; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-gray {
  background: var(--gray-light);
  color: var(--text-muted);
  cursor: default;
  box-shadow: none;
}

.btn-sm {
  padding: 8px 14px;
  font-size: .85rem;
}

.btn-full { width: 100%; }

/* ----- アラート ----- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert-error   { background: var(--danger-bg);  color: var(--danger);  border-left: 4px solid var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); border-left: 4px solid var(--success); }
.alert-info    { background: var(--primary-light); color: var(--primary); border-left: 4px solid var(--primary); }

/* ----- ログイン画面 ----- */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1a3a6c 0%, #1a56c4 100%);
}

.login-box {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo h1 {
  font-size: 1.1rem;
  color: var(--primary);
  font-weight: 700;
}

.login-logo .subtitle {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-church-name {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 20px;
}

/* ----- 登録者一覧 ----- */
.member-count {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.member-item {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color .15s;
}

.member-item:hover { border-color: var(--primary); }

.member-item.confirmed {
  background: var(--gray-light);
  border-color: var(--gray-border);
  opacity: .7;
}

.member-info { flex: 1; min-width: 0; }

.member-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-meta {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.member-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.member-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.badge-member  { background: var(--success-bg); color: var(--success); }
.badge-nonmember { background: var(--danger-bg); color: var(--danger); }

/* ----- モーダル ----- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--white);
  border-radius: 16px 16px 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 520px;
  animation: slideUp .2s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-target {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-border);
}

.modal-target strong { color: var(--text); }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.modal-actions .btn { flex: 1; }

/* ----- 完了バナー ----- */
.complete-banner {
  text-align: center;
  padding: 40px 20px;
}

.complete-banner .icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.complete-banner h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 8px;
}

.complete-banner p {
  color: var(--text-muted);
  font-size: .9rem;
}

/* ----- 教会選択 ----- */
.church-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 60vh;
  overflow-y: auto;
}

.church-option {
  padding: 14px 16px;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--white);
  transition: border-color .15s, background .15s;
  text-decoration: none;
  color: var(--text);
}

.church-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.church-option .church-option-count {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ----- 管理者テーブル ----- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.admin-table th {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--primary);
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-border);
  vertical-align: middle;
}

.admin-table tr:hover td { background: var(--gray-light); }

/* ----- 進捗バー ----- */
.progress-bar-wrap {
  background: var(--gray-border);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 20px;
  transition: width .3s;
}

/* ----- 管理ダッシュボードのグリッド ----- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-card .stat-num {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ----- 名寄せ画面 ----- */
.alias-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-border);
  flex-wrap: wrap;
}

.alias-name {
  flex: 1;
  font-size: .9rem;
  min-width: 140px;
}

.alias-count {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.alias-select {
  flex: 2;
  min-width: 160px;
}

/* ----- ユーティリティ ----- */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); font-size: .85rem; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mb-4  { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex  { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none; }

/* ----- PC対応（タブレット以上） ----- */
@media (min-width: 640px) {
  .page-wrapper { padding: 24px; }
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: 16px; }
  .member-item { padding: 16px 20px; }
  .login-box { padding: 44px 40px; }
}

/* ----- 印刷スタイル ----- */
@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .print-page {
    page-break-after: always;
    padding: 20mm;
    max-width: 100%;
  }
  .print-page:last-child { page-break-after: avoid; }
}
