/**
 * Стили для универсального компонента toast-уведомлений
 */

/* Контейнер для toast-уведомлений */
.toast-container {
    position: fixed !important;
    top: 80px !important; /* Отступ от навбара */
    right: 20px !important;
    z-index: 99999 !important; /* Увеличено для гарантии видимости */
    display: flex !important;
    flex-direction: column;
    gap: 16px;
    max-width: 420px;
    width: auto; /* Изменено с 100% на auto для правильного позиционирования */
    pointer-events: none; /* Позволяет кликать сквозь контейнер, но не сквозь сами toast */
    visibility: visible !important;
    opacity: 1 !important;
}

/* Отдельный toast */
.toast {
    position: relative;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 2px 6px rgba(0, 0, 0, 0.04);
    padding: 18px 20px;
    display: flex !important; /* Важно: гарантировать видимость */
    align-items: flex-start;
    gap: 14px;
    min-width: 320px;
    max-width: 420px;
    pointer-events: auto; /* Разрешаем кликать на сам toast */
    border-left: 4px solid;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease-out, box-shadow 0.3s ease;
    visibility: visible !important; /* Важно: гарантировать видимость */
    backdrop-filter: blur(10px);
}

/* Начальное состояние для анимации появления */
.toast.toast-entering {
    opacity: 0;
    transform: translateX(120%);
    display: flex !important; /* Важно: гарантировать видимость даже в начальном состоянии */
    visibility: visible !important;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease-out;
}

/* Финальное состояние после анимации появления */
.toast.toast-entered {
    opacity: 1;
    transform: translateX(0);
    display: flex !important; /* Важно: гарантировать видимость */
    visibility: visible !important;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease-out;
}

.toast.toast-entered:hover {
    box-shadow: 
        0 12px 32px rgba(0, 0, 0, 0.15),
        0 6px 16px rgba(0, 0, 0, 0.1),
        0 3px 8px rgba(0, 0, 0, 0.06);
    transform: translateX(0) translateY(-2px);
}

.toast.hiding {
    opacity: 0;
    transform: translateX(120%);
    display: flex !important; /* Важно: сохранить display даже при скрытии */
    visibility: visible !important;
    /* Используем transition вместо animation для более плавной работы */
    transition: transform 0.4s cubic-bezier(0.4, 0, 1, 1), opacity 0.4s ease-out;
}

/* Анимации появления и исчезновения */
@keyframes toastSlideIn {
    from {
        transform: translateX(120%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

/* Типы toast */
.toast-success {
    border-left-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(255, 255, 255, 0.95) 30%, var(--white) 100%);
}

.toast-success::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.toast-danger {
    border-left-color: #ef4444;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(255, 255, 255, 0.95) 30%, var(--white) 100%);
}

.toast-danger::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 10% 20%, rgba(239, 68, 68, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.toast-warning {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(255, 255, 255, 0.95) 30%, var(--white) 100%);
}

.toast-warning::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 10% 20%, rgba(245, 158, 11, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.toast-info {
    border-left-color: #3b82f6;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(255, 255, 255, 0.95) 30%, var(--white) 100%);
}

.toast-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

/* Иконка toast */
.toast-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 50%;
    margin-top: 0;
    position: relative;
    z-index: 1;
    animation: iconPulse 0.6s ease-out;
}

@keyframes iconPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.toast-success .toast-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.toast-danger .toast-icon {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.toast-warning .toast-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.toast-info .toast-icon {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Содержимое toast */
.toast-content {
    flex: 1;
    min-width: 0; /* Позволяет тексту переноситься */
    position: relative;
    z-index: 1;
}

.toast-title {
    font-weight: 700;
    font-size: 15px;
    color: #1f2937;
    margin-bottom: 6px;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.toast-message {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.6;
    word-wrap: break-word;
    font-weight: 400;
}

/* Кнопка закрытия */
.toast-close {
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.03);
    border: none;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
    border-radius: 50%;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 0;
    margin-right: -2px;
    position: relative;
    z-index: 1;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #374151;
    transform: rotate(90deg);
}

.toast-close:active {
    transform: rotate(90deg) scale(0.92);
}

/* Прогресс-бар для автоматического закрытия */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: currentColor;
    opacity: 0.4;
    border-radius: 0 0 12px 12px;
    transition: width linear;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
}

.toast-success .toast-progress {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.toast-danger .toast-progress {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.toast-warning .toast-progress {
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.toast-info .toast-progress {
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
}

/* Адаптивность */
@media (max-width: 768px) {
    .toast-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* Когда открыта модалка, показывать toast поверх неё */
.modal-overlay.active ~ .toast-container {
    z-index: 10000;
}

