/**
 * Modern Toast Notifications System
 * Hudo AI - Brand-aligned floating notifications
 *
 * Features:
 * - Fixed positioning (no layout displacement)
 * - Smooth slide-in/slide-out animations
 * - Glassmorphism design with brand colors
 * - Auto-dismiss with progress bar
 * - Mobile responsive
 */

/* Container for all toast notifications */
.hudo-toast-container {
    position: fixed;
    top: 80px; /* Below navbar */
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    width: calc(100% - 40px);
    pointer-events: none;
}

/* Individual toast notification */
.hudo-toast {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.08),
        0 8px 32px rgba(143, 76, 254, 0.08),
        0 0 0 1px rgba(255, 255, 255, 0.8) inset;
    pointer-events: auto;
    position: relative;
    overflow: hidden;

    /* Animation */
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hudo-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.hudo-toast.hide {
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Left accent bar */
.hudo-toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--toast-accent-color, var(--primary-3, #8F4CFE));
    border-radius: 4px 0 0 4px;
}

/* Icon container */
.hudo-toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--toast-icon-bg, rgba(143, 76, 254, 0.1));
    color: var(--toast-accent-color, var(--primary-3, #8F4CFE));
    font-size: 18px;
    flex-shrink: 0;
}

/* Content area */
.hudo-toast-content {
    flex: 1;
    min-width: 0;
}

.hudo-toast-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--gray-5, #232323);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.hudo-toast-message {
    font-size: 13px;
    color: var(--gray-7, #5E5E5C);
    margin: 0;
    line-height: 1.5;
    word-break: break-word;
}

/* Close button */
.hudo-toast-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--gray-4, #B2B3AF);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin: -4px -8px -4px 0;
}

.hudo-toast-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--gray-6, #333333);
}

/* Progress bar for auto-dismiss */
.hudo-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--toast-accent-color, var(--primary-3, #8F4CFE));
    border-radius: 0 0 0 4px;
    opacity: 0.6;
    animation: toast-progress 5s linear forwards;
}

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

/* ========================================
   Type Variants
   ======================================== */

/* Success */
.hudo-toast.success {
    --toast-accent-color: #10b981;
    --toast-icon-bg: rgba(16, 185, 129, 0.12);
}

.hudo-toast.success .hudo-toast-icon {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.08));
}

/* Error */
.hudo-toast.error {
    --toast-accent-color: #ef4444;
    --toast-icon-bg: rgba(239, 68, 68, 0.12);
}

.hudo-toast.error .hudo-toast-icon {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
}

/* Warning */
.hudo-toast.warning {
    --toast-accent-color: #f59e0b;
    --toast-icon-bg: rgba(245, 158, 11, 0.12);
}

.hudo-toast.warning .hudo-toast-icon {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.08));
}

/* Info */
.hudo-toast.info {
    --toast-accent-color: var(--primary-3, #8F4CFE);
    --toast-icon-bg: rgba(143, 76, 254, 0.12);
}

.hudo-toast.info .hudo-toast-icon {
    background: linear-gradient(135deg, rgba(143, 76, 254, 0.15), rgba(128, 119, 254, 0.1));
}

/* ========================================
   Hover Effects
   ======================================== */

.hudo-toast:hover {
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 12px 48px rgba(143, 76, 254, 0.12),
        0 0 0 1px rgba(255, 255, 255, 0.9) inset;
    transform: translateX(0) translateY(-2px);
}

.hudo-toast:hover .hudo-toast-progress {
    animation-play-state: paused;
}

/* ========================================
   Mobile Responsive
   ======================================== */

@media (max-width: 576px) {
    .hudo-toast-container {
        top: 70px;
        right: 12px;
        left: 12px;
        max-width: none;
        width: auto;
    }

    .hudo-toast {
        padding: 14px 16px;
        gap: 12px;
        border-radius: 14px;

        /* Mobile: slide down from top */
        transform: translateY(-100%);
    }

    .hudo-toast.show {
        transform: translateY(0);
    }

    .hudo-toast.hide {
        transform: translateY(-100%);
    }

    .hudo-toast-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
        border-radius: 10px;
    }

    .hudo-toast-title {
        font-size: 13px;
    }

    .hudo-toast-message {
        font-size: 12px;
    }
}

/* ========================================
   Dark Mode Support
   Uses data-bs-theme selector for manual toggle
   ======================================== */

[data-bs-theme="dark"] .hudo-toast {
    background: rgba(30, 30, 30, 0.95);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.3),
        0 8px 32px rgba(143, 76, 254, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

[data-bs-theme="dark"] .hudo-toast-title {
    color: #ffffff;
}

[data-bs-theme="dark"] .hudo-toast-message {
    color: rgba(255, 255, 255, 0.7);
}

[data-bs-theme="dark"] .hudo-toast-close {
    color: rgba(255, 255, 255, 0.5);
}

[data-bs-theme="dark"] .hudo-toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

[data-bs-theme="dark"] .hudo-toast:hover {
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 12px 48px rgba(143, 76, 254, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

/* ========================================
   Stacking Animations
   ======================================== */

.hudo-toast:nth-child(2) {
    transition-delay: 0.05s;
}

.hudo-toast:nth-child(3) {
    transition-delay: 0.1s;
}

.hudo-toast:nth-child(n+4) {
    transition-delay: 0.15s;
}

/* Limit visible toasts */
.hudo-toast:nth-child(n+5) {
    display: none;
}
