.alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation: overlay-fade-in 0.4s ease-out forwards;
}

.alert-overlay.active {
    display: flex;
    opacity: 1;
}

.alert-overlay.closing {
    animation: overlay-fade-out 0.3s ease-in forwards;
}

.alert-card {
    background: var(--color-white);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.7) translateY(30px) rotateX(15deg);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-top: 4px solid var(--color-primary);
    perspective: 1000px;
    transform-style: preserve-3d;
    animation: card-entrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.alert-overlay.active .alert-card {
    transform: scale(1) translateY(0) rotateX(0deg);
}

.alert-overlay.closing .alert-card {
    animation: card-exit 0.3s ease-in forwards;
}

.alert-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Estilos para transiciones entre estados */
.alert-card.transitioning {
    transition: all 0.4s ease-in-out;
}

.alert-card.transitioning .alert-icon {
    transition: transform 0.3s ease-in-out;
}


/* Loading específico */
.alert-card.loading {
    border-top-color: var(--color-primary);
}

.alert-card.loading .alert-icon {
    color: var(--color-primary);
    /* Animación aplicada en sección de animaciones */
}

.alert-card.loading .alert-title {
    color: var(--color-primary);
}

/* Success con efecto de celebración */
.alert-card.success {
    border-top-color: var(--color-success);
    position: relative;
    overflow: hidden;
}

.alert-card.success::before {
    content: '✨';
    position: absolute;
    top: -10px;
    left: -10px;
    font-size: 1.5rem;
    opacity: 0;
    animation: sparkle 2s ease-out 0.8s;
}

.alert-card.success::after {
    content: '🎉';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 1.5rem;
    opacity: 0;
    animation: sparkle 2s ease-out 1.2s;
}

@keyframes sparkle {
    0% {
        opacity: 0;
        transform: translateY(20px) rotate(0deg) scale(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-10px) rotate(180deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px) rotate(360deg) scale(0);
    }
}

.alert-card.success .alert-icon {
    color: var(--color-success);
    /* Animación aplicada en sección de animaciones */
}

.alert-card.success .alert-title {
    color: var(--color-success);
}

/* Warning específico */
.alert-card.warning {
    border-top-color: var(--color-warning);
}

.alert-card.warning .alert-icon {
    color: var(--color-warning);
    /* Animación aplicada en sección de animaciones */
}

.alert-card.warning .alert-title {
    color: var(--color-warning);
}

/* Error específico */
.alert-card.error {
    border-top-color: var(--color-error);
}

.alert-card.error .alert-icon {
    color: var(--color-error);
    /* Animación aplicada en sección de animaciones */
}

.alert-card.error .alert-title {
    color: var(--color-error);
}

/* Confirm específico */
.alert-card.confirm {
    border-top-color: var(--color-primary);
    max-width: 450px;
}

.alert-card.confirm .alert-icon {
    color: var(--color-primary);
}

.alert-card.confirm .alert-title {
    color: var(--color-primary);
}

.confirm-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.confirm-btn {
    padding: 0.85rem 1.75rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1.3rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-width: 130px;
    position: relative;
    overflow: hidden;
    transform: translateY(10px);
    opacity: 0;
    animation: button-slide-up 0.4s ease-out 0.5s both;
    text-align: center;
    line-height: 1.4;
}

.confirm-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.confirm-btn:hover::before {
    left: 100%;
}

.confirm-btn:nth-child(2) {
    animation-delay: 0.6s;
}

