/**
 * SPU Frontend — Supabase / SaaS Stripe-style notifications
 * Clean white glass card, circular avatar, soft layered shadow,
 * price chip and a subtle verified footer.
 */

:root {
    --spu-bg: rgba(255, 255, 255, 0.96);
    --spu-accent: #0d9488;              /* emerald-teal accent */
    --spu-text: #0f172a;                /* slate-900 */
    --spu-subtext: #64748b;             /* slate-500 */
    --spu-border: rgba(15, 23, 42, 0.08);
    --spu-glass-blur: 14px;
    --spu-pro-radius: 16px;
    --spu-pro-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.08), 0 20px 48px rgba(15, 23, 42, 0.06);
    --spu-pro-slide: -36px;
    --spu-pro-font: inherit;
}

#spu-notification-container {
    position: fixed;
    z-index: 999999;
    padding: 20px;
    pointer-events: none;
    font-family: var(--spu-pro-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.spu-position-bottom-left {
    bottom: 0;
    left: 0;
}

.spu-position-bottom-right {
    bottom: 0;
    right: 0;
}

.spu-position-top-left {
    top: 72px;
    left: 0;
}

.spu-position-top-right {
    top: 72px;
    right: 0;
}

.spu-notification {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--spu-bg);
    backdrop-filter: blur(var(--spu-glass-blur));
    -webkit-backdrop-filter: blur(var(--spu-glass-blur));
    border: 1px solid var(--spu-border);
    border-radius: var(--spu-pro-radius, 14px);
    padding: 10px 12px;
    box-shadow: var(--spu-pro-shadow, 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.08));
    box-sizing: border-box;
    width: fit-content;
    min-width: 240px;
    max-width: 340px;
    pointer-events: auto;
    transform: translateX(var(--spu-pro-slide, -36px)) scale(0.98);
    opacity: 0;
    transform-origin: left center;
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease, box-shadow 0.3s ease;
    margin-bottom: 10px;
}

/* Speed Presets */
.spu-notification.spu-speed-fast {
    transition-duration: 0.3s;
}

.spu-notification.spu-speed-smooth {
    transition-duration: 0.6s;
}

.spu-notification.spu-speed-slow {
    transition-duration: 1.2s;
}

.spu-position-bottom-right .spu-notification,
.spu-position-top-right .spu-notification {
    transform: translateX(var(--spu-pro-slide, 36px)) scale(0.98);
    transform-origin: right center;
}

.spu-notification.spu-show {
    transform: translateX(0) scale(1);
    opacity: 1;
}

.spu-notification:hover {
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.05), 0 14px 34px rgba(15, 23, 42, 0.12);
}

.spu-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.spu-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--spu-accent), color-mix(in srgb, var(--spu-accent) 40%, #38bdf8));
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 0 0 2.5px #fff, 0 4px 12px rgba(15, 23, 42, 0.12);
    object-fit: cover;
}

.spu-badge {
    position: absolute;
    bottom: -1px;
    right: -1px;
    background: #22c55e;
    color: #fff;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
}

/* Purchases get an accent-coloured badge */
.spu-type-purchase .spu-badge {
    background: var(--spu-accent);
}

.spu-content {
    flex-grow: 1;
    min-width: 0;
    line-height: 1.35;
}

.spu-user-name {
    margin: 0 0 1px;
    font-weight: 700;
    font-size: 13px;
    color: var(--spu-accent); /* fallback when gradient isn't supported */
    line-height: 1.25;
    letter-spacing: -0.01em;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Special gradient username (SaaS look). Falls back to plain accent colour. */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
    .spu-user-name {
        background: linear-gradient(120deg, var(--spu-accent) 0%, color-mix(in srgb, var(--spu-accent) 45%, #38bdf8) 100%);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        color: transparent;
    }
}

.spu-action-text {
    margin: 0;
    font-size: 12.5px;
    color: var(--spu-subtext);
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.spu-action-text strong {
    color: var(--spu-text);
    font-weight: 600;
}

/* Price — bold accent text, kept tight with its parentheses (e.g. (RM39.99)) */
.spu-price {
    color: #059669;
    font-weight: 700;
    white-space: nowrap;
}

/* Keeps the price (and its parentheses) together on one line — never split
   the "(" from the price or drop it to its own line. */
.spu-price-parens {
    white-space: nowrap;
}

.spu-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    gap: 10px;
}

.spu-verif-branding {
    font-size: 9px;
    color: var(--spu-subtext);
    opacity: 0.75;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.spu-time {
    margin: 0;
    font-size: 9px;
    color: var(--spu-subtext);
    opacity: 0.6;
    font-weight: 500;
}

.spu-close {
    padding: 0 0 0 8px;
    cursor: pointer;
    font-size: 16px;
    color: #cbd5e1;
    line-height: 1;
    transition: color 0.2s ease;
    align-self: flex-start;
    background: none;
    border: none;
}

.spu-close:hover {
    color: #64748b;
}

/* Mobile Optimization */
@media (max-width: 500px) {
    #spu-notification-container {
        padding: 14px;
    }

    .spu-notification {
        min-width: 0;
        max-width: calc(100vw - 28px);
        padding: 9px 10px;
        gap: 9px;
        border-radius: 13px;
    }

    .spu-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .spu-user-name {
        font-size: 12.5px;
    }

    .spu-action-text {
        font-size: 12px;
    }

    .spu-badge {
        width: 14px;
        height: 14px;
    }

    .spu-price {
        font-size: 11px;
    }
}
