/* ==========================================================================
   ALTAIDE — MODALS / SHEETS
   Load AFTER tokens.css and base.css. Replaces assets/css/modals.css.

   Two shapes, both full-bleed:
     .modal-content            bottom sheet, height follows content (max 92vh)
     .modal-content.sheet-full full screen — use for forms and any required step
   Class names are unchanged, so existing markup keeps working.
   ========================================================================== */

/* --- Overlay ------------------------------------------------------------
   Darker than before (0.55 vs 0.6 blurred slate) and, crucially, no
   padding: the sheet reaches the screen edges instead of sitting in a
   16px frame at 96% width. */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;   /* sheets rise from the bottom */
  justify-content: center;
  padding: 0;
  background: rgba(16, 24, 40, 0.55);
  opacity: 1;
  transition: opacity var(--transition-slow);
}

.modal-overlay.hidden {
  display: none !important;
  opacity: 0;
}

/* --- Sheet --------------------------------------------------------------- */

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  background: var(--surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: sheetUp var(--transition-slow) forwards;
}

/* Required steps and long forms: no dismissible-dialog signals at all. */
.modal-content.sheet-full {
  height: 100%;
  max-height: none;
  border-radius: 0;
  animation: sheetFade var(--transition) forwards;
}

@keyframes sheetUp {
  from { transform: translateY(6%); opacity: 0; }
  to   { transform: translateY(0);  opacity: 1; }
}

@keyframes sheetFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* --- Header -------------------------------------------------------------
   Left-aligned, same scale as a page title, with room for the close
   control on the right. Optional sub-line: .modal-header p. */

.modal-header {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5) var(--page-gutter) var(--space-4);
  padding-right: calc(var(--page-gutter) + var(--tap-min));
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-titles);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-title);
  color: var(--text-strong);
}

.modal-header p {
  margin: 0;
  font-size: var(--text-base);
  color: var(--text-muted);
  text-wrap: pretty;
}

/* A grab handle instead of a header, for short confirmations. */
.modal-content .sheet-handle {
  flex-shrink: 0;
  width: 40px;
  height: 4px;
  margin: var(--space-3) auto 0;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
}

/* --- Body ---------------------------------------------------------------- */

.modal-body {
  flex-grow: 1;
  padding: var(--space-5) var(--page-gutter);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- Footer -------------------------------------------------------------
   White, not grey — the grey read as a second surface. Vertical stack:
   the primary action is full width and the secondary sits under it,
   so a two-word label never has to wrap into two lines. */

.modal-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--page-gutter)
           calc(var(--space-4) + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* Side-by-side only where both labels are one short word. */
.modal-footer.is-inline {
  flex-direction: row;
  align-items: center;
}

/* --- Close --------------------------------------------------------------- */

.modal-close-icon {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 2;
  width: var(--tap-min);
  height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-chip);
  color: var(--text-main);
  cursor: pointer;
  transition: background var(--transition);
}

.modal-close-icon:hover { background: var(--surface-sunken); }

/* --- Explanation carousel (unchanged behaviour) -------------------------- */

#explication-slides-wrapper {
  position: relative;
  width: 100%;
  min-height: 250px;
  overflow: hidden;
}

#explication-slides-inner {
  display: flex;
  width: 100%;
  transition: transform var(--transition-slow);
  will-change: transform;
}

