/* ══════════════════════════════════════════════════════════════════════════
   Gestionchantiers UI — fenêtres superposées (voir CLAUDE.md § Conventions UI)
   .ui-sheet  : choix / actions  → panneau du bas (mobile), boîte centrée (PC)
   .ui-form   : formulaires      → plein écran qui monte du bas (mobile), panneau droit (PC)
   .ui-dialog : confirmations    → boîte centrée
   Ouverture / fermeture : window.UI (public/js/batix-ui.js)
   ══════════════════════════════════════════════════════════════════════════ */

/* L'attribut hidden l'emporte toujours (sinon écrasé par .flex / .grid de Tailwind) */
[hidden] { display: none !important; }

.ui-overlay {
  position: fixed; inset: 0; z-index: 70;
  visibility: hidden; pointer-events: none;
  /* la visibilité bascule après l'animation de fermeture */
  transition: visibility 0s linear .32s;
}
.ui-overlay.is-open { visibility: visible; pointer-events: auto; transition-delay: 0s; }

.ui-backdrop {
  position: absolute; inset: 0;
  background: rgba(30, 34, 48, .45);
  opacity: 0; transition: opacity .3s ease;
}
.ui-overlay.is-open > .ui-backdrop { opacity: 1; }

.ui-panel {
  position: absolute; display: flex; flex-direction: column;
  background: #fff; outline: none;
  transition: transform .32s cubic-bezier(.32, .72, 0, 1), opacity .2s ease;
}

