/* =================================================================
   TOAST COMPONENT - ENHANCED STYLES v2.0
   ================================================================= */

/* Variables CSS */
:root {
    --toast-success: #10b981;
    --toast-error: #ef4444;
    --toast-warning: #f59e0b;
    --toast-info: #3b82f6;
    --toast-loading: #6366f1;

    --toast-success-light: #d1fae5;
    --toast-error-light: #fee2e2;
    --toast-warning-light: #fef3c7;
    --toast-info-light: #dbeafe;

    --toast-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1),
        0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --toast-shadow-hover: 0 20px 35px -8px rgba(0, 0, 0, 0.15),
        0 12px 15px -8px rgba(0, 0, 0, 0.12);
}

/* Contenedor Principal */
.toast-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    max-width: 420px;
    width: 100%;
}

/* Posiciones */
.toast-top-right {
    top: 0;
    right: 0;
}

.toast-top-left {
    top: 0;
    left: 0;
}

.toast-bottom-right {
    bottom: 0;
    right: 0;
}

.toast-bottom-left {
    bottom: 0;
    left: 0;
}

.toast-top-center {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.toast-bottom-center {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Toast Base */
.toast {
    pointer-events: auto;
    background: white;
    border-radius: 12px;
    box-shadow: var(--toast-shadow);
    overflow: hidden;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    position: relative;
    will-change: transform, opacity;
    backface-visibility: hidden;
}

.toast-wrapper {
    position: relative;
    width: 100%;
}

/* Contenido */
.toast-content {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    gap: 12px;
}

/* Icono */
.toast-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: 10px;
    position: relative;
}

.toast-icon::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    opacity: 0.15;
    background: currentColor;
}

/* Avatar */
.toast-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
}

.toast-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Body */
.toast-body {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

.toast-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.4;
    margin-bottom: 4px;
    color: #111827;
    letter-spacing: -0.01em;
}

.toast-message {
    font-size: 14px;
    line-height: 1.5;
    color: #6b7280;
    word-wrap: break-word;
}

/* Botón Cerrar */
.toast-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.toast-close::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 6px;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.2s;
}

.toast-close:hover::before {
    opacity: 0.1;
}

.toast-close:hover {
    color: #4b5563;
    transform: scale(1.1);
}

.toast-close:active {
    transform: scale(0.95);
}

/* Acciones */
.toast-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.toast-action-btn {
    padding: 6px 12px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #374151;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.toast-action-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    transform: translateY(-1px);
}

.toast-action-btn:active {
    transform: translateY(0);
}

/* Barra de Progreso */
.toast-progress {
    height: 3px;
    background: rgba(0, 0, 0, 0.08);
    overflow: hidden;
    position: relative;
}

.toast-progress-bar {
    height: 100%;
    width: 100%;
    background: currentColor;
    transition: width linear;
    border-radius: 3px;
}

/* Tipos de Toast */
.toast-success {
    border-left: 4px solid var(--toast-success);
}

.toast-success .toast-icon {
    color: var(--toast-success);
}

.toast-error {
    border-left: 4px solid var(--toast-error);
}

.toast-error .toast-icon {
    color: var(--toast-error);
}

.toast-warning {
    border-left: 4px solid var(--toast-warning);
}

.toast-warning .toast-icon {
    color: var(--toast-warning);
}

.toast-info {
    border-left: 4px solid var(--toast-info);
}

.toast-info .toast-icon {
    color: var(--toast-info);
}

.toast-loading {
    border-left: 4px solid var(--toast-loading);
}

.toast-loading .toast-icon {
    color: var(--toast-loading);
}

