/* ==========================================================
   Meetings page (/meet), part: a church's meetings (js/meet-team.js, TINL-1470).
   The calendar (month grid + agenda), the details / schedule / Room settings dialogs (#meet-modal) and the room QR
   dialog (#meet-qr-modal). Loaded after meet-home.css.
   The calendar and dialog rules are the team console's own (they moved here from team.css with the code); the small
   helpers below them are the ones team.css had, because team.css is not loaded on this page.
   Tokens only (docs/design.md). Prefix: meet- (moved), mt- (this page's own).
   ========================================================== */

/* ---------- Helpers the moved markup uses (from team.css) ---------- */
.err-box { display: flex; align-items: flex-start; gap: 10px; }
.err-box .btn { margin-left: auto; }
.skel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.skel-card { height: 220px; border-radius: var(--radius); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-row .form-group { margin-bottom: 18px; }
.form-optional { font-weight: 400; color: var(--text-faint); font-size: var(--fs-xs); margin-left: 4px; }
.copy-field { display: flex; gap: 8px; align-items: stretch; }
.copy-field .form-control { font-family: var(--font-mono); font-size: 0.8rem; background: var(--bg-subtle); }

.qr-box {
  display: grid; place-items: center;
  padding: 18px; margin: 0 auto 16px;
  width: fit-content;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.qr-box canvas { display: block; width: 220px; height: 220px; image-rendering: pixelated; }
.qr-url { text-align: center; font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-secondary); word-break: break-all; margin-bottom: 16px; }

.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 0; }
.switch-row + .switch-row { border-top: 1px solid var(--border-light); }
.switch-row-text strong { display: block; font-size: var(--fs-sm); color: var(--text); font-weight: 600; }
.switch-row-text span { display: block; font-size: var(--fs-xs); color: var(--text-light); margin-top: 2px; }

/* ---------- Meetings (church room settings + calendar; js/meet-team.js) ---------- */
.meet-link-field .form-control { min-width: 0; }
.meet-room-settings { margin-top: 18px; border-top: 1px solid var(--border-light); }
.meet-room-settings h4 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-light); margin: 16px 0 0; font-weight: 700; }
.meet-langs { padding: 14px 0 0; border-top: 1px solid var(--border-light); }
.meet-rate-note {
  display: flex; gap: 8px; align-items: flex-start; margin: 14px 0 0; padding: 10px 12px;
  border-radius: var(--radius-sm); background: var(--bg-subtle); border: 1px solid var(--border-light);
  font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.5;
}
.meet-rate-note svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--primary); margin-top: 1px; }
.meet-member-note { display: flex; gap: 8px; align-items: center; margin: 14px 0 0; font-size: var(--fs-sm); color: var(--text-light); }
.meet-member-note svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Month grid + agenda */
.meet-cal-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.meet-cal-layout > .card { margin-bottom: 0; }
.meet-cal { padding: 16px; }
.meet-cal-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.meet-cal-nav { display: flex; align-items: center; gap: 8px; min-width: 0; }
.meet-cal-title { font-size: var(--fs-lg); margin: 0; min-width: 9em; text-align: center; }
.meet-cal-dow, .meet-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.meet-cal-dow { margin-bottom: 4px; }
.meet-cal-dow > span { text-align: center; font-size: var(--fs-xs); font-weight: 600; color: var(--text-light); padding: 4px 0; }
.meet-dow-n { display: none; }
.meet-day {
  min-height: 92px; min-width: 0; padding: 4px;
  display: flex; flex-direction: column; gap: 3px;
  border-radius: 10px; background: var(--bg-subtle); border: 1px solid var(--border-light);
}
.meet-day.is-other { background: transparent; border-color: transparent; }
.meet-day.is-other .meet-day-num { color: var(--text-faint); }
.meet-day.is-selected { border-color: var(--primary); box-shadow: var(--ring); }
.meet-day-num {
  align-self: flex-start; min-width: 28px; height: 28px; padding: 0 6px;
  border: 0; border-radius: var(--radius-full); background: transparent;
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); cursor: pointer;
}
.meet-day-num:hover { background: var(--bg-hover); }
.meet-day-num:focus-visible { outline: none; box-shadow: var(--ring); }
.meet-day.is-today .meet-day-num { background: var(--primary); color: var(--text-on-primary); }
.meet-day-items { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.meet-chip {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: 0; border-left: 3px solid var(--primary); border-radius: 6px;
  padding: 3px 6px; background: var(--primary-bg); color: var(--primary-dark);
  font-size: 0.72rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.meet-chip b, .meet-chip span { display: block; overflow: hidden; text-overflow: ellipsis; }
.meet-chip b { font-weight: 700; }
.meet-chip:hover { background: rgba(var(--primary-rgb), 0.16); }
.meet-chip:focus-visible { outline: none; box-shadow: var(--ring); }
.meet-chip.is-past { opacity: 0.6; }
.meet-chip-more { background: transparent; border-left-color: transparent; color: var(--text-light); font-weight: 600; }
.meet-day-dots { display: none; }

.meet-agenda { padding: 18px; }
.meet-agenda-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.meet-agenda-head h3 { margin: 0; font-size: var(--fs-lg); }
.meet-agenda-list { display: flex; flex-direction: column; gap: 14px; }
.meet-ag-date { font-size: var(--fs-xs); font-weight: 700; color: var(--text-light); margin-bottom: 6px; }
.meet-ag-date.is-today { color: var(--primary); }
.meet-ag-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); border-left: 3px solid var(--primary); background: var(--bg-card);
}
.meet-ag-item + .meet-ag-item { margin-top: 6px; }
.meet-ag-item.is-past { opacity: 0.62; border-left-color: var(--border-strong); }
.meet-ag-item.is-now { background: var(--primary-bg); border-color: var(--primary-border); border-left-color: var(--primary); }
.meet-ag-main {
  flex: 1; min-width: 0; min-height: 44px; padding: 2px 0;
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  border: 0; background: transparent; text-align: left; color: inherit; cursor: pointer;
}
.meet-ag-main:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
.meet-ag-main:hover .meet-ag-title { color: var(--primary-dark); }
.meet-ag-time { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-light); font-variant-numeric: tabular-nums; }
.meet-ag-title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meet-ag-meta { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--text-light); min-width: 0; }
.meet-ag-meta svg { width: 12px; height: 12px; flex-shrink: 0; }
.meet-agenda-empty { color: var(--text-light); font-size: var(--fs-sm); padding: 18px 0; text-align: center; margin: 0; }
.meet-tz-note { display: flex; gap: 6px; align-items: flex-start; font-size: var(--fs-xs); color: var(--text-light); margin: 14px 0 0; }
.meet-tz-note svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }

