/* =====================================================================
   MOBILE LIBRARY BOOKING — STYLESHEET
   ===================================================================== */

:root {
  --primary:        #2A7D6F;
  --primary-dark:   #1f5f54;
  --primary-light:  #e8f5f2;
  --accent:         #f0a500;
  --success:        #2e9e6b;
  --danger:         #c0392b;
  --muted:          #6b7280;
  --border:         #d1d5db;
  --surface:        #ffffff;
  --bg:             #f4f7f6;
  --text:           #1a1a1a;
  --text-light:     #4b5563;

  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;

  --shadow-card: 0 2px 12px rgba(42, 125, 111, 0.10), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-hover: 0 6px 24px rgba(42, 125, 111, 0.18), 0 2px 6px rgba(0,0,0,0.08);

  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────── */
.site-header {
  background: var(--primary);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-header .logo-icon {
  font-size: 28px;
  line-height: 1;
}

.site-header h1 {
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.site-header p {
  color: rgba(255,255,255,0.8);
  font-size: 0.8rem;
  margin-top: 1px;
}

/* ── Main layout ─────────────────────────────────────────────────── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 60px;
}

/* ── Progress bar ────────────────────────────────────────────────── */
.progress-wrap {
  width: 100%;
  max-width: 560px;
  margin-bottom: 24px;
}

.progress-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.progress-steps {
  display: flex;
  gap: 6px;
}

.progress-steps .step-dot {
  flex: 1;
  height: 5px;
  border-radius: 99px;
  background: var(--border);
  transition: background var(--transition);
}

.progress-steps .step-dot.active  { background: var(--primary); }
.progress-steps .step-dot.done    { background: var(--primary-light); border: 1.5px solid var(--primary); }

/* ── Card ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 36px 32px;
  width: 100%;
  max-width: 560px;
  animation: fadeUp 0.3s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.card-subtitle {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 28px;
  line-height: 1.5;
  text-wrap: pretty;
}

/* ── Form fields ─────────────────────────────────────────────────── */
.field {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

label .optional {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.78rem;
}

input[type="text"],
input[type="email"],
select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42, 125, 111, 0.12);
}

input::placeholder { color: #adb5bd; }

/* ── New site message ────────────────────────────────────────────── */
.new-site-message {
  display: flex;
  gap: 14px;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 18px 16px;
  margin-bottom: 4px;
}

.new-site-message-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.new-site-message-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e40af;
  margin-bottom: 8px;
}

.new-site-message-body {
  font-size: 0.875rem;
  color: #1e3a8a;
  line-height: 1.5;
  margin-bottom: 10px;
}

.new-site-message-body a { color: #1d4ed8; }

.new-site-message-list {
  font-size: 0.85rem;
  color: #1e3a8a;
  padding-left: 18px;
  line-height: 1.8;
  margin-bottom: 10px;
}

.new-site-message-note {
  font-size: 0.8rem;
  color: #3b82f6;
  font-style: italic;
  line-height: 1.5;
}

/* ── Region auto-display ─────────────────────────────────────────── */
.region-display {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9fafb;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: border-color var(--transition);
}

.region-display.filled {
  background: var(--primary-light);
  border-color: var(--primary);
}

.region-placeholder {
  font-size: 0.9rem;
  color: #adb5bd;
  font-style: italic;
}

.region-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.region-badge::before {
  content: '📍';
  font-style: normal;
}

/* ── Radio cards (yes/no MOLLY site) ────────────────────────────── */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  user-select: none;
}

.radio-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42, 125, 111, 0.08);
}

.radio-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px var(--primary);
}

.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-icon { font-size: 1.2rem; flex-shrink: 0; }
.radio-label { font-size: 0.9rem; font-weight: 500; color: var(--text); line-height: 1.4; }

/* ── Month sub-progress ──────────────────────────────────────────── */
.month-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.month-progress-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.month-progress-dots {
  display: flex;
  gap: 6px;
}

.month-dot {
  width: 28px;
  height: 5px;
  border-radius: 99px;
  background: var(--border);
  transition: background var(--transition);
}

