/* GROUP-booking (28 Oct 2026, Claude): "Reserva em grupo" dialogs and the gold "Grupo" tag. The dialogs reuse the Reserva
   recorrente shell and its -rd1 design (recurring.css: rec-dialog / rec-card / rec-head / rec-form / rec-section / rec-grid /
   rec-seg / rec-pill / rec-series / rec-facts / rec-mini); this file only adds what is new: the line editors, the shortcuts bar,
   the preview rows with their price field, and the group line rows. Same Madalena tokens (--rm-*), no inline styles (CSP). */

/* Tag (Reservas rows, Calendário bars, Limpeza, the list): the compact gold .status-badge of "Recorrente". */
body.rm-admin .rec-tag.is-group { background: var(--rm-accent-soft); color: #8a6420; }
body.rm-admin .calendar-stay .rec-tag.is-group { background: rgba(255, 255, 255, .85); }

/* Dialog width: the group dialogs hold a list of reservations (~860 px on desktop; the phone card keeps its 18 px gutters). */
body.rm-admin dialog.rec-dialog.grp-dialog { width: min(860px, calc(100vw - 36px)); }
body.rm-admin .grp-dialog [hidden] { display: none !important; }
body.rm-admin .grp-form fieldset:disabled { opacity: .7; }

/* Reservas: one card per line editor = the .lock-detail-panel block of the preview (line border, body tone, .5rem). */
body.rm-admin .grp-count { color: var(--rm-text); font-weight: 600; }
body.rm-admin .grp-lines { display: flex; flex-direction: column; gap: 10px; }
body.rm-admin .grp-line { min-width: 0; padding: 10px 14px 14px; border: 1px solid var(--rm-line); border-radius: .5rem; background: var(--rm-body); }
body.rm-admin .grp-line-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
body.rm-admin .grp-line-head strong { color: var(--rm-primary); font-size: 12.5px; font-weight: 700; }
body.rm-admin .grp-line-tools { display: inline-flex; align-items: center; gap: 4px; }
body.rm-admin .grp-line-tools .rec-link .ri { font-size: 14px; }
body.rm-admin .grp-line .grp-remove { width: 30px; height: 30px; }
/* Desktop: one row of four fields (Apartamento, Tipo, Entrada, Saída; FORMS-no-guests removed Adultos/Crianças); a fixed apartment takes the Tipo cell. */
body.rm-admin .grp-line-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.05fr) minmax(0, 1.15fr) minmax(0, 1.15fr); }
body.rm-admin .grp-line.is-fixed .grp-f-unit { grid-column: span 2; }
body.rm-admin .grp-line-grid > label { min-width: 0; }
/* Date fields: the browser's intrinsic date width must not push the field out of its half-width cell on phones. */
body.rm-admin .rec-form .grp-line input[type="date"] { min-width: 0; max-width: 100%; }
body.rm-admin .grp-mode-label { display: block; margin: 10px 0 5px; color: var(--rm-text); font-size: 12px; font-weight: 600; letter-spacing: .1px; }
body.rm-admin .grp-mode { margin-top: 0; }
body.rm-admin .grp-other { margin-top: 10px; }
body.rm-admin .grp-line .rec-form input, body.rm-admin .grp-line input, body.rm-admin .grp-line select { background-color: var(--rm-paper); }

/* Shortcuts bar under the lines. */
body.rm-admin .grp-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
body.rm-admin .grp-tools .button { height: 36px; min-height: 36px; padding: 0 12px; font-size: 12.5px; box-shadow: none; }
body.rm-admin .grp-bulk { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
body.rm-admin .rec-form .grp-bulk input { width: 64px; height: 36px; min-height: 36px; padding: 0 8px; text-align: center; }
body.rm-admin .rec-form .grp-bulk select { width: 138px; height: 36px; min-height: 36px; padding: 0 8px; }

/* Preview rows: nº | unit, dates, guest | price field; a refused row = the danger tone with its reason and "Usar sugestão". */
body.rm-admin .grp-preview { padding: 12px 15px; border: 1px solid var(--rm-line); border-radius: .5rem; background: var(--rm-body); }
body.rm-admin .grp-preview.is-stale { opacity: 1; filter: none; }
body.rm-admin .grp-preview.is-stale .rec-pv-head, body.rm-admin .grp-preview.is-stale .grp-main, body.rm-admin .grp-preview.is-stale .grp-pv-reason { opacity: .45; }
body.rm-admin .grp-pv-error { margin-top: 10px; }
body.rm-admin .grp-pv-list { margin: 8px 0 0; padding: 0; list-style: none; }
body.rm-admin .grp-pv-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 132px; grid-template-areas: "no main price" "no reason reason"; align-items: center; gap: 0 10px;
  padding: 8px 0; border-top: 1px solid var(--rm-line); color: var(--rm-heading); font-size: 12px; }