/* Temas */
.toast-theme-colored.toast-success {
    background: linear-gradient(135deg, var(--toast-success) 0%, #059669 100%);
    border-left: none;
}

.toast-theme-colored.toast-success .toast-title,
.toast-theme-colored.toast-success .toast-message,
.toast-theme-colored.toast-success .toast-close {
    color: white;
}

.toast-theme-colored.toast-success .toast-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.toast-theme-colored.toast-error {
    background: linear-gradient(135deg, var(--toast-error) 0%, #dc2626 100%);
    border-left: none;
}

.toast-theme-colored.toast-error .toast-title,
.toast-theme-colored.toast-error .toast-message,
.toast-theme-colored.toast-error .toast-close {
    color: white;
}

.toast-theme-colored.toast-error .toast-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.toast-theme-colored.toast-warning {
    background: linear-gradient(135deg, var(--toast-warning) 0%, #d97706 100%);
    border-left: none;
}

.toast-theme-colored.toast-warning .toast-title,
.toast-theme-colored.toast-warning .toast-message,
.toast-theme-colored.toast-warning .toast-close {
    color: white;
}

.toast-theme-colored.toast-warning .toast-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.toast-theme-colored.toast-info {
    background: linear-gradient(135deg, var(--toast-info) 0%, #2563eb 100%);
    border-left: none;
}

.toast-theme-colored.toast-info .toast-title,
.toast-theme-colored.toast-info .toast-message,
.toast-theme-colored.toast-info .toast-close {
    color: white;
}

.toast-theme-colored.toast-info .toast-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Tema Dark */
.toast-theme-dark {
    background: #1f2937;
}

.toast-theme-dark .toast-title {
    color: #f9fafb;
}

.toast-theme-dark .toast-message {
    color: #d1d5db;
}

.toast-theme-dark .toast-close {
    color: #9ca3af;
}

.toast-theme-dark .toast-action-btn {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

/* ================================================================
   ANIMACIONES
   ================================================================ */

/* Slide + Fade Animation */
.toast-animation-slidefade {
    opacity: 0;
    transform: translateX(400px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-animation-slidefade.toast-enter {
    animation: slideInFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-animation-slidefade.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast-animation-slidefade.toast-exit {
    animation: slideOutFadeOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes slideInFadeIn {
    0% {
        opacity: 0;
        transform: translateX(400px) scale(0.8);
    }

    50% {
        transform: translateX(-10px) scale(1.02);
    }

    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes slideOutFadeOut {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateX(100px) scale(0.9);
    }
}

/* Para posiciones izquierdas */
.toast-top-left .toast-animation-slidefade,
.toast-bottom-left .toast-animation-slidefade {
    transform: translateX(-400px);
}

.toast-top-left .toast-animation-slidefade.toast-enter,
.toast-bottom-left .toast-animation-slidefade.toast-enter {
    animation: slideInFadeInLeft 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-top-left .toast-animation-slidefade.toast-exit,
.toast-bottom-left .toast-animation-slidefade.toast-exit {
    animation: slideOutFadeOutLeft 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes slideInFadeInLeft {
    0% {
        opacity: 0;
        transform: translateX(-400px) scale(0.8);
    }

    50% {
        transform: translateX(10px) scale(1.02);
    }

    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes slideOutFadeOutLeft {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateX(-100px) scale(0.9);
    }
}

/* Bounce Animation */
.toast-animation-bounce {
    opacity: 0;
    transform: translateY(-200px);
}

.toast-animation-bounce.toast-enter {
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.toast-animation-bounce.toast-show {
    opacity: 1;
    transform: translateY(0);
}

.toast-animation-bounce.toast-exit {
    animation: bounceOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: translateY(-200px) scale(0.3);
    }

    50% {
        transform: translateY(10px) scale(1.05);
    }

    70% {
        transform: translateY(-5px);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes bounceOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0.3) translateY(-50px);
    }
}

/* Zoom Animation */
.toast-animation-zoom {
    opacity: 0;
    transform: scale(0);
}

.toast-animation-zoom.toast-enter {
    animation: zoomIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-animation-zoom.toast-show {
    opacity: 1;
    transform: scale(1);
}

.toast-animation-zoom.toast-exit {
    animation: zoomOut 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes zoomIn {
    0% {
        opacity: 0;
        transform: scale(0);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes zoomOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0.3);
    }
}

/* Flip Animation */
.toast-animation-flip {
    opacity: 0;
    transform: perspective(600px) rotateY(90deg);
}

.toast-animation-flip.toast-enter {
    animation: flipIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-animation-flip.toast-show {
    opacity: 1;
    transform: perspective(600px) rotateY(0);
}

.toast-animation-flip.toast-exit {
    animation: flipOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes flipIn {
    0% {
        opacity: 0;
        transform: perspective(600px) rotateY(90deg);
    }

    100% {
        opacity: 1;
        transform: perspective(600px) rotateY(0);
    }
}

@keyframes flipOut {
    0% {
        opacity: 1;
        transform: perspective(600px) rotateY(0);
    }

    100% {
        opacity: 0;
        transform: perspective(600px) rotateY(-90deg);
    }
}

/* Toast Updating Animation */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }
}

.toast-updating {
    animation: pulse 0.3s ease-in-out;
}

/* Hover Effect */
.toast:hover {
    box-shadow: var(--toast-shadow-hover);
    transform: translateY(-2px);
}

.toast-clickable {
    cursor: pointer;
    user-select: none;
}

.toast-clickable:active {
    transform: scale(0.98);
}

/* Icono giratorio para loading */
.fa-spin {
    animation: fa-spin 1s infinite linear;
}

@keyframes fa-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 640px) {
    .toast-container {
        max-width: 100%;
        padding: 12px;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
    }

    .toast {
        margin: 0;
        border-radius: 8px;
    }

    .toast-content {
        padding: 14px;
        gap: 10px;
    }

    .toast-icon,
    .toast-avatar {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .toast-title {
        font-size: 14px;
    }

    .toast-message {
        font-size: 13px;
    }

    .toast-close {
        width: 24px;
        height: 24px;
    }
}

/* Accesibilidad */
@media (prefers-reduced-motion: reduce) {

    .toast,
    .toast-progress-bar,
    .toast-close,
    .toast-action-btn {
        transition: none !important;
        animation: none !important;
    }

    .toast-animation-slidefade,
    .toast-animation-bounce,
    .toast-animation-zoom,
    .toast-animation-flip {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Print */
@media print {
    .toast-container {
        display: none !important;
    }
}