/* ─── Design tokens ──────────────────────────────────────────────────────────── */
:root {
  /* Recreate NZ brand */
  --cream:       #F2EDE3;
  --cream-dark:  #E8E1D4;
  --navy:        #1C1B3A;
  --navy-mid:    #2e2d52;
  --green:       #2A4F14;
  --green-mid:   #3a6b1e;
  --green-light: #C5D9A0;
  --green-pale:  #e8f0d8;
  --yellow:      #F2C840;
  --yellow-dark: #d9b230;

  /* Neutrals */
  --grey-700: #374151;
  --grey-500: #6b7280;
  --grey-300: #d1d5db;
  --grey-100: #f3f4f6;
  --grey-50:  #f9fafb;
  --white:    #ffffff;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 3px rgba(28,27,58,.08), 0 1px 2px rgba(28,27,58,.04);
  --shadow-md: 0 4px 16px rgba(28,27,58,.12);
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--cream);
  color: var(--navy);
  line-height: 1.5;
  min-height: 100vh;
}
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; font-size: 1rem; }

/* ─── Utilities ──────────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}
.hidden { display: none !important; }

/* ─── Login page ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--cream);
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--cream-dark);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}

.login-brand-icon {
  width: 44px;
  height: 44px;
  background: var(--green);
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-brand-icon svg { color: var(--white); }

.login-brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.2;
}

.login-brand-sub {
  font-size: 0.8rem;
  color: var(--grey-500);
  font-weight: 400;
}

.login-heading {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 8px;
}

.login-sub {
  font-size: 0.9rem;
  color: var(--grey-500);
  margin-bottom: 28px;
  line-height: 1.6;
}

.form-group { margin-bottom: 16px; }

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

.form-group input,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--grey-300);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--navy);
  background: var(--white);
  transition: border-color .15s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(42,79,20,.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  transition: background .15s, opacity .15s, transform .1s;
  outline: none;
}

.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--yellow);
  color: var(--navy);
  width: 100%;
}
.btn-primary:hover:not(:disabled) { background: var(--yellow-dark); }

.btn-secondary {
  background: var(--grey-100);
  color: var(--grey-700);
}
.btn-secondary:hover:not(:disabled) { background: var(--grey-300); }

.btn-ghost {
  background: transparent;
  color: var(--grey-500);
  padding: 8px 12px;
  font-size: 0.85rem;
}
.btn-ghost:hover { color: var(--navy); background: var(--cream); }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 20px;
}
.alert-success { background: var(--green-pale); color: var(--green); border: 1px solid var(--green-light); }
.alert-error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ─── Portal layout ──────────────────────────────────────────────────────────── */
.portal-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal-header {
  background: var(--cream);
  color: var(--navy);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--cream-dark);
}

.portal-header-brand {
  display: inline-flex;
  align-items: center;
}

.header-logo {
  height: 28px;
  width: auto;
  display: block;
}

.portal-header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-header-user span {
  font-size: 0.88rem;
  color: var(--grey-500);
}

.logout-btn {
  background: var(--white);
  color: var(--navy);
  border: 1px solid var(--cream-dark);
  border-radius: 99px;
  padding: 7px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.logout-btn:hover { background: var(--cream-dark); }

/* ─── Tabs ───────────────────────────────────────────────────────────────────── */
.portal-tabs {
  background: var(--white);
  border-bottom: 1px solid var(--cream-dark);
  padding: 0 28px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.tab-btn {
  padding: 14px 18px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--grey-500);
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--navy); }

.tab-btn.active {
  color: var(--green);
  border-bottom-color: var(--yellow);
}

/* ─── Content area ───────────────────────────────────────────────────────────── */
.portal-content {
  flex: 1;
  padding: 36px 28px;
  max-width: 880px;
  margin: 0 auto;
  width: 100%;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 4px;
}

.section-sub {
  font-size: 0.88rem;
  color: var(--grey-500);
  margin-bottom: 28px;
  line-height: 1.6;
}

