/**
 * KMS Notification System - Fade In/Out Suau
 * Animacions amb opacitat 0 → 1 i desvaniment suau
 */

/* Container de notificacions */
#kms-notification-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    pointer-events: none;
    width: 100%;
    max-width: 420px;
    padding: 0 20px;
    box-sizing: border-box;
}

/* Notificació individual */
.kms-notification {
    pointer-events: auto;
    margin-bottom: 10px;
    padding: 12px 36px 12px 16px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15),
                0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    /* Iniciar amb opacitat 0 */
    opacity: 0;
    transform: translateY(-20px);
}

/* Dark theme support */
html[data-theme="dark"] .kms-notification {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4),
                0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Animació d'entrada - FADE IN SUAU de 0 a 1 */
@keyframes kmsFadeInDown {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animació de sortida - FADE OUT SUAU de 1 a 0 */
@keyframes kmsFadeOutUp {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Aplicar animació d'entrada */
.kms-notification.kms-notification-enter {
    animation: kmsFadeInDown 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Aplicar animació de sortida */
.kms-notification.kms-notification-exit {
    animation: kmsFadeOutUp 0.4s cubic-bezier(0.7, 0, 0.84, 0) forwards;
}

/* Hover effect - més subtil */
.kms-notification:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2),
                0 4px 12px rgba(0, 0, 0, 0.15);
}

html[data-theme="dark"] .kms-notification:hover {
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5),
                0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Barra de progrés amb fade */
.kms-notification::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.3;
    animation: kmsProgress linear;
    transform-origin: left;
}

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

/* Contingut del missatge */
.kms-notification-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 10px;
}

/* Icona */
.kms-notification-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

/* Missatge */
.kms-notification-message {
    flex: 1;
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* Botó de tancar */
.kms-notification-close {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    opacity: 0.8;
    transition: all 0.2s ease;
    border-radius: 5px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    position: absolute;
    top: 8px;
    right: 8px;
}

.kms-notification-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
    transform: rotate(90deg);
}

html[data-theme="dark"] .kms-notification-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Tipus de notificació - colors adaptats al KMS */

/* Success - degradat blau turquesa a verd turquesa */
.kms-notification-success {
    background: linear-gradient(145deg, #3dbdd9 0%, #00e5b8 100%);
    color: #ffffff;
}

html[data-theme="dark"] .kms-notification-success {
    background: linear-gradient(145deg, #3dbdd9 0%, #00d4a6 100%);
}

/* Error - vermell suau */
.kms-notification-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
}

html[data-theme="dark"] .kms-notification-error {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

/* Warning - taronja càlid */
.kms-notification-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
}

html[data-theme="dark"] .kms-notification-warning {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

/* Info - blau modern */
.kms-notification-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
}

html[data-theme="dark"] .kms-notification-info {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

/* Responsive */
@media (max-width: 640px) {
    #kms-notification-container {
        top: 10px;
        max-width: 100%;
        padding: 0 12px;
    }

    .kms-notification {
        padding: 10px 32px 10px 14px;
        font-size: 12px;
        border-radius: 8px;
    }

    .kms-notification-icon {
        font-size: 14px;
    }

    .kms-notification-close {
        font-size: 16px;
        width: 18px;
        height: 18px;
        top: 6px;
        right: 6px;
    }
}

/* Accessibilitat */
.kms-notification:focus-within {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Reducir moviment */
@media (prefers-reduced-motion: reduce) {
    .kms-notification,
    .kms-notification-close,
    .kms-notification:hover {
        transition: none;
        animation-duration: 0.01ms !important;
    }
    
    .kms-notification::before {
        animation: none;
    }
}