.month-dot.active  { background: var(--primary); }
.month-dot.done    { background: #a7f3d0; }
.month-dot.skipped { background: #f3f4f6; border: 1.5px solid var(--border); }

/* ── Skip month button ───────────────────────────────────────────── */
.skip-month-wrap {
  text-align: center;
  margin: 20px 0 4px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.btn-skip-month {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.btn-skip-month:hover {
  color: var(--text);
  background: #f3f4f6;
  text-decoration: none;
}

/* ── Month summary blocks (Step 4) ──────────────────────────────── */
.month-summary-block {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.month-summary-header {
  background: var(--primary-light);
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

.month-summary-body {
  padding: 0;
}

.month-summary-body .summary-table {
  margin: 0;
}

.month-summary-body .summary-table td {
  padding: 8px 14px;
}

.month-skipped {
  padding: 10px 14px;
  font-size: 0.875rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Slot legend ─────────────────────────────────────────────────── */
.slot-legend {
  background: #f8faf9;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.slot-legend-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.slot-legend-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-light);
  line-height: 1.4;
}

.cal-btn--legend {
  flex-shrink: 0;
  width: 72px;
  pointer-events: none;
  font-size: 0.7rem;
  padding: 4px 6px;
}

/* ── Calendar slot grid ──────────────────────────────────────────── */
.cal-week {
  margin-bottom: 28px;
}

.cal-week-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.cal-week-num {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-light);
  border-radius: 99px;
  padding: 2px 10px;
}

.cal-week-range {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Horizontal scroll on narrow screens */
.cal-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cal-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

/* Header: day names */
.cal-day-name {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 6px 2px;
  width: 80px;
}

/* Header: date numbers */
.cal-date-num {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
  padding: 2px 6px 8px;
  border-bottom: 2px solid var(--primary-light);
}

.cal-corner { width: 100px; }

/* Row label (Morning / Afternoon) */
.cal-slot-label {
  padding: 8px 10px 8px 0;
  vertical-align: middle;
  white-space: nowrap;
  border-right: 2px solid var(--primary-light);
}

.cal-slot-label {
  display: table-cell; /* needed for flex child inside */
}

.cal-slot-label > * { vertical-align: middle; }

.cal-slot-icon {
  font-size: 1.1rem;
  margin-right: 6px;
}

.cal-slot-lbl-text {
  font-size: 0.8rem;
  line-height: 1.3;
  display: inline-block;
  vertical-align: middle;
}

.cal-slot-lbl-text strong { color: var(--text); font-size: 0.82rem; }
.cal-slot-lbl-text small  { color: var(--muted); font-size: 0.7rem; }

/* Slot data cells */
.cal-cell {
  text-align: center;
  padding: 6px 4px;
  border-bottom: 1px solid #f0f0f0;
}

.cal-cell--empty {
  background: repeating-linear-gradient(
    -45deg, transparent, transparent 4px, #f9f9f9 4px, #f9f9f9 8px
  );
}

/* Slot buttons */
.cal-btn {
  display: inline-block;
  width: 100%;
  max-width: 78px;
  padding: 5px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  line-height: 1.3;
  white-space: nowrap;
}

.cal-btn--avail {
  background: #d1fae5;
  color: #065f46;
  border-color: #6ee7b7;
}
.cal-btn--avail:hover {
  background: #a7f3d0;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.cal-btn--match {
  background: #bbf7d0;
  color: #065f46;
  border-color: var(--success);
}

.cal-btn--taken {
  background: #f3f4f6;
  color: #9ca3af;
  border-color: #e5e7eb;
  cursor: not-allowed;
}

.cal-btn--locked {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
  cursor: not-allowed;
  font-size: 0.68rem;
}

.cal-btn--selected {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary-dark) !important;
  box-shadow: 0 0 0 2px rgba(42, 125, 111, 0.3);
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  font-family: inherit;
  letter-spacing: -0.01em;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  flex: 1;
}

.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-hover); }

.btn-secondary {
  background: #f3f4f6;
  color: var(--text-light);
  padding-left: 18px;
  padding-right: 18px;
}

.btn-secondary:hover { background: var(--border); }

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

/* Spinner inside button */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn.loading .btn-label { display: none; }
.btn.loading .spinner   { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Alert / notice ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}

.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-warning { background: #fef9c3; border: 1px solid #fde047; color: #713f12; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* ── Summary table (step 4) ──────────────────────────────────────── */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}

.summary-table tr:not(:last-child) td {
  border-bottom: 1px solid var(--border);
}

.summary-table td {
  padding: 10px 0;
  font-size: 0.9rem;
  vertical-align: top;
}

.summary-table td:first-child {
  color: var(--muted);
  font-weight: 500;
  width: 120px;
  padding-right: 12px;
}

.summary-table td:last-child {
  color: var(--text);
  font-weight: 600;
}

/* ── Success screen ──────────────────────────────────────────────── */
.success-screen {
  text-align: center;
  padding: 12px 0;
}

.success-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  display: block;
}

.success-screen h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.success-screen p {
  color: var(--text-light);
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 380px;
  margin: 0 auto;
  text-wrap: pretty;
}

/* ── Loading overlay ─────────────────────────────────────────────── */
.loading-overlay {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.875rem;
  padding: 16px 0;
}

.loading-overlay .spinner {
  border-color: rgba(42, 125, 111, 0.2);
  border-top-color: var(--primary);
  display: block;
  width: 18px; height: 18px;
}

/* ── Footer ──────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 20px 16px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .card { padding: 24px 20px; border-radius: var(--radius-md); }
  .slot-cards { grid-template-columns: 1fr; }
  .card-title { font-size: 1.2rem; }
  .btn-row { flex-direction: column-reverse; }
  .btn-secondary { width: 100%; }
}
