/**
 * Xnprofil Toast Notifications — lesbar, persistent, modal-sicher
 */

#toast-container {
    position: fixed;
    top: max(1rem, env(safe-area-inset-top, 0px));
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translateX(-50%);
    z-index: 100050;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    width: min(440px, calc(100vw - 1.5rem));
    max-width: calc(100vw - 1.5rem);
    pointer-events: none;
    padding: 0;
    margin: 0;
}

.toast-notification {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    border-radius: 14px;
    border: 2px solid rgba(255, 255, 255, 0.18);
    background: #1a1a1e;
    color: #ffffff;
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(-14px) scale(0.98);
    transition: opacity 0.28s ease, transform 0.28s ease;
    pointer-events: none;
    overflow: hidden;
    font-family: inherit;
    -webkit-font-smoothing: antialiased;
}

.toast-notification.toast-show {
    opacity: 1 !important;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.toast-notification.toast-hide {
    opacity: 0 !important;
    transform: translateY(-10px) scale(0.98);
}

.toast-notification__body {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 1rem 1rem 0.85rem 1.05rem;
}

.toast-notification__icon {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #111;
    background: rgba(255, 255, 255, 0.95);
}

.toast-notification__content {
    flex: 1;
    min-width: 0;
    padding-top: 0.1rem;
}

.toast-notification__title {
    display: block;
    font-size: 0.98rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    line-height: 1.25;
    color: #ffffff;
    margin: 0 0 0.3rem;
}

.toast-notification__message {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.96);
    word-break: break-word;
}

.toast-notification__close {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    margin: -0.15rem -0.2rem 0 0;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: background 0.15s ease;
}

.toast-notification__close:hover,
.toast-notification__close:focus-visible {
    background: rgba(255, 255, 255, 0.28);
    outline: none;
}

.toast-notification__progress {
    display: block;
    height: 4px;
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.toast-notification__progress-bar {
    display: block;
    height: 100%;
    width: 100%;
    transform-origin: left center;
    background: rgba(255, 255, 255, 0.85);
    transform: scaleX(1);
}

.toast-notification.toast-show .toast-notification__progress-bar {
    animation-name: toast-progress;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

.toast-notification.is-paused .toast-notification__progress-bar {
    animation-play-state: paused;
}

@keyframes toast-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Typen */
.toast-notification--error {
    background: linear-gradient(165deg, #c62828 0%, #8e1b1b 100%);
    border-color: rgba(255, 205, 210, 0.45);
}

.toast-notification--error .toast-notification__icon {
    background: #fff;
    color: #c62828;
}

.toast-notification--warning {
    background: linear-gradient(165deg, #e65100 0%, #bf360c 100%);
    border-color: rgba(255, 224, 178, 0.5);
}

.toast-notification--warning .toast-notification__icon {
    background: #fff8e1;
    color: #e65100;
}

.toast-notification--success {
    background: linear-gradient(165deg, #2e7d32 0%, #1b5e20 100%);
    border-color: rgba(200, 230, 201, 0.45);
}

.toast-notification--success .toast-notification__icon {
    background: #e8f5e9;
    color: #2e7d32;
}

.toast-notification--info {
    background: linear-gradient(165deg, #1565c0 0%, #0d47a1 100%);
    border-color: rgba(187, 222, 251, 0.45);
}

.toast-notification--info .toast-notification__icon {
    background: #e3f2fd;
    color: #1565c0;
}

/* Validierung / Pflichtfelder — extra deutlich */
.toast-notification--validation {
    background: linear-gradient(165deg, #ff6f00 0%, #e65100 55%, #bf360c 100%);
    border-color: #ffe082;
    border-width: 3px;
    box-shadow:
        0 18px 52px rgba(0, 0, 0, 0.6),
        0 0 0 3px rgba(255, 193, 7, 0.35);
}

.toast-notification--validation .toast-notification__icon {
    background: #fffde7;
    color: #e65100;
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.35rem;
}

.toast-notification--validation .toast-notification__title {
    font-size: 1.08rem;
    text-transform: none;
}

.toast-notification--validation .toast-notification__message {
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.5;
}

.toast-notification.toast-pulse {
    animation: toast-attention 0.55s ease;
}

@keyframes toast-attention {
    0%, 100% { transform: translateY(0) scale(1); }
    30% { transform: translateY(0) scale(1.03); }
    55% { transform: translateY(0) scale(0.99); }
}

@media (max-width: 600px) {
    #toast-container {
        top: max(0.65rem, env(safe-area-inset-top, 0px));
        width: calc(100vw - 1rem);
    }

    .toast-notification__body {
        padding: 0.9rem 0.85rem 0.75rem;
        gap: 0.7rem;
    }

    .toast-notification__title {
        font-size: 1rem;
    }

    .toast-notification__message {
        font-size: 0.94rem;
    }

    .toast-notification--validation .toast-notification__title {
        font-size: 1.05rem;
    }

    .toast-notification--validation .toast-notification__message {
        font-size: 1rem;
    }
}
