/*
 * Styles centralises des popups FacControl.
 *
 * Le but est de remplacer les alertes navigateur par un rendu plus propre
 * sans toucher aux messages metier ni aux conditions qui les declenchent.
 */

:root {
  --fc-popup-bg: #ffffff;
  --fc-popup-text: #0f172a;
  --fc-popup-muted: #475569;
  --fc-popup-shadow: 0 28px 60px rgba(15, 23, 42, 0.2);
  --fc-popup-overlay: rgba(15, 23, 42, 0.48);
  --fc-popup-radius: 24px;
  --fc-popup-success: #15803d;
  --fc-popup-success-soft: #dcfce7;
  --fc-popup-error: #b91c1c;
  --fc-popup-error-soft: #fee2e2;
  --fc-popup-warning: #b45309;
  --fc-popup-warning-soft: #fef3c7;
  --fc-popup-info: #1d4ed8;
  --fc-popup-info-soft: #dbeafe;
}

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

@keyframes faccontrolPopupSlideUp {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.faccontrol-swal-popup {
  border-radius: var(--fc-popup-radius) !important;
  padding: 1.8rem 1.6rem 1.4rem !important;
  box-shadow: var(--fc-popup-shadow) !important;
  border: 1px solid rgba(148, 163, 184, 0.18) !important;
}

.faccontrol-swal-title {
  color: var(--fc-popup-text) !important;
  font-size: 1.45rem !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
}

.faccontrol-swal-html {
  color: var(--fc-popup-muted) !important;
  font-size: 0.98rem !important;
  line-height: 1.65 !important;
}

/* Suppression du centrage global des popups pour retour au comportement d’origine */

.faccontrol-swal-confirm,
.faccontrol-swal-cancel {
  border: 0 !important;
  border-radius: 999px !important;
  font-weight: 600 !important;
  padding: 0.82rem 1.5rem !important;
  min-width: 120px !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease !important;
}

.faccontrol-swal-confirm:hover,
.faccontrol-swal-cancel:hover {
  transform: translateY(-1px);
}

.faccontrol-swal-confirm {
  background: linear-gradient(135deg, #0f766e, #0f9b8e) !important;
  color: #ffffff !important;
  box-shadow: 0 16px 30px rgba(15, 118, 110, 0.28) !important;
}

.faccontrol-swal-cancel {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

.faccontrol-swal-input,
.faccontrol-popup-input {
  width: 100%;
  border-radius: 16px !important;
  border: 1px solid rgba(148, 163, 184, 0.35) !important;
  padding: 0.9rem 1rem !important;
  color: var(--fc-popup-text) !important;
  background: #f8fafc !important;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04) !important;
}

.faccontrol-swal-input:focus,
.faccontrol-popup-input:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.55) !important;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14) !important;
}

/*
 * Ajustement ultra cible du popup de motif d'annulation.
 *
 * On reduit volontairement le champ et on le centre dans le popup,
 * sans impacter les autres popups du projet.
 */
.swal2-popup.faccontrol-popup-annulation-motif .swal2-input.faccontrol-popup-annulation-motif-input,
.faccontrol-popup-shell.faccontrol-popup-annulation-motif .faccontrol-popup-input.faccontrol-popup-annulation-motif-input {
  width: min(58%, 320px) !important;
  max-width: 320px !important;
  margin: 0.7rem auto 0.35rem !important;
  display: block !important;
  box-sizing: border-box !important;
}

/*
 * Ciblage direct du champ "Saisir le motif".
 *
 * Cette regle est volontairement plus specifique pour garantir que
 * l'input du motif d'annulation reste bien centre dans le popup.
 *
 * Le centrage horizontal repose ici sur :
 * - display: block ;
 * - margin: auto ;
 * afin que le champ soit recentre par son conteneur, et pas seulement
 * redimensionne en largeur.
 */
.swal2-popup.faccontrol-popup-annulation-motif input.swal2-input.faccontrol-popup-annulation-motif-input[placeholder="Saisir le motif"],
.faccontrol-popup-shell.faccontrol-popup-annulation-motif input.faccontrol-popup-input.faccontrol-popup-annulation-motif-input[placeholder="Saisir le motif"] {
  width: min(82%, 260px) !important;
  max-width: 260px !important;
  min-width: 0 !important;
  margin: 15px auto !important;
  display: block !important;
  box-sizing: border-box !important;
  text-align: center !important;
  align-self: center !important;
  justify-self: center !important;
}

.faccontrol-popup-root {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
}

.faccontrol-popup-root.is-open {
  display: block;
}

.faccontrol-popup-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(15, 118, 110, 0.12), transparent 38%),
    var(--fc-popup-overlay);
  backdrop-filter: blur(6px);
  animation: faccontrolPopupFadeIn 0.2s ease;
}