/* Bouton fermer (✕) commun : 44px */
.ui-close {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 9999px;
  display: grid; place-items: center;
  background: #F4F5F8; color: #646B7D; transition: background .15s, transform .15s;
}
.ui-close:active { transform: scale(.94); background: #ECEDF2; }
.ui-close svg { width: 20px; height: 20px; }

/* ── Choix / actions ─────────────────────────────────────────────────────── */
.ui-sheet .ui-panel {
  left: 0; right: 0; bottom: 0; max-height: 88dvh;
  border-radius: 24px 24px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(100%);
}
.ui-sheet.is-open .ui-panel { transform: translateY(0); }
.ui-sheet.is-dragging .ui-panel { transition: none; }

.ui-handle { width: 40px; height: 5px; border-radius: 99px; background: #DDE0E7; margin: 10px auto 2px; }

@media (min-width: 1024px) {
  .ui-sheet .ui-panel {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: 440px; max-height: 80vh; border-radius: 20px; padding-bottom: 0;
    transform: translate(-50%, -46%); opacity: 0;
    box-shadow: 0 24px 60px -12px rgba(30, 34, 48, .3);
  }
  .ui-sheet.is-open .ui-panel { transform: translate(-50%, -50%); opacity: 1; }
  .ui-sheet .ui-handle { display: none; }
}

/* ── Formulaires ─────────────────────────────────────────────────────────── */
.ui-form .ui-panel {
  left: 0; right: 0; top: 0; height: 100dvh;
  transform: translateY(100%);
}
.ui-form.is-open .ui-panel { transform: translateY(0); }

@media (min-width: 1024px) {
  .ui-form .ui-panel {
    left: auto; width: 480px; height: 100%;
    transform: translateX(100%);
    box-shadow: -12px 0 40px rgba(30, 34, 48, .15);
  }
  .ui-form.is-open .ui-panel { transform: translateX(0); }
}

/* ── Confirmations ───────────────────────────────────────────────────────── */
.ui-dialog .ui-panel {
  left: 50%; top: 50%; width: min(400px, calc(100% - 32px));
  border-radius: 20px; opacity: 0;
  transform: translate(-50%, -50%) scale(.95);
  box-shadow: 0 24px 60px -12px rgba(30, 34, 48, .35);
}
.ui-dialog.is-open .ui-panel { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ── Option d'une liste de choix (tri, filtre…) : .is-selected = choisie ── */
.ui-option {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 14px;
  display: flex; align-items: center; gap: 12px; text-align: left;
  font-size: 15px; font-weight: 600; color: #1E2230; transition: background .15s;
}
.ui-option:active { background: #F7F8FB; }
.ui-option > svg:first-child { width: 18px; height: 18px; flex-shrink: 0; color: #9AA0B0; }
.ui-option.is-selected { background: #F0ECFE; color: #7C5CFC; }
.ui-option.is-selected > svg:first-child { color: #7C5CFC; }
.ui-option-check { display: none; margin-left: auto; width: 18px; height: 18px; flex-shrink: 0; }
.ui-option.is-selected .ui-option-check { display: block; }
/* Variante formulaire : <label class="ui-option"><input type="radio|checkbox" class="sr-only">…</label> */
label.ui-option { cursor: pointer; }
.ui-option:has(> input:checked) { background: #F0ECFE; color: #7C5CFC; }
.ui-option:has(> input:checked) .ui-option-check { display: block; }
.ui-option:has(> input:focus-visible) { box-shadow: 0 0 0 2px #7C5CFC; }

/* Pastilles de couleur (radio) : <label class="ui-swatch"><input type="radio" class="sr-only"><span class="bg-…"><svg/></span></label> */
.ui-swatch { display: grid; place-items: center; cursor: pointer; }
.ui-swatch > span { width: 44px; height: 44px; border-radius: 9999px; display: grid; place-items: center; transition: box-shadow .15s; }
.ui-swatch svg { display: none; width: 20px; height: 20px; color: #fff; }
.ui-swatch input:checked + span { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #1E2230; }
.ui-swatch input:checked + span svg { display: block; }
.ui-swatch input:focus-visible + span { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #7C5CFC; }

/* Interrupteur : <label class="ui-switch"><input type="checkbox" class="sr-only"><span></span></label> */
.ui-switch { position: relative; display: inline-flex; flex-shrink: 0; cursor: pointer; }
.ui-switch > span { width: 44px; height: 26px; border-radius: 99px; background: #DDE0E7; transition: background .2s; position: relative; }
.ui-switch > span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 99px; background: #fff; box-shadow: 0 1px 3px rgba(30,34,48,.2); transition: transform .2s; }
.ui-switch input:checked + span { background: #7C5CFC; }
.ui-switch input:checked + span::after { transform: translateX(18px); }
.ui-switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(124,92,252,.3); }

/* ── Champs de formulaire communs ────────────────────────────────────────── */
.ui-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: #9AA0B0; margin-bottom: 12px;
}
.ui-label { display: block; font-size: 13px; font-weight: 600; color: #4B5263; margin-bottom: 6px; }
.ui-label .ui-optional { font-weight: 400; color: #9AA0B0; margin-left: 4px; }
.ui-input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid #E2E4EA; border-radius: 12px; background: #fff;
  font-size: 15px; color: #1E2230; transition: border-color .15s, box-shadow .15s;
}
textarea.ui-input { min-height: 88px; resize: none; }
.ui-input:focus { outline: none; border-color: #7C5CFC; box-shadow: 0 0 0 3px rgba(124, 92, 252, .12); }
.ui-input:disabled { opacity: .45; }
/* Champs date / heure natifs (iOS Safari, et flatpickr en mobile qui crée un input type=date) :
   iOS leur impose une largeur minimale et ignore width:100% → débordement à droite dans une grille à 2 colonnes */
input[type="date"], input[type="time"], input[type="datetime-local"], input.flatpickr-mobile {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; min-width: 0; max-width: 100%;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value,
input.flatpickr-mobile::-webkit-date-and-time-value { text-align: left; }

/* ── Boutons de pied de fenêtre ──────────────────────────────────────────── */
.ui-btn {
  height: 48px; padding: 0 18px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 700; transition: background .15s, transform .15s, opacity .15s;
}
.ui-btn:active { transform: scale(.98); }
.ui-btn:disabled { opacity: .6; }
.ui-btn-secondary { background: #fff; border: 1px solid #E2E4EA; color: #4B5263; }
.ui-btn-secondary:active { background: #F7F8FB; }
.ui-btn-primary { background: #7C5CFC; color: #fff; box-shadow: 0 6px 16px -6px rgba(124, 92, 252, .6); }
.ui-btn-primary:active { background: #6645F0; }
.ui-btn-danger { background: #E5547B; color: #fff; box-shadow: 0 6px 16px -6px rgba(229, 84, 123, .55); }
.ui-btn-danger:active { background: #D23F67; }

/* ── Prix confidentiels ──────────────────────────────────────────────────────
   <x-ui.prix> : montant masqué (••••) par défaut, à chaque chargement de page.
   UI.togglePrix() bascule la classe .prix-visibles sur <html> ; bouton : .btn-toggle-prix + <x-ui.oeil-prix>. */
.ui-prix { display: none; }
.ui-prix-masque { opacity: .5; letter-spacing: .08em; }
.prix-visibles .ui-prix { display: inline; }
.prix-visibles .ui-prix-masque { display: none; }
.btn-toggle-prix .ui-oeil-on { display: none; }
.prix-visibles .btn-toggle-prix .ui-oeil-on { display: block; }
.prix-visibles .btn-toggle-prix .ui-oeil-off { display: none; }