body.rm-admin .grp-pv-row .grp-no { grid-area: no; }
body.rm-admin .grp-pv-row .grp-main { grid-area: main; }
body.rm-admin .grp-pv-price { grid-area: price; }
body.rm-admin .rec-form .grp-pv-price > span { margin-bottom: 2px; font-size: 10.5px; text-align: right; }
body.rm-admin .rec-form .grp-pv-price input { height: 36px; min-height: 36px; padding: 0 8px; color: var(--rm-primary); font-weight: 650; text-align: right; }
body.rm-admin .grp-pv-reason { grid-area: reason; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 6px 0 0; color: #b23836; font-size: 12px; line-height: 1.4; }
body.rm-admin .grp-pv-reason b { color: #96661d; font-weight: 650; }
body.rm-admin .grp-pv-row.is-off .grp-main b { color: #b23836; }
body.rm-admin .grp-pv-row.is-off .grp-no { background: var(--rm-danger-soft); color: #b23836; }

/* Shared row pieces (preview and list). */
body.rm-admin .grp-no { display: inline-flex; align-items: center; justify-content: center; align-self: start; width: 24px; height: 24px; margin-top: 2px; border-radius: 99px;
  background: var(--rm-primary-soft); color: var(--rm-primary); font-size: 11px; font-weight: 700; }
body.rm-admin .grp-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
body.rm-admin .grp-main b { color: var(--rm-primary); font-weight: 650; }
/* Unit codes never break at the hyphen (RM-12 stays on one line). */
body.rm-admin .grp-code { white-space: nowrap; }
body.rm-admin .grp-pv-row.is-off .grp-main b.is-auto { color: var(--rm-primary); }
body.rm-admin .grp-main small { color: var(--rm-text); font-size: 11px; font-weight: 500; overflow-wrap: anywhere; }
body.rm-admin .grp-manual { display: inline-flex; align-items: center; min-height: 16px; margin-left: 4px; padding: 0 6px; border-radius: 99px; background: var(--rm-warning-soft);
  color: #96661d; font-size: 9.5px; font-style: normal; font-weight: 650; letter-spacing: .02em; text-transform: uppercase; vertical-align: middle; }

/* List: group cards = the rec-series card; line rows = nº | unit, dates, guest | state pills | total | actions. */
body.rm-admin .grp-head-pills { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
body.rm-admin .grp-reason { margin: 8px 0 0; }
body.rm-admin .grp-rows { margin: 0; padding: 0; list-style: none; }
body.rm-admin .grp-row { display: grid; grid-template-columns: 26px minmax(0, 1.5fr) minmax(0, 1.2fr) 130px 150px; grid-template-areas: "no main state total acts"; align-items: center; gap: 0 10px;
  min-height: 44px; padding: 6px 0; border-top: 1px dashed var(--rm-line); color: var(--rm-heading); font-size: 12px; }
body.rm-admin .grp-row .grp-no { grid-area: no; }
body.rm-admin .grp-row .grp-main { grid-area: main; }
body.rm-admin .grp-state { grid-area: state; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }
body.rm-admin .grp-total { grid-area: total; text-align: right; color: var(--rm-primary); font-size: 12.5px; font-weight: 650; white-space: nowrap; }
body.rm-admin .grp-acts { grid-area: acts; display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; min-width: 0; }
body.rm-admin .grp-acts:empty { display: none; }
body.rm-admin .grp-actions .button { height: 36px; min-height: 36px; padding: 0 12px; font-size: 12.5px; box-shadow: none; }
body.rm-admin .grp-card > .rec-error { margin-top: 10px; }
/* "Grupos" shows a create in progress: the gold dot of "Recorrentes" (recurring.css #recurring-open.rec-busy). */
body.rm-admin #group-open.rec-busy { position: relative; }
body.rm-admin #group-open.rec-busy::after { content: ""; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--rm-accent);
  box-shadow: 0 0 0 2px var(--rm-paper); animation: rec-pulse 1.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { body.rm-admin #group-open.rec-busy::after { animation: none; } }
body.rm-admin .grp-copy-area { position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Phones: the centred card (recurring.css); line editors in two columns, shortcuts full width, rows stacked. */
@media (max-width: 780px) {
  body.rm-admin .grp-line { padding: 8px 10px 12px; }
  body.rm-admin .rec-grid.grp-line-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  body.rm-admin .grp-line.is-fixed .grp-f-unit { grid-column: 1 / -1; }
  body.rm-admin .grp-line .rec-seg label > span { padding: 7px 8px; }
  body.rm-admin .rec-form .grp-line input[type="date"] { padding: 0 6px 0 10px; }
  body.rm-admin .rec-form .grp-line input[type="date"]::-webkit-calendar-picker-indicator { margin-left: 2px; }
  body.rm-admin .grp-tools .button { flex: 1 1 auto; justify-content: center; }
  body.rm-admin .grp-bulk { flex: 1 1 100%; margin-left: 0; }
  body.rm-admin .rec-form .grp-bulk select { flex: 1 1 auto; width: auto; min-width: 0; }
  body.rm-admin .grp-bulk .button { flex: 1 1 100%; }
  body.rm-admin .grp-bulk { flex-wrap: wrap; }
  body.rm-admin .grp-preview { padding: 10px 12px; }
  body.rm-admin .grp-pv-row { grid-template-columns: 26px minmax(0, 1fr) 108px; }
  body.rm-admin .grp-main { flex-direction: column; align-items: flex-start; }
  body.rm-admin .grp-row { grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-areas: "no main total" ". state acts"; row-gap: 6px; padding: 8px 0; }
  body.rm-admin .grp-acts { justify-content: flex-end; }
  body.rm-admin .grp-actions .button { flex: 1 1 auto; justify-content: center; }
  body.rm-admin .grp-card .rec-series-head { flex-wrap: wrap; row-gap: 6px; }
  body.rm-admin .grp-head-pills { flex: 1 1 100%; justify-content: flex-start; padding-left: 40px; }
  body.rm-admin .grp-row .grp-total { grid-area: total; }
  /* 44 px touch targets for the group-only controls (the recurring UI keeps its sizes). Small icon buttons get an invisible hit
     area around them; text buttons and fields grow to 44 px. */
  body.rm-admin .grp-dialog .grp-remove, body.rm-admin .grp-dialog .rec-toggle { position: relative; z-index: 1; } /* the hit area paints above the next siblings */
  body.rm-admin .grp-dialog .grp-remove::before, body.rm-admin .grp-dialog .rec-toggle::before { content: ""; position: absolute; top: -8px; right: -8px; bottom: -8px; left: -8px; } /* 30 px + 2 x 8 px from the padding box = 44 px+ */
  body.rm-admin .grp-dialog .grp-dup { min-height: 44px; }
  body.rm-admin .grp-dialog .rec-mini { min-height: 44px; }
  body.rm-admin .grp-dialog .grp-tools .button, body.rm-admin .grp-dialog .grp-actions .button { height: 44px; min-height: 44px; }
  body.rm-admin .rec-form .grp-bulk input, body.rm-admin .rec-form .grp-bulk select, body.rm-admin .rec-form .grp-pv-price input { height: 44px; min-height: 44px; }
}

/* FORMS-toolbar (owner, 28 Oct 2026): Reservas header = icon buttons Grupos / Recorrentes / Fallback (name in aria-label +
   title, Fallback count as a badge) and "Nova reserva" with its label on the right, all the same height, one row at every width. */
body.rm-admin [data-page="reservations"] > .page-intro { flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: flex-end; gap: 8px; }
body.rm-admin [data-page="reservations"] > .page-intro > .button { flex: 0 0 auto; width: auto; height: 40px; min-height: 40px; }
body.rm-admin [data-page="reservations"] > .page-intro > .button.rm-tool-icon { position: relative; width: 40px; min-width: 40px; padding: 0; gap: 0; }
body.rm-admin [data-page="reservations"] > .page-intro > .rm-tool-icon > .ri { margin: 0; font-size: 18px; line-height: 1; }
body.rm-admin .rm-tool-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--rm-primary, #193452);
  color: #fff; font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--rm-paper, #fff); pointer-events: none; }
@media (max-width: 780px) {
  body.rm-admin [data-page="reservations"] > .page-intro > .button { height: 44px; min-height: 44px; }
  body.rm-admin [data-page="reservations"] > .page-intro > .button.rm-tool-icon { width: 44px; min-width: 44px; }
  body.rm-admin [data-page="reservations"] > .page-intro > #new-direct-booking { flex: 1 1 auto; min-width: 0; }
}