.faccontrol-popup-shell {
  position: relative;
  width: min(440px, calc(100vw - 32px));
  margin: min(10vh, 72px) auto 0;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), #ffffff);
  color: var(--fc-popup-text);
  border-radius: var(--fc-popup-radius);
  box-shadow: var(--fc-popup-shadow);
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 1.5rem;
  animation: faccontrolPopupSlideUp 0.22s ease;
}

.faccontrol-popup-shell::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 6px;
  border-radius: 24px 24px 0 0;
  background: linear-gradient(90deg, var(--fc-popup-accent, var(--fc-popup-info)), rgba(15, 118, 110, 0.82));
}

.faccontrol-popup-close {
  position: absolute;
  top: 0.95rem;
  right: 0.95rem;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(226, 232, 240, 0.85);
  color: var(--fc-popup-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.faccontrol-popup-close:hover {
  background: rgba(203, 213, 225, 0.95);
  color: var(--fc-popup-text);
  transform: rotate(8deg);
}

.faccontrol-popup-icon {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

.faccontrol-popup-icon--success {
  background: var(--fc-popup-success-soft);
  color: var(--fc-popup-success);
}

.faccontrol-popup-icon--error {
  background: var(--fc-popup-error-soft);
  color: var(--fc-popup-error);
}

.faccontrol-popup-icon--warning {
  background: var(--fc-popup-warning-soft);
  color: var(--fc-popup-warning);
}

.faccontrol-popup-icon--info {
  background: var(--fc-popup-info-soft);
  color: var(--fc-popup-info);
}

.faccontrol-popup-title {
  margin: 0 2.5rem 0.55rem 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--fc-popup-text);
}

.faccontrol-popup-message {
  margin: 0;
  color: var(--fc-popup-muted);
  font-size: 0.98rem;
  line-height: 1.7;
  white-space: pre-line;
}

.faccontrol-popup-input-wrap {
  margin-top: 1rem;
  display: none;
}

.faccontrol-popup-actions {
  margin-top: 1.45rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.faccontrol-popup-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.82rem 1.45rem;
  min-width: 120px;
  font-weight: 600;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.faccontrol-popup-btn:hover {
  transform: translateY(-1px);
}

.faccontrol-popup-btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, #0f766e, #0f9b8e);
  box-shadow: 0 16px 30px rgba(15, 118, 110, 0.28);
}

.faccontrol-popup-btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

/*
 * Harmonisation des messages inline deja presents dans les templates.
 *
 * On garde le HTML existant et on centralise seulement le rendu visuel
 * afin d'eviter des affichages disparates selon les ecrans.
 */
.alert {
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-left: 6px solid currentColor;
  border-radius: 18px;
  padding: 1rem 1.1rem;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
  background: #ffffff;
  color: var(--fc-popup-text);
}

.alert-success {
  color: var(--fc-popup-success);
  background: linear-gradient(180deg, #f4fdf6, var(--fc-popup-success-soft));
}

.alert-danger,
.alert-error {
  color: var(--fc-popup-error);
  background: linear-gradient(180deg, #fff5f5, var(--fc-popup-error-soft));
}

.alert-warning {
  color: var(--fc-popup-warning);
  background: linear-gradient(180deg, #fffaf0, var(--fc-popup-warning-soft));
}

.alert-info {
  color: var(--fc-popup-info);
  background: linear-gradient(180deg, #f4f8ff, var(--fc-popup-info-soft));
}

.alert-secondary {
  color: #475569;
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
}

.alert a {
  color: inherit;
  font-weight: 600;
}

@media (max-width: 575.98px) {
  .swal2-popup.faccontrol-popup-annulation-motif .swal2-input.faccontrol-popup-annulation-motif-input,
  .faccontrol-popup-shell.faccontrol-popup-annulation-motif .faccontrol-popup-input.faccontrol-popup-annulation-motif-input {
    width: min(82%, 260px) !important;
    max-width: 260px !important;
  }

  .swal2-popup.faccontrol-popup-annulation-motif input.swal2-input.faccontrol-popup-annulation-motif-input[placeholder="Saisir le motif"],
  .faccontrol-popup-shell.faccontrol-popup-annulation-motif input.faccontrol-popup-input.faccontrol-popup-annulation-motif-input[placeholder="Saisir le motif"] {
    width: min(82%, 260px) !important;
    max-width: 260px !important;
    margin: 15px auto !important;
  }

  .faccontrol-popup-shell {
    margin-top: 6vh;
    padding: 1.2rem;
    border-radius: 20px;
  }

  .faccontrol-popup-actions {
    flex-direction: column-reverse;
  }

  .faccontrol-popup-btn,
  .faccontrol-swal-confirm,
  .faccontrol-swal-cancel {
    width: 100%;
  }
}