/* Details + schedule dialogs (#meet-modal) */
#meet-modal .modal { max-width: 600px; }
.meet-dl { margin: 0 0 16px; display: grid; gap: 8px; }
.meet-dl-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; font-size: var(--fs-sm); }
.meet-dl dt { color: var(--text-light); display: flex; align-items: center; gap: 6px; font-weight: 500; }
.meet-dl dt svg { width: 15px; height: 15px; flex-shrink: 0; }
.meet-dl dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.meet-desc { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); color: var(--text-muted); background: var(--bg-subtle); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 16px; }
/* a scheduled meeting's New link and Password, for its editors (TINL-1476) */
.meet-link-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.meet-link-tools .btn { min-height: 44px; white-space: normal; line-height: 1.2; justify-content: center; flex-wrap: wrap; row-gap: 3px; }
/* a finger-sized tap area on the details dialog's buttons (touch screens) */
@media (pointer: coarse) { .meet-link-field .btn, .meet-detail-actions .btn, .meet-detail-edit .btn { min-height: 44px; } }
.meet-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.meet-detail-actions .btn { flex: 1 1 0; }
.meet-detail-actions .btn-primary { flex-basis: 100%; }
/* .modal .form-group:last-of-type drops the margin inside each .form-row; keep it when they stack. */
#meet-form .form-row .form-group { margin-bottom: 18px; }
.meet-detail-edit { justify-content: space-between; border-top: 1px solid var(--border-light); padding-top: 16px; margin-top: 20px; }
.meet-form-preview { margin: -8px 0 16px; }
.meet-form-preview:empty { display: none; }
.meet-form-preview.is-error { color: var(--danger); font-weight: 500; }
.meet-days { display: flex; flex-wrap: wrap; gap: 6px; }
.meet-daychip {
  min-width: 52px; min-height: 44px; padding: 0 10px; cursor: pointer;
  border-radius: var(--radius-full); border: 1px solid var(--border-strong); background: var(--bg-card);
  color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600;
  transition: background var(--dur) ease, color var(--dur) ease, border-color var(--dur) ease;
}
.meet-daychip:hover { border-color: var(--primary-border); }
.meet-daychip:focus-visible { outline: none; box-shadow: var(--ring); }
.meet-daychip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--text-on-primary); }
.meet-form-switch { border-top: 1px solid var(--border-light); margin-top: 4px; }
.meet-form-switch .switch { min-height: 44px; }

