.flashes {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.alert {
    display: flex;
    align-items: flex-start;
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 0.95em;
    font-family: inherit;
    font-weight: 500;
    color: #ffffff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideInRight 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition: all 0.3s ease;
    min-width: 250px;
}

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

.alert:hover::before {
    left: 100%;
}

.alert:hover {
    transform: translateX(-5px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.alert-icon {
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.alert-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.alert-message {
    font-weight: 600;
    line-height: 1.4;
}

.alert-close {
    background: none;
    border: none;
    color: currentColor;
    cursor: pointer;
    padding: 4px;
    margin-left: 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0.7;
    flex-shrink: 0;
}

.alert-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.alert-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    animation: progress 5s linear forwards;
    border-radius: 0 0 12px 12px;
}

/* Alert Types */
.alert-success {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: #ffffff;
}

.alert-error, .alert-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #ffffff;
}

.alert-warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: #ffffff;
}

.alert-info {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: #ffffff;
}

/* Default alert (no category) */
.alert:not([class*="alert-success"]):not([class*="alert-error"]):not([class*="alert-danger"]):not([class*="alert-warning"]):not([class*="alert-info"]) {
    background: linear-gradient(135deg, #1ec6b6, #0e5e5a);
    color: #ffffff;
}

/* Dark Mode Adjustments */
body.dark-mode .alert {
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .alert-success {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

body.dark-mode .alert-error, 
body.dark-mode .alert-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

body.dark-mode .alert-warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

body.dark-mode .alert-info {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

/* Animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes progress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

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

/* ============ RESPONSIVE DESIGN MEJORADO ============ */

/* Tablet Portrait y Large Mobile - 768px y menos */
@media (max-width: 768px) {
    .flashes {
        position: fixed !important;
        top: 80px !important;
        left: 15px !important;
        right: 15px !important;
        max-width: none !important;
        z-index: 1050 !important; /* Mayor z-index para asegurar visibilidad */
    }
    
    .alert {
        min-width: auto !important;
        width: 100% !important;
        padding: 18px 20px !important; /* Más padding para better touch experience */
        border-radius: 14px !important;
        font-size: 16px !important; /* Previene zoom automático en iOS */
        min-height: 60px !important; /* Altura mínima para mejor legibilidad */
        animation: slideInDown 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
        box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2) !important;
        margin-bottom: 12px !important;
        max-width: calc(100vw - 30px) !important; /* Previene overflow horizontal */
        box-sizing: border-box !important; /* Incluye padding y border en el width */
    }
    
    .alert:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    }
    
    .alert-icon {
        width: 28px;
        height: 28px;
        margin-right: 15px;
        background: rgba(255, 255, 255, 0.25);
    }
    
    .alert-icon svg {
        width: 22px;
        height: 22px;
    }
    
    .alert-message {
        font-weight: 600;
        line-height: 1.5; /* Mejor legibilidad en móvil */
        font-size: 1em;
    }
    
    .alert-close {
        padding: 8px;
        margin-left: 15px;
        border-radius: 8px;
        min-width: 40px; /* Área táctil mínima */
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .alert-close svg {
        width: 18px;
        height: 18px;
    }
    
    .alert-progress {
        height: 4px; /* Más gruesa para mejor visibilidad en móvil */
        border-radius: 0 0 14px 14px;
    }
    
    /* Animación personalizada para móvil */
    @keyframes slideInDown {
        from {
            transform: translateY(-100%);
            opacity: 0;
            scale: 0.95;
        }
        to {
            transform: translateY(0);
            opacity: 1;
            scale: 1;
        }
    }
}

/* Mobile Small - 480px y menos */
@media (max-width: 480px) {
    .flashes {
        position: fixed !important;
        top: 70px !important;
        left: 10px !important;
        right: 10px !important;
        max-width: fit-content !important;
        z-index: 2000 !important;
        box-sizing: border-box !important;
    }
    
    .alert {
        padding: 15px 25px !important;
        border-radius: 12px !important;
        font-size: 15px !important;
        min-height: 56px !important;
        margin-bottom: 10px !important;
        max-width: calc(100vw - 20px) !important; /* Previene desbordamiento horizontal */
        min-width: auto !important;
        width: 100% !important; /* Ocupa todo el ancho del contenedor .flashes */
        box-sizing: border-box !important;
    }
    
    .alert-icon {
        width: 26px !important;
        height: 26px !important;
        margin-right: 12px !important;
    }
    
    .alert-icon svg {
        width: 20px !important;
        height: 20px !important;
    }
    
    .alert-message {
        font-size: 0.9em !important;
        line-height: 1.4 !important; /* Mejor legibilidad */
        padding: 5px !important;
    }
    
    .alert-close {
        padding: 10px !important;
        margin-left: 5px !important;
        min-width: 36px !important;
        min-height: 36px !important;
        border-radius: 6px !important;
    }
    
    .alert-close svg {
        width: 16px !important;
        height: 16px !important;
    }
    
    .alert-progress {
        height: 3px;
        border-radius: 0 0 12px 12px;
    }
}

/* Landscape mode optimizations para móviles */
@media (max-height: 500px) and (orientation: landscape) {
    .flashes {
        top: 50px;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .alert {
        margin-bottom: 8px;
        padding: 12px 16px;
        min-height: 48px;
    }
    
    .alert-icon {
        width: 22px;
        height: 22px;
        margin-right: 10px;
    }
    
    .alert-message {
        line-height: 1.3;
        font-size: 0.9em;
    }
}

/* Large Desktop - mejor posicionamiento */
@media (min-width: 1200px) {
    .flashes {
        top: 90px;
        right: 30px;
        max-width: 450px;
    }
    
    .alert {
        padding: 18px 24px;
        border-radius: 14px;
        min-width: 350px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    }
    
    .alert-icon {
        width: 26px;
        height: 26px;
        margin-right: 14px;
    }
    
    .alert-message {
        font-size: 1rem;
        line-height: 1.5;
    }
}

/* Mejoras para accesibilidad y touch */
@media (hover: none) and (pointer: coarse) {
    /* Dispositivos táctiles */
    .alert:hover {
        transform: none; /* Evita hover effects en táctil */
    }
    
    .alert-close:hover {
        transform: scale(1.05); /* Efecto táctil más sutil */
    }
    
    .alert-close:active {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 0.3);
    }
}

/* High DPI displays - mejores sombras y efectos */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .alert {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
        backdrop-filter: blur(12px);
    }
    
    .alert:hover {
        box-shadow: 0 6px 28px rgba(0, 0, 0, 0.22);
    }
}

/* Dark mode responsive adjustments */
body.dark-mode .alert {
    border: 1px solid rgba(255, 255, 255, 0.15);
}

@media (max-width: 768px) {
    body.dark-mode .alert {
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }
}

/* Enhanced auto-dismiss animation */
.alert.auto-dismiss {
    animation: fadeOut 0.4s ease-in-out forwards;
}

/* Swipe gesture support */
.alert:not(.no-swipe) {
    touch-action: pan-y; /* Permite scroll vertical pero captura horizontal */
    will-change: transform, opacity; /* Optimización de performance */
}

.alert.no-swipe {
    touch-action: manipulation; /* Desactiva gestos personalizados */
}

/* Focus states para accesibilidad */
.alert:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
    z-index: 1051; /* Asegurar que el foco sea visible */
}

.alert-close:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 1px;
    background: rgba(255, 255, 255, 0.25);
}

/* Estados de swipe en progreso */
.alert.swiping {
    pointer-events: none; /* Evita clicks accidentales durante swipe */
    transition: none !important; /* Deshabilitar transiciones durante swipe */
}

/* Indicador visual para swipe disponible en móvil */
@media (hover: none) and (pointer: coarse) {
    .alert:not(.no-swipe):after {
        content: '←→';
        position: absolute;
        top: 50%;
        right: 50px;
        transform: translateY(-50%);
        opacity: 0.3;
        font-size: 12px;
        color: currentColor;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    
    .alert:not(.no-swipe):hover:after {
        opacity: 0.6;
    }
}

/* Animaciones mejoradas para diferentes tamaños */
@media (max-width: 768px) {
    @keyframes slideInDown {
        from {
            transform: translateY(-100%) scale(0.95);
            opacity: 0;
        }
        50% {
            transform: translateY(-20%) scale(1.02);
            opacity: 0.8;
        }
        to {
            transform: translateY(0) scale(1);
            opacity: 1;
        }
    }
    
    @keyframes fadeOut {
        from {
            transform: translateY(0) scale(1);
            opacity: 1;
        }
        to {
            transform: translateY(-100%) scale(0.95);
            opacity: 0;
        }
    }
}

/* Mejoras para modos de alto contraste */
@media (prefers-contrast: high) {
    .alert {
        border: 2px solid currentColor;
        backdrop-filter: none;
        background: var(--alert-bg-high-contrast);
    }
    
    .alert-success {
        --alert-bg-high-contrast: #2ecc71;
    }
    
    .alert-error, .alert-danger {
        --alert-bg-high-contrast: #e74c3c;
    }
    
    .alert-warning {
        --alert-bg-high-contrast: #f39c12;
    }
    
    .alert-info {
        --alert-bg-high-contrast: #3498db;
    }
}

/* Prefers reduced motion - accessibility */
@media (prefers-reduced-motion: reduce) {
    .alert {
        animation: none;
        transition: opacity 0.3s ease;
    }
    
    .alert::before {
        transition: none;
    }
    
    .alert:hover::before {
        left: -100%;
    }
    
    .alert-progress {
        animation: progressReduced 5s linear forwards;
    }
    
    @keyframes progressReduced {
        from { width: 100%; }
        to { width: 0%; }
    }
    
    /* Sin swipe gestures para usuarios que prefieren menos movimiento */
    .alert {
        touch-action: manipulation;
    }
}