.expl-slide {
  flex: 0 0 100%;
  width: 100%;
  padding: 0 var(--page-gutter);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* --- Caregiver detail sheet --------------------------------------------- */

.detail-card {
  max-width: 720px;
  padding: 0;
  overflow: hidden;
}

.cg-detail-header {
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  padding: var(--space-6) var(--page-gutter) var(--space-5);
  text-align: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.cg-detail-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
}

.cg-detail-identity h2 {
  margin: var(--space-3) 0 var(--space-1);
  font-size: var(--text-xl);
}

.cg-detail-meta {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.cg-detail-body {
  flex-grow: 1;
  padding: var(--space-5) var(--page-gutter);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.detail-section { margin-bottom: var(--space-6); }

.detail-section h4 {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: var(--space-2);
}

.cg-bio-text {
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-main);
}

.detail-footer {
  flex-shrink: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--page-gutter)
           calc(var(--space-4) + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin: 0;
}

.price-big {
  font-family: var(--font-titles);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

/* --- PWA install prompt (same shape as every other sheet) --------------- */

#pwa-install-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

#pwa-install-modal.hidden { display: none; }

.pwa-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.55);
}

.pwa-modal-content {
  position: relative;
  width: 100%;
  max-width: 720px;
  padding: var(--space-6) var(--page-gutter)
           calc(var(--space-5) + var(--safe-bottom));
  background: var(--surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: var(--shadow-md);
  text-align: left;
  animation: sheetUp var(--transition-slow) forwards;
}

.pwa-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.pwa-modal-content h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
  color: var(--text-strong);
}

.pwa-modal-content p {
  margin: 0 0 var(--space-5);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-muted);
}

.pwa-modal-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* --- FICHE AIDANT ------------------------------------------------------ */
.cg-sheet-head {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--surface-sunken);
}
.cg-sheet-photo {
  width: 64px; height: 64px; flex-shrink: 0;
  border-radius: 20px; object-fit: cover;
  background: var(--surface-sunken);
  cursor: pointer;
}
.cg-sheet-ident { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; padding-top: 2px; }
.cg-sheet-name {
  margin: 0;
  font-family: var(--font-titles);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--text-strong);
}
.cg-sheet-place {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.cg-sheet-place .icon { flex-shrink: 0; }
.cg-sheet-close {
  width: 36px; height: 36px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  color: var(--text-main);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.cg-sheet-close:hover { border-color: var(--border-strong); color: var(--text-strong); }

.cg-sheet-body { display: flex; flex-direction: column; gap: 22px; }
.cg-block { display: flex; flex-direction: column; gap: 9px; }
.cg-block-label {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.cg-bio { margin: 0; font-size: var(--text-base); line-height: 1.6; color: var(--text-main); text-wrap: pretty; }

/* Correspondance avec la demande */
.cg-match {
  display: flex; flex-direction: column; gap: 11px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--color-success-soft);
  border: 1px solid color-mix(in oklch, var(--color-success) 28%, #fff);
}
.cg-match.is-partial {
  background: var(--color-warning-soft);
  border-color: color-mix(in oklch, var(--color-warning) 28%, #fff);
}
.cg-match-head {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-titles);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-success);
}
.cg-match.is-partial .cg-match-head { color: var(--color-warning); }

.cg-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.cg-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-main);
}
.cg-chip .icon { font-size: 1rem; flex-shrink: 0; }
.cg-chip.is-ok {
  background: var(--surface);
  border-color: color-mix(in oklch, var(--color-success) 28%, #fff);
  color: var(--color-success);
  font-weight: var(--weight-semibold);
}
.cg-chip.is-missing {
  background: transparent;
  border-style: dashed;
  color: var(--text-muted);
  text-decoration: line-through;
}
.cg-chip.is-like { background: var(--color-accent-soft); border-color: var(--color-accent-border); color: var(--color-accent-ink); }

/* Pied : un montant, une action */
.cg-sheet-foot { display: flex; align-items: center; gap: var(--space-3); padding: 14px 20px 22px; }
.cg-price { display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.cg-price-line { display: flex; align-items: baseline; gap: 5px; }
.cg-price-total {
  font-family: var(--font-titles);
  font-size: var(--text-display);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--text-strong);
}
.cg-price-cycle { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-muted); }
.cg-price-detail { font-size: var(--text-sm); color: var(--text-muted); }
.cg-action { flex: 1; }
.cg-action .contact-btn { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.cg-action .status-badge {
  width: 100%; min-height: 52px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 16px;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
}.modal-footer.cg-sheet-foot {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  padding: 14px 20px 22px;
}
.cg-sheet-foot .cg-price { flex: 0 0 auto; }
.cg-sheet-foot .cg-action { flex: 1 1 auto; min-width: 0; }