/* ─── Profile ────────────────────────────────────────────────────────────────── */
.profile-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  border: 1px solid var(--cream-dark);
}

.profile-card h3 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--cream-dark);
}

.profile-card--danger {
  border-color: #fecaca;
  background: #fff8f8;
}

.profile-card--danger h3 {
  color: #b91c1c;
  border-bottom-color: #fecaca;
}

.danger-desc {
  font-size: 0.85rem;
  color: var(--grey-500);
  margin-bottom: 20px;
  line-height: 1.5;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 560px) {
  .profile-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; }
  .portal-content { padding: 24px 16px; }
  .portal-header { padding: 0 16px; }
  .portal-tabs { padding: 0 16px; }
}

.field-readonly label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--grey-500);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.field-readonly .value {
  font-size: 0.95rem;
  color: var(--navy);
  font-weight: 500;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-active     { background: var(--green-pale);  color: var(--green); }
.badge-inactive   { background: var(--grey-100);    color: var(--grey-700); }
.badge-pending    { background: #fef9c3;             color: #854d0e; }
.badge-confirmed  { background: var(--green-pale);  color: var(--green); }
.badge-waitlisted { background: #fef3c7;             color: #92400e; }
.badge-cancelled  { background: #fee2e2;             color: #991b1b; }
.badge-attended   { background: #dbeafe;             color: #1e40af; }
.badge-review     { background: #f3e8ff;             color: #6b21a8; }

.save-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  align-items: center;
}

.save-status {
  font-size: 0.85rem;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─── Programme cards ────────────────────────────────────────────────────────── */
.programme-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.programme-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--cream-dark);
}

.programme-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.programme-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
}

.programme-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--grey-500);
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--cream);
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 0.78rem;
  color: var(--grey-700);
  font-weight: 500;
  border: 1px solid var(--cream-dark);
}

.meta-chip--price {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
  font-weight: 600;
}

.programme-description {
  margin-top: 10px;
  font-size: 0.84rem;
  color: var(--grey-600);
  line-height: 1.5;
}

.spots-bar {
  height: 6px;
  background: var(--cream);
  border-radius: 99px;
  overflow: hidden;
}

.spots-fill {
  height: 100%;
  background: var(--green-light);
  border-radius: 99px;
  transition: width .4s;
}

.spots-fill.full { background: #f87171; }
.spots-fill.nearly { background: #fbbf24; }

.spots-label {
  font-size: 0.8rem;
  color: var(--grey-500);
}

.programme-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.btn-book {
  background: var(--yellow);
  color: var(--navy);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}

.btn-book:hover:not(:disabled) { background: var(--yellow-dark); }
.btn-book:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Bookings list ──────────────────────────────────────────────────────────── */
.bookings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.booking-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  align-items: center;
  border: 1px solid var(--cream-dark);
}

.booking-ref {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--grey-500);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.booking-programme {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
}

.booking-date {
  font-size: 0.82rem;
  color: var(--grey-500);
  margin-top: 2px;
}

.booking-status-col {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.btn-cancel-booking {
  background: none;
  border: none;
  font-size: 0.78rem;
  color: var(--grey-500);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.btn-cancel-booking:hover { color: #b91c1c; }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--grey-500);
}

.empty-state svg {
  margin: 0 auto 16px;
  opacity: .3;
  color: var(--green-light);
}

.empty-state p {
  font-size: 0.95rem;
}

/* ─── Loading spinner ────────────────────────────────────────────────────────── */
.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--cream-dark);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  background: var(--navy);
  color: var(--white);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
  max-width: 320px;
}

.toast.success { background: var(--green); }
.toast.error   { background: #b91c1c; }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── Programme checkbox + notes (booking request flow) ─────────────────────── */
.prog-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  flex: 1;
}

.prog-checkbox-label input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}

.programme-card-notes {
  padding-top: 4px;
}

.prog-notes {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--grey-300);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--navy);
  background: var(--grey-50);
  outline: none;
  transition: border-color .15s;
}

.prog-notes:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(42,79,20,.1);
}

