:root {
  --flash-success-bg: #ecfdf5;
  --flash-success-text: #065f46;
  --flash-success-border: #10b981;

  --flash-error-bg: #fef2f2;
  --flash-error-text: #991b1b;
  --flash-error-border: #ef4444;

  --flash-warning-bg: #fffbeb;
  --flash-warning-text: #92400e;
  --flash-warning-border: #f59e0b;

  --flash-info-bg: #eff6ff;
  --flash-info-text: #1e40af;
  --flash-info-border: #3b82f6;
}

.flash-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  max-width: 90%;
  min-width: 250px;
}

.flash-container.bottom-right {
  top: auto;
  bottom: 20px;
  right: 20px;
}

.flash {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  border-left: 5px solid;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  font-family: sans-serif;
  position: relative; /* Indispensable pour la barre en absolute */
  overflow: hidden; /* Pour que la barre ne dépasse pas des arrondis */
  animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  text-align: left;
}

.flash.hide {
  animation: slideOut 0.4s ease-in forwards;
}

/* --- Barre de progression --- */

.flash-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.1); /* Fond discret */
  transform-origin: left;
}

/* On réutilise les couleurs de bordure pour la barre */
.flash.success .flash-progress {
  background-color: var(--flash-success-border);
}
.flash.error .flash-progress {
  background-color: var(--flash-error-border);
}
.flash.warning .flash-progress {
  background-color: var(--flash-warning-border);
}
.flash.info .flash-progress {
  background-color: var(--flash-info-border);
}

@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(110%);
    opacity: 0;
  }
}

@keyframes shrink {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.flash.success {
  background-color: var(--flash-success-bg);
  color: var(--flash-success-text);
  border-color: var(--flash-success-border);
}

.flash.error {
  background-color: var(--flash-error-bg);
  color: var(--flash-error-text);
  border-color: var(--flash-error-border);
}

.flash.warning {
  background-color: var(--flash-warning-bg);
  color: var(--flash-warning-text);
  border-color: var(--flash-warning-border);
}

.flash.info {
  background-color: var(--flash-info-bg);
  color: var(--flash-info-text);
  border-color: var(--flash-info-border);
}

.flash-message {
  flex-grow: 1;
  font-size: 0.95rem;
  line-height: 1.4;
}

.flash-close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.5;
  padding-left: 10px;
  color: inherit;
}

.flash-close:hover {
  opacity: 1;
}