@media (max-width: 1100px) {
  .meet-cal-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .meet-cal { padding: 12px 10px; }
  .meet-cal-title { min-width: 0; font-size: var(--fs-base); }
  .meet-dow-s { display: none; }
  .meet-dow-n { display: inline; }
  .meet-cal-dow, .meet-cal-grid { gap: 2px; }
  .meet-day { min-height: 50px; padding: 0; align-items: stretch; justify-content: flex-start; border-radius: 8px; position: relative; }
  .meet-day-num { align-self: stretch; width: 100%; height: 100%; min-height: 48px; border-radius: 8px; padding: 0 0 10px; font-size: var(--fs-sm); }
  .meet-day.is-today .meet-day-num { background: transparent; color: var(--primary); font-weight: 800; }
  .meet-day.is-today { border-color: var(--primary-border); }
  .meet-day-items { display: none; }
  .meet-day-dots { display: flex; gap: 3px; justify-content: center; position: absolute; left: 0; right: 0; bottom: 8px; pointer-events: none; }
  .meet-day-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
  .meet-agenda { padding: 16px; }
  .meet-dl-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .meet-detail-actions .btn { flex: 1 1 100%; }
  .meet-link-field { flex-wrap: wrap; }
  .meet-link-field .form-control { flex: 1 1 100%; }
  .meet-link-field .btn:not(.btn-icon) { flex: 1 1 auto; }
  .meet-detail-edit { flex-direction: column-reverse; }
}

/* ---------- This page's own parts ---------- */
/* The section head's tools: the church picker (2 or more churches) or its name, and "Schedule a meeting". */
.mt-church-tools { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.mt-church-pick { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mt-church-pick label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-light); }
.mt-church-pick .form-control { min-height: 44px; min-width: 220px; max-width: 320px; }
/* one church: its name as a plain label (information, not a button) beside "Schedule a meeting" */
.mt-church-name {
  display: inline-flex; align-items: center; align-self: center; gap: 8px; min-height: 36px; padding: 0 4px; max-width: 320px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary);
}
.mt-church-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-church-name svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-light); }
.mt-church-tools .btn { min-height: 44px; }
/* the calendar's place while it loads */
.mt-cal-skel { height: 420px; border-radius: var(--radius-lg); }
/* the calendar fades in when it is drawn (prefers-reduced-motion is honoured globally, style.css) */
#meet-cal-wrap > .meet-cal-layout, #meet-cal-wrap > .card { animation: mtIn var(--dur-slow) var(--ease-out) both; }
@keyframes mtIn { from { opacity: 0; transform: translateY(6px); } }
/* Room settings in its dialog: the head above already separates it */
#meet-modal .meet-room-settings { margin-top: 0; border-top: 0; }
#meet-modal .meet-room-settings .switch { flex-shrink: 0; min-height: 44px; }
/* Room cards: with QR beside Share and the gear, a church's name takes up to two lines instead of being cut short */
.mh-room-title h3 { white-space: normal; overflow-wrap: break-word; line-height: 1.25; }
/* a mouse: a little smaller (no padding: the desktop's compact .btn padding would squeeze the icon) */
@media (pointer: fine) { .mh-room-tools .btn.btn-icon { width: 36px; min-width: 36px; min-height: 36px; padding: 0; } }
/* the QR dialog */
.modal.mt-qr-modal { max-width: 420px; }
.mt-qr-actions { justify-content: center; }