.programme-card--booked {
  opacity: .85;
  border-color: var(--green-light) !important;
  background: var(--green-pale) !important;
}

.btn-cancel-request {
  background: none;
  border: none;
  font-size: 0.78rem;
  color: var(--grey-500);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.btn-cancel-request:hover:not(:disabled) { color: #b91c1c; }
.btn-cancel-request:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Loading splash ─────────────────────────────────────────────────────────── */
#splash {
  position: fixed;
  inset: 0;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity .45s ease;
}

#splash.fading {
  opacity: 0;
  pointer-events: none;
}

.splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.splash-logo {
  height: 48px;
  width: auto;
  display: block;
}

.splash-tagline {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -.02em;
  line-height: 1.2;
}

#splash-dots {
  display: inline-block;
  width: 1.6em;
  text-align: left;
}

/* ─── Privacy banner ─────────────────────────────────────────────────────────── */
.privacy-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--navy);
  color: rgba(255,255,255,.6);
  font-size: 11px;
  line-height: 1.65;
  padding: 11px 48px 11px 20px;
  text-align: center;
  z-index: 500;
  border-top: 1px solid rgba(255,255,255,.08);
}

.privacy-banner a {
  color: rgba(255,255,255,.6);
  text-decoration: underline;
}

.privacy-banner a:hover { color: var(--white); }

.privacy-close {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,.45);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color .15s;
}

.privacy-close:hover { color: var(--white); }

/* Give the page body enough bottom clearance for the fixed privacy banner */
.portal-layout { padding-bottom: 52px; }

/* ─── Parent portal: participant selector bar ─────────────────────────────────── */
.participant-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--cream-dark);
}

.participant-bar-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--grey-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

.participant-select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23374151' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-color: var(--cream);
  flex: 1;
  max-width: 280px;
  padding: 7px 32px 7px 10px;
  border: 1.5px solid var(--grey-300);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}

.participant-select:focus { border-color: var(--green); }

/* ─── Parent portal: invoices ─────────────────────────────────────────────────── */
.invoices-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.invoice-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}

.invoice-ref {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--grey-500);
  letter-spacing: .03em;
  margin-bottom: 4px;
}

.invoice-num {
  font-family: monospace;
  font-weight: 400;
}

.invoice-programme {
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
}

.invoice-date {
  font-size: 0.82rem;
  color: var(--grey-500);
  margin-top: 4px;
}

.invoice-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.invoice-amount {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
}

.invoice-link {
  font-size: 0.82rem;
  color: var(--green);
  text-decoration: underline;
}

.invoice-link:hover { color: var(--green-mid); }

/* ─── Confirm modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28,27,58,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 36px 32px 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-md), 0 20px 60px rgba(28,27,58,.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  animation: modalIn .18s ease;
}

@keyframes modalIn {
  from { transform: scale(.95) translateY(4px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);   opacity: 1; }
}

.modal-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fee2e2;
  color: #b91c1c;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--navy);
  margin: 0;
}

.modal-message {
  font-size: 0.9rem;
  color: var(--grey-700);
  line-height: 1.6;
  max-width: 320px;
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
}

.modal-actions .btn { flex: 1; }

.btn-danger {
  background: #b91c1c;
  color: var(--white);
}
.btn-danger:hover:not(:disabled) { background: #991b1b; }

.btn-cancel-parent-booking {
  background: none;
  border: none;
  font-size: 0.78rem;
  color: var(--grey-500);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.btn-cancel-parent-booking:hover { color: #b91c1c; }

/* ─── Parent portal: settings toggles ────────────────────────────────────────── */
.settings-toggles {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 20px;
  border-top: 1px solid var(--cream-dark);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--cream-dark);
}

.toggle-info { flex: 1; }

.toggle-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
}

.toggle-desc {
  font-size: 0.82rem;
  color: var(--grey-500);
  margin-top: 3px;
  line-height: 1.5;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--grey-300);
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-switch input:focus-visible + .toggle-slider { outline: 2px solid var(--green); outline-offset: 2px; }