@keyframes button-slide-up {
    0% {
        transform: translateY(10px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.confirm-btn.cancel {
    background: var(--color-surface-2);
    color: var(--color-gray-dark);
}

.confirm-btn.accept {
    background: var(--color-primary);
    color: var(--color-white);
}

/* Mejorar alineación del contenido de los botones */
.confirm-btn i {
    font-size: 1rem;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.confirm-btn span,
.confirm-btn .btn-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.confirm-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

.confirm-btn:active {
    transform: translateY(-1px) scale(1.02);
    transition: all 0.1s ease;
}

/* ===============================
           ANIMACIONES PERSONALIZADAS
           =============================== */

/* Animaciones de overlay */
@keyframes overlay-fade-in {
    0% {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    100% {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

@keyframes overlay-fade-out {
    0% {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
    100% {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
}

/* Animaciones de entrada de la tarjeta */
@keyframes card-entrance {
    0% {
        transform: scale(0.7) translateY(30px) rotateX(15deg);
        opacity: 0;
        filter: blur(5px);
    }
    50% {
        transform: scale(1.05) translateY(-5px) rotateX(5deg);
        opacity: 0.8;
        filter: blur(1px);
    }
    100% {
        transform: scale(1) translateY(0) rotateX(0deg);
        opacity: 1;
        filter: blur(0px);
    }
}

/* Animaciones de salida de la tarjeta */
@keyframes card-exit {
    0% {
        transform: scale(1) translateY(0) rotateX(0deg);
        opacity: 1;
        filter: blur(0px);
    }
    100% {
        transform: scale(0.8) translateY(20px) rotateX(-10deg);
        opacity: 0;
        filter: blur(3px);
    }
}

/* Animación de rebote suave para el icono */
@keyframes icon-bounce-in {
    0% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(90deg);
        opacity: 0.7;
    }
    80% {
        transform: scale(0.9) rotate(10deg);
        opacity: 0.9;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Animación de pulsación para títulos */
@keyframes title-slide-in {
    0% {
        transform: translateX(-20px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Animación de deslizamiento para mensajes */
@keyframes message-slide-up {
    0% {
        transform: translateY(10px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Loading Spinner Animation Mejorado */
@keyframes alert-spin {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.1);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

@keyframes alert-spin-pulse {
    0%, 100% {
        transform: rotate(0deg) scale(1);
        opacity: 1;
        filter: drop-shadow(0 0 10px rgba(37, 99, 235, 0.5));
    }
    50% {
        transform: rotate(180deg) scale(1.15);
        opacity: 0.8;
        filter: drop-shadow(0 0 20px rgba(37, 99, 235, 0.8));
    }
}

/* Success Checkmark Animation Mejorado */
@keyframes alert-success-pop {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
        filter: drop-shadow(0 0 0 rgba(40, 167, 69, 0));
    }
    30% {
        transform: scale(1.3) rotate(-15deg);
        opacity: 0.7;
        filter: drop-shadow(0 0 15px rgba(40, 167, 69, 0.6));
    }
    60% {
        transform: scale(0.9) rotate(5deg);
        opacity: 0.9;
        filter: drop-shadow(0 0 25px rgba(40, 167, 69, 0.8));
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
        filter: drop-shadow(0 0 20px rgba(40, 167, 69, 0.6));
    }
}

@keyframes alert-success-bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0) scale(1);
    }
    40%, 43% {
        transform: translate3d(0, -12px, 0) scale(1.1);
    }
    70% {
        transform: translate3d(0, -6px, 0) scale(1.05);
    }
    90% {
        transform: translate3d(0, -3px, 0) scale(1.02);
    }
}

@keyframes success-glow {
    0%, 100% {
        filter: drop-shadow(0 0 15px rgba(40, 167, 69, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 30px rgba(40, 167, 69, 0.8));
    }
}

/* Warning Pulse Animation Mejorado */
@keyframes alert-warning-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: drop-shadow(0 0 0 rgba(255, 193, 7, 0.7));
    }
    50% {
        transform: scale(1.15);
        opacity: 0.8;
        filter: drop-shadow(0 0 20px rgba(255, 193, 7, 0.8));
    }
    100% {
        transform: scale(1);
        opacity: 1;
        filter: drop-shadow(0 0 0 rgba(255, 193, 7, 0.7));
    }
}

@keyframes alert-warning-shake {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-3px) rotate(-1deg);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(3px) rotate(1deg);
    }
}

@keyframes warning-glow {
    0%, 100% {
        filter: drop-shadow(0 0 10px rgba(255, 193, 7, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 25px rgba(255, 193, 7, 0.8));
    }
}

/* Error Animations Mejorado */
@keyframes alert-error-shake {
    0%, 100% {
        transform: translateX(0) scale(1);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-8px) scale(1.05);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(8px) scale(1.05);
    }
}

@keyframes alert-error-flash {
    0%, 50%, 100% {
        opacity: 1;
        filter: drop-shadow(0 0 5px rgba(220, 53, 69, 0.8));
    }
    25%, 75% {
        opacity: 0.7;
        filter: drop-shadow(0 0 15px rgba(220, 53, 69, 1));
    }
}

@keyframes error-glow {
    0%, 100% {
        filter: drop-shadow(0 0 15px rgba(220, 53, 69, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 30px rgba(220, 53, 69, 0.8));
    }
}

/* Confirm Animation Mejorado */
@keyframes confirm-pulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(37, 99, 235, 0.3));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 20px rgba(37, 99, 235, 0.6));
    }
}

/* Aplicar animaciones específicas por tipo con mejoras */
.alert-card .alert-icon {
    animation: icon-bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.alert-card .alert-title {
    animation: title-slide-in 0.4s ease-out 0.2s both;
}

.alert-card .alert-message {
    animation: message-slide-up 0.4s ease-out 0.3s both;
}

.alert-card.loading .alert-icon {
    animation: icon-bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), alert-spin-pulse 2s ease-in-out infinite 0.6s;
}

.alert-card.success .alert-icon {
    animation: icon-bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), alert-success-pop 0.8s ease-out 0.6s, success-glow 2s ease-in-out infinite 1.4s;
}

.alert-card.warning .alert-icon {
    animation: icon-bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), alert-warning-pulse 1.8s ease-in-out infinite 0.6s, warning-glow 2s ease-in-out infinite 0.6s;
}

.alert-card.error .alert-icon {
    animation: icon-bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), alert-error-shake 0.8s ease-in-out 0.6s, error-glow 2s ease-in-out infinite 1.4s;
}

.alert-card.confirm .alert-icon {
    animation: icon-bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), confirm-pulse 2s ease-in-out infinite 0.6s;
}

/* Responsive */
@media (max-width: 768px) {
    .demo-container {
        padding: 2rem;
        margin: 1rem;
    }

    .confirm-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .confirm-btn {
        width: 100%;
        min-width: auto;
        padding: 1rem 1.5rem;
        font-size: 1.05rem;
        justify-content: center;
    }

    .confirm-btn i {
        font-size: 1.1rem;
    }

    .alert-card {
        padding: 1.5rem;
    }

    .alert-icon {
        font-size: 3rem;
    }

    .demo-title {
        font-size: 2rem;
    }
}