/* flash-messages.css - Modernes Design mit Auto-Dismiss */

.flash-messages {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1050;
  max-width: 350px;
  width: 100%;
}

.flash-message {
  position: relative;
  padding: 16px 20px;
  margin-bottom: 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  /* Laenger sichtbar (8 statt 5 Sekunden) und deutlich weicher aus- als
     einblenden: das Wegblitzen war der Hauptkritikpunkt. Die weiche Kurve
     laesst die Meldung gleiten statt zu springen. */
  animation:
    slideIn 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    fadeOut 1.1s cubic-bezier(0.4, 0, 0.2, 1) 7.9s forwards;
  opacity: 0.95;
  backdrop-filter: blur(5px);
  transform-origin: top right;
  overflow: hidden;
}

.flash-message::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 5px;
}

.flash-message .close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 18px;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  transition: opacity 0.2s;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.flash-message .close:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.1);
}

.flash-message .icon {
  margin-right: 12px;
  display: inline-block;
  vertical-align: middle;
}

.flash-message .content {
  display: flex;
  align-items: flex-start;
}

.flash-message .message-text {
  flex-grow: 1;
  padding-right: 20px;
}

.flash-message .title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 16px;
}

.flash-message .description {
  opacity: 0.9;
  font-size: 14px;
}

/* Success message */
.flash-message.success {
  background-color: rgba(240, 255, 240, 0.95);
  color: #155724;
  border-left: none;
}

.flash-message.success::before {
  background-color: #28a745;
}

/* Error message */
.flash-message.error {
  background-color: rgba(255, 240, 240, 0.95);
  color: #721c24;
  border-left: none;
}

.flash-message.error::before {
  background-color: #dc3545;
  /* Breiter als bei den uebrigen Arten: ein Fehlschlag soll sich schon am
     Rand vom Erfolg unterscheiden lassen, nicht erst beim Lesen. */
  width: 8px;
}

.flash-message.error {
  border: 1px solid rgba(220, 53, 69, 0.35);
}

.flash-message.error .description {
  font-weight: 500;
}

/* Warning message */
.flash-message.warning {
  background-color: rgba(255, 250, 230, 0.95);
  color: #856404;
  border-left: none;
}

.flash-message.warning::before {
  background-color: #ffc107;
}

/* Info message */
.flash-message.info {
  background-color: rgba(240, 249, 255, 0.95);
  color: #0c5460;
  border-left: none;
}

.flash-message.info::before {
  background-color: #17a2b8;
}

/* Progress bar for auto-dismiss */
.flash-message .progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: rgba(255, 255, 255, 0.3);
}

.flash-message .progress-bar {
  height: 100%;
  width: 100%;
  transform-origin: left;
  animation: progress 9s linear;
}

.flash-message.success .progress-bar {
  background-color: #28a745;
}

.flash-message.error .progress-bar {
  background-color: #dc3545;
}

.flash-message.warning .progress-bar {
  background-color: #ffc107;
}

.flash-message.info .progress-bar {
  background-color: #17a2b8;
}

/* Animations */
@keyframes slideIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0); opacity: 0.97; }
}

/* Gleitet seitlich weg und schrumpft dabei die eigene Hoehe, damit die
   darunterliegenden Meldungen sanft nachruecken statt zu springen. */
@keyframes fadeOut {
  0%   { transform: translateX(0); opacity: 0.97; max-height: 220px; margin-bottom: 10px; }
  55%  { transform: translateX(0); opacity: 0; max-height: 220px; margin-bottom: 10px; }
  100% { transform: translateX(40%); opacity: 0; max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; }
}

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

/* Responsive adjustments */
@media (max-width: 576px) {
  .flash-messages {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

/* Wer die Maus darauf haelt, will lesen - dann bleibt sie stehen. Das ist
   schon in Javascript geloest; hier nur der weiche Uebergang beim Schliessen
   von Hand. */
.flash-message {
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Nutzer, die Bewegung reduzieren moechten, bekommen keine Gleitanimation */
@media (prefers-reduced-motion: reduce) {
  .flash-message {
    animation: none;
    opacity: 0.97;
  }
  .flash-message .progress-bar {
    animation: none;
  }
}