@media (max-width: 760px) {
  .form-row { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 640px) {
  .qr-box canvas { width: 200px; height: 200px; }
  .mt-church-tools { width: 100%; }
  .mt-church-pick, .mt-church-tools .btn { flex: 1 1 100%; max-width: none; }
  .mt-church-name { max-width: 100%; }
  .mt-church-pick .form-control { min-width: 0; max-width: none; width: 100%; }
  .mt-church-tools .btn { justify-content: center; }
  .mt-cal-skel { height: 360px; }
}
/* Touch: every button of the section and its dialogs is at least 44 px (team.css has the same rule for the console) */
@media (pointer: coarse) {
  #mh-team .btn, #meet-modal .btn-sm, #meet-qr-modal .btn-sm { min-height: 44px; }
  #mh-team .btn-icon.btn-sm, #meet-modal .btn-icon.btn-sm { width: 44px; min-width: 44px; }
}

/* ---------- Invite people by email (js/meet-invite.js, owner Dec 1 2026; docs/meet-invites.md) ----------
   A section of the schedule dialog: the people who get the meeting's link by email 30 minutes before it. Rows of
   name + email + remove; on a phone each row is a small card (name over email). The list scrolls inside the dialog
   once it is long (a CSV of 500). */
.mi { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border-light); }
.mi-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.mi-title { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: var(--fs-base); font-weight: 600; color: var(--text); }
.mi-title svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }
.mi-hint { margin: 0 0 12px; }
.mi-count {
  flex-shrink: 0; margin-top: 2px; padding: 4px 10px; border-radius: var(--radius-full);
  background: var(--bg-subtle); color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.mi-count.is-full { background: var(--warning-bg); color: var(--warning-ink); }
.mi-loading { margin: 0 0 8px; font-size: var(--fs-sm); color: var(--text-light); }
.mi-list {
  list-style: none; margin: 0; padding: 2px; display: grid; gap: 8px;
  /* a long list scrolls in its own box on larger screens; when it reaches its end the wheel or the finger goes on
     scrolling the dialog (no overscroll-behavior: contain here: that held every swipe that started on the list) */
  max-height: 320px; overflow-y: auto;
}
.mi-list:empty { display: none; }
.mi-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1.35fr) 44px; gap: 8px; align-items: center; }
.mi-num { font-size: var(--fs-xs); color: var(--text-faint); text-align: right; font-variant-numeric: tabular-nums; }
.mi-row .form-control { min-height: 44px; }
.mi-remove {
  width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border-radius: var(--radius-full);
  color: var(--text-muted); transition: color var(--dur) ease, background var(--dur) ease;
}
.mi-remove:hover { color: var(--danger); background: var(--danger-bg); }
.mi-remove:focus-visible { outline: none; box-shadow: var(--ring); }
.mi-stopped { grid-column: 2 / -1; margin-top: -4px; font-size: var(--fs-xs); color: var(--text-light); }
.mi-row.is-stopped .form-control { color: var(--text-muted); }
.mi-row.is-new { animation: mi-in 0.28s ease-out; }
@keyframes mi-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.mi-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.mi-tools .btn { min-height: 44px; }
.mi-clear { margin-left: auto; color: var(--text-muted); }
.mi-csv-hint { margin: 8px 0 0; }
.mi-note { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-subtle); font-size: var(--fs-sm); color: var(--text); animation: mi-in 0.28s ease-out; }
.mi-note p { margin: 0; }
.mi-note p + p { margin-top: 4px; }
.mi-note.is-error { background: var(--danger-bg); color: var(--danger); }
/* the dialog after a new meeting is made: its own link and who gets an email */
.mi-done-chip { background: var(--success-bg); color: var(--success); }
.mi-done-hint { margin: 8px 0 0; }
.mi-done-mail {
  display: flex; align-items: flex-start; gap: 8px; margin: 14px 0 0; padding: 12px 14px;
  border-radius: var(--radius-sm); background: var(--success-bg); color: var(--text); font-size: var(--fs-sm);
}
.mi-done-mail svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--success); margin-top: 1px; }
@media (prefers-reduced-motion: reduce) { .mi-row.is-new, .mi-note { animation: none; } }
@media (max-width: 640px) {
  /* Phones (owner, Dec 1 2026: "make sure phone can scroll able to input info on meeting schedule"):
     - ONE scroller, the sheet: the list grows with the form instead of scrolling inside it, so a swipe anywhere moves
       the whole dialog;
     - the sheet fits the part of the screen a person can see (js/meet-team.js sets --meet-vv-h / --meet-vv-top from
       visualViewport): above the on-screen keyboard and inside the browser's own bars, so the field being typed in
       can always be scrolled into sight and Schedule is never under the keyboard;
     - Cancel / Schedule stay at the bottom of the sheet, side by side, so Schedule is one tap away after 500 people. */
  #meet-modal { top: var(--meet-vv-top, 0); bottom: auto; height: var(--meet-vv-h, 100dvh); }
  /* (scroll-padding: a field the browser scrolls to while typing stops above the pinned Cancel / Schedule bar) */
  #meet-modal .modal { max-height: calc(var(--meet-vv-h, 100dvh) * 0.94); scroll-padding-bottom: 96px; }
  #meet-form .modal-actions {
    position: sticky; bottom: calc(-24px - var(--safe-bottom, 0px)); z-index: 2;
    flex-direction: row; gap: 10px; margin: 16px -20px calc(-24px - var(--safe-bottom, 0px));
    padding: 12px 20px calc(12px + var(--safe-bottom, 0px));
    background: var(--bg-card); border-top: 1px solid var(--border-light);
  }
  #meet-form .modal-actions .btn { flex: 1 1 0; width: auto; min-height: 48px; }
  .mi-list { max-height: none; overflow: visible; }
  .mi-row {
    grid-template-columns: minmax(0, 1fr) 44px; grid-template-areas: "name remove" "email remove";
    gap: 6px; padding: 8px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--bg-card);
  }
  .mi-num { display: none; }
  .mi-name { grid-area: name; }
  .mi-email { grid-area: email; }
  .mi-remove { grid-area: remove; }
  .mi-stopped { grid-column: 1 / -1; margin-top: 0; }
  .mi-clear { margin-left: 0; }
}
