/* ============================================================
   新莊慈聖宮 線上報名系統 — 溫潤莊嚴宮廟風格 UI
   專為長輩與 LINE 手機瀏覽器最佳化（大字體、高對比、大按鈕）
   ============================================================ */
:root {
  --primary: #8b1e1e;
  --primary-dark: #6b1414;
  --primary-light: #fdf2f2;
  --gold: #b8860b;
  --gold-bg: #fcf8eb;
  --bg: #f7f3ec;
  --surface: #ffffff;
  --ink: #231f20;
  --muted: #5f5853;
  --border: #dfd6c7;
  --success: #1f6f43;
  --success-bg: #eaf6ef;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(45, 28, 18, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Header */
.site-header {
  background: linear-gradient(135deg, #7c1919 0%, #9b2626 100%);
  color: #fff;
  border-bottom: 4px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
}

.header-inner {
  max-width: 1020px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-seal {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid #f4d27a;
  background: rgba(0, 0, 0, 0.18);
  color: #f9e3a3;
  font-family: "DFKai-SB", "BiauKai", serif;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 1px;
}

.brand-text h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 1px;
  line-height: 1.2;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #f3dfd5;
}

.main-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}

.nav-btn:hover,
.nav-btn.active {
  background: #fff;
  color: var(--primary);
  border-color: #fff;
}

.nav-admin {
  border-color: #f4d27a;
  color: #fde8a8;
}

/* Layout */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  min-height: calc(100vh - 160px);
}

.site-footer {
  text-align: center;
  padding: 20px 16px 32px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

.footer-note {
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.85;
}

/* Cards & Typography */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 20px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.section-heading {
  font-size: 22px;
  margin: 0 0 14px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.badge-banshi { background: var(--primary-light); color: var(--primary); border: 1px solid #e7baba; }
.badge-general { background: var(--gold-bg); color: #8c6200; border: 1px solid #e7d195; }
.badge-open { background: var(--success-bg); color: var(--success); }
.badge-late { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-gray { background: #ece8e1; color: #57524d; }

/* Alerts */
.alert {
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 15px;
  border-left: 4px solid;
}

.alert-warn { background: var(--warn-bg); border-color: var(--warn); color: #78350f; }
.alert-info { background: #eff6ff; border-color: #2563eb; color: #1e3a8a; }
.alert-success { background: var(--success-bg); border-color: var(--success); color: #14532d; }
.alert-danger { background: var(--danger-bg); border-color: var(--danger); color: #7f1d1d; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

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

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

.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover:not(:disabled) { background: #966d09; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #165633; }

.btn-outline { background: #fff; color: var(--ink); border-color: #c8bfb0; }
.btn-outline:hover:not(:disabled) { background: #f5efe6; }

.btn-danger-outline { background: #fff; color: var(--danger); border-color: #f3b8b8; }
.btn-danger-outline:hover:not(:disabled) { background: var(--danger-bg); }

.btn-sm { padding: 6px 12px; font-size: 14px; border-radius: 8px; }
.btn-block { width: 100%; }

/* Form Elements */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-group.full {
  grid-column: 1 / -1;
}

label.field-label {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}

.req { color: var(--danger); margin-left: 3px; }

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid #cfc6b8;
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 30, 30, 0.12);
}

/* Checkbox / Radio Chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1.5px solid #cfc6b8;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  user-select: none;
  transition: all 0.15s;
}

.chip-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.chip-label.checked {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.chip-label.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sub-box {
  margin-top: 8px;
  padding: 12px;
  border-radius: 10px;
  background: #faf7f2;
  border: 1px dashed #d1c4b0;
}

/* Member Cards inside Registration Form */
.member-card {
  border: 2px solid #e3d9ca;
  border-radius: 14px;
  padding: 18px;
  background: #fffdf9;
  margin-bottom: 16px;
}

.member-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ebe3d6;
}

.member-card-header h4 {
  margin: 0;
  font-size: 18px;
  color: var(--primary);
}

.talisman-box {
  background: var(--gold-bg);
  border: 1.5px solid #e3cb8e;
  border-radius: 12px;
  padding: 14px;
  margin-top: 10px;
}

.talisman-box-title {
  font-weight: 700;
  color: #7a5400;
  margin-bottom: 8px;
  font-size: 15px;
}

/* Sticky Summary Bar */
.sticky-summary {
  position: sticky;
  bottom: 12px;
  background: #231f20;
  color: #fff;
  padding: 14px 18px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  z-index: 30;
}

/* Event Cards */
.event-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

/* Admin Tabs & Tables */
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 9px 16px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
}

.sheet-admin-card {
  border: 1.5px solid #d9cebc;
  border-radius: 12px;
  padding: 16px;
  background: #fff;
  margin-bottom: 14px;
}

.sheet-admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid #eee7dc;
}

.queue-input {
  width: 82px !important;
  padding: 6px 8px !important;
  text-align: center;
  font-weight: 800;
  font-size: 16px !important;
}

.merged-pill {
  background: #faf6ee;
  border: 1px solid #e2d6c1;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

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

table.data-table th,
table.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e9e2d6;
  text-align: left;
  vertical-align: top;
}

table.data-table th {
  background: #f5efe6;
  font-weight: 700;
  white-space: nowrap;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 12, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-backdrop.hidden { display: none; }

.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  color: var(--primary);
}

/* Toast */
.toast-root {
  position: fixed;
  top: 76px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #231f20;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.print-only {
  display: none;
}

.reg-code-box {
  background: var(--gold-bg);
  border: 2px dashed var(--gold);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  margin: 16px 0;
}

.reg-code-text {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--primary);
}

/* v2: 農曆日期選單群組排版 */
.lunar-select-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

@media (max-width: 640px) {
  .lunar-select-row {
    grid-template-columns: 1fr 1fr;
  }
}

.leap-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 10px;
  border: 1.5px solid #cfc6b8;
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.leap-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}
