/**
 * Toast Notification System
 * Système de notifications modernes avec animations smooth
 */

/* Container de toasts */
.toast-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    padding: 20px;
}

/* Positions */
.toast-container.top-right {
    top: 0;
    right: 0;
}

.toast-container.top-left {
    top: 0;
    left: 0;
}

.toast-container.bottom-right {
    bottom: 0;
    right: 0;
}

.toast-container.bottom-left {
    bottom: 0;
    left: 0;
}

/* Toast item */
.toast-item {
    pointer-events: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12),
                0 2px 6px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transform: translateX(calc(100% + 20px));
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    min-width: 320px;
    max-width: 420px;
    position: relative;
}

/* Animation d'entrée */
.toast-item.toast-show {
    transform: translateX(0);
    opacity: 1;
}

/* Animation de sortie */
.toast-item.toast-hide {
    transform: translateX(calc(100% + 20px));
    opacity: 0;
    transition: all 0.2s ease-in;
}

/* Pour position left */
.toast-container.top-left .toast-item,
.toast-container.bottom-left .toast-item {
    transform: translateX(calc(-100% - 20px));
}

.toast-container.top-left .toast-item.toast-show,
.toast-container.bottom-left .toast-item.toast-show {
    transform: translateX(0);
}

.toast-container.top-left .toast-item.toast-hide,
.toast-container.bottom-left .toast-item.toast-hide {
    transform: translateX(calc(-100% - 20px));
}

/* Contenu du toast */
.toast-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    position: relative;
}

/* Icône */
.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
}

/* Message */
.toast-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    color: #2d3748;
    font-weight: 500;
    padding-top: 2px;
}

/* Bouton de fermeture */
.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #718096;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 18px;
    margin-left: 8px;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #2d3748;
}

/* Barre de progression */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    width: 100%;
    transform-origin: left;
    border-radius: 0 0 12px 12px;
}

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

/* Types de toasts */

/* Success */
.toast-success {
    border-left: 4px solid #10b981;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-success .toast-progress {
    background: #10b981;
}

/* Error */
.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-error .toast-progress {
    background: #ef4444;
}

/* Warning */
.toast-warning {
    border-left: 4px solid #f59e0b;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-warning .toast-progress {
    background: #f59e0b;
}

/* Info */
.toast-info {
    border-left: 4px solid #3b82f6;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

.toast-info .toast-progress {
    background: #3b82f6;
}

/* Hover effect */
.toast-item:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16),
                0 4px 8px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px) translateX(0);
}

.toast-item:hover .toast-progress {
    animation-play-state: paused !important;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .toast-item {
        background: #1e293b;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4),
                    0 2px 6px rgba(0, 0, 0, 0.3);
    }

    .toast-message {
        color: #e2e8f0;
    }

    .toast-close {
        color: #94a3b8;
    }

    .toast-close:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #e2e8f0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .toast-container {
        max-width: 100%;
        left: 0;
        right: 0;
        padding: 12px;
    }

    .toast-item {
        min-width: auto;
        max-width: 100%;
    }

    /* Sur mobile, toujours venir du haut */
    .toast-container.top-right,
    .toast-container.top-left,
    .toast-container.bottom-right,
    .toast-container.bottom-left {
        top: 0;
        left: 0;
        right: 0;
    }

    .toast-item {
        transform: translateY(-100%);
    }

    .toast-item.toast-show {
        transform: translateY(0);
    }

    .toast-item.toast-hide {
        transform: translateY(-100%);
    }
}

/* Animation de "bounce" subtile à l'entrée */
@keyframes toast-bounce-in {
    0% {
        transform: translateX(calc(100% + 20px));
        opacity: 0;
    }
    60% {
        transform: translateX(-10px);
        opacity: 1;
    }
    80% {
        transform: translateX(5px);
    }
    100% {
        transform: translateX(0);
    }
}

/* Variante avec bounce pour les toasts success */
.toast-success.toast-show {
    animation: toast-bounce-in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Support des icônes personnalisées (emojis, etc.) */
.toast-icon img,
.toast-icon svg {
    width: 24px;
    height: 24px;
}

/* Toast avec actions (boutons) */
.toast-actions {
    display: flex;
    gap: 8px;
    padding: 0 16px 12px 52px;
}

.toast-action-btn {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.toast-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.toast-action-btn.primary {
    background: #3b82f6;
    color: white;
}

.toast-action-btn.primary:hover {
    background: #2563eb;
}
