/* ============================================================================
   KAYFASIL — Toasts & Dialogues unifiés (toast.css)
   À charger sur TOUTES les pages via base.html et les pages autonomes.

   Les toasts produits par toast.js utilisent exactement les mêmes classes
   (.flash, .flash-container, .flash-{type}) que celles définies dans
   legacy.css, de façon à garantir un rendu strictement identique sur toutes
   les pages — qu'elles incluent legacy.css ou non.

   Variables requises (définies dans legacy.css) :
     --green-deep, --green-light
     --ease
     --radius-sm  (fallback 10px)
   ============================================================================ */

/* ── Fallbacks pour les pages autonomes sans legacy.css ── */
:root {
  --kf-ease:       cubic-bezier(0.22, 1, 0.36, 1);
  --kf-radius-sm:  10px;
  --kf-radius-lg:  16px;
  --kf-shadow-md:  0 4px 20px rgba(0, 0, 0, 0.12);
  --kf-transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ══════════════════════════════════════════════════════════════════════
   CONTENEUR DE TOASTS
   Identique au .flash-container de legacy.css
   ══════════════════════════════════════════════════════════════════════ */

.flash-container {
  position: fixed;
  top: 80px;
  right: 1.5rem;
  z-index: 9999;           /* priorité maximale, au-dessus de tout */
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;    /* le container lui-même ne capte pas les clics */
}

/* ══════════════════════════════════════════════════════════════════════
   TOAST (.flash)
   Structure identique à base.html :
     <div class="flash flash-{type}">
       <span>…</span>
       <button class="flash-close"><i class="fas fa-times"></i></button>
     </div>
   ══════════════════════════════════════════════════════════════════════ */

.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-sm, var(--kf-radius-sm));
  min-width: 260px;
  max-width: 380px;
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: var(--kf-shadow-md);
  pointer-events: auto;    /* les toasts eux-mêmes restent cliquables */
  animation: slideIn 0.3s var(--ease, var(--kf-ease));
}

/* Sortie */
.flash.hiding {
  animation: slideOut 0.35s var(--ease, var(--kf-ease)) forwards;
  pointer-events: none;
}

/* ── Animations (entrée depuis la droite — identique legacy.css) ── */
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

/* ── Variantes de couleur — identiques à legacy.css ── */

.flash-success {
  background: var(--green-light, #e6f0ee);
  color: var(--green-deep, #1c3d35);
  border: 1px solid rgba(42, 92, 84, 0.2);
}

.flash-error,
.flash-danger {
  background: #fdecea;
  color: #9b1c1c;
  border: 1px solid rgba(155, 28, 28, 0.2);
}

.flash-warning {
  background: #fff8e6;
  color: #92400e;
  border: 1px solid rgba(146, 64, 14, 0.2);
}

.flash-info {
  background: #e8f4fd;
  color: #1e40af;
  border: 1px solid rgba(30, 64, 175, 0.2);
}

/* ── Bouton fermeture ── */
.flash-close {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  font-size: 0.9rem;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
  font-family: inherit;
}
.flash-close:hover { opacity: 1; }


/* ══════════════════════════════════════════════════════════════════════
   OVERLAY DIALOGUE (kfAlert / kfConfirm)
   ══════════════════════════════════════════════════════════════════════ */

.kf-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 18, 0.25);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s;
}
.kf-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── Dialogue ── */
.kf-dialog {
  background: #fff;
  border-radius: var(--radius, var(--kf-radius-lg));
  box-shadow: 0 8px 32px rgba(10, 20, 18, 0.14);
  width: 100%;
  max-width: 320px;
  overflow: hidden;
  transform: scale(0.96) translateY(6px);
  transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.kf-overlay.active .kf-dialog {
  transform: scale(1) translateY(0);
}

.kf-dialog__body    { padding: 1.4rem 1.4rem 0.9rem; }
.kf-dialog__title   {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 0.975rem;
  font-weight: 700;
  color: var(--text-dark, #1a1a1a);
  margin-bottom: 0.4rem;
  line-height: 1.3;
}
.kf-dialog__message {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 0.84rem;
  color: var(--text-mid, #555);
  line-height: 1.55;
}

.kf-dialog__actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.9rem 1.4rem 1.3rem;
}
.kf-dialog__actions--single              { justify-content: flex-end; }
.kf-dialog__actions--single .kf-btn      { min-width: 90px; }

/* ── Boutons dialogue ── */
.kf-dialog__actions .kf-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm, var(--kf-radius-sm));
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: var(--transition, var(--kf-transition));
}

.kf-btn--primary       { background: var(--green-mid, #2A5C54); color: #fff; border-color: var(--green-mid, #2A5C54); }
.kf-btn--primary:hover { background: var(--green-deep, #1c3d35); border-color: var(--green-deep, #1c3d35); }

.kf-btn--danger        { background: #9b1c1c; color: #fff; border-color: #9b1c1c; }
.kf-btn--danger:hover  { background: #7b1414; border-color: #7b1414; }

.kf-btn--ghost         { background: transparent; color: var(--text-mid, #555); border-color: var(--border-light, #ede9e2); }
.kf-btn--ghost:hover   { border-color: var(--green-mid, #2A5C54); color: var(--green-mid, #2A5C54); }


/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  .flash-container {
    right: 1rem;
    left: 1rem;
  }
  .flash {
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }
  .kf-dialog { max-width: calc(100% - 2rem); }
}