/* ================================================================================
   TOAST.CSS - Toast Notification System
   Global component - no modal ID scoping needed
   No dark mode overrides - uses variables
   ================================================================================ */

/* ================================
   TOAST CONTAINER
   ================================ */
.toast-container {
    position: fixed;
    z-index: var(--z-toast);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-xl);
    
    /* Default: bottom center */
    bottom: calc(var(--nav-height) + var(--space-xl));
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
    width: 100%;
    max-width: 500px;
}

/* Position variants */
.toast-container[data-position="top-right"] {
    top: calc(var(--nav-height) + var(--space-md));
    bottom: auto;
    left: auto;
    right: var(--space-md);
    transform: none;
    align-items: flex-end;
}

.toast-container[data-position="bottom-right"] {
    left: auto;
    right: var(--space-md);
    transform: none;
    align-items: flex-end;
}

.toast-container[data-position="top-center"] {
    top: calc(var(--nav-height) + var(--space-md));
    bottom: auto;
}

/* ================================
   INDIVIDUAL TOAST
   ================================ */
.toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 420px;
    width: calc(100vw - 40px);
    padding: var(--space-lg) var(--space-xl);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    opacity: 0;
    transform: translateY(100%) scale(0.9);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    
    /* Glass morphism design */
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
}

/* ================================
   TOAST STATES
   ================================ */
.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast.hide {
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
    transition: all 0.3s ease-in;
}

/* ================================
   TOAST CONTENT
   ================================ */
.toast-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-circle);
    background: var(--bg-section);
}

.toast-message {
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* ================================
   TOAST CLOSE BUTTON
   ================================ */
.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.toast-close:hover {
    opacity: 1;
    background: var(--hover-subtle);
    transform: scale(1.1);
}

.toast-close:focus {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}

/* ================================
   TOAST TYPE VARIANTS
   ================================ */

/* Success */
.toast.success {
    background: var(--bg-green);
    border-color: var(--border-green);
}

.toast.success .toast-icon {
    background: var(--bg-green-hover);
    color: var(--green);
}

.toast.success .toast-message {
    color: var(--green);
}

/* Error */
.toast.error {
    background: var(--bg-red);
    border-color: var(--border-red);
}

.toast.error .toast-icon {
    background: var(--bg-red-hover);
    color: var(--red);
}

.toast.error .toast-message {
    color: var(--red);
}

/* Warning */
.toast.warning {
    background: var(--bg-orange);
    border-color: var(--border-orange);
}

.toast.warning .toast-icon {
    background: var(--bg-orange-hover);
    color: var(--orange);
}

.toast.warning .toast-message {
    color: var(--dark-orange);
}

/* Info */
.toast.info {
    background: var(--bg-blue);
    border-color: var(--border-blue);
}

.toast.info .toast-icon {
    background: rgba(59, 130, 246, 0.15);
    color: var(--blue);
}

.toast.info .toast-message {
    color: var(--dark-blue);
}

/* Loading */
.toast.loading {
    background: var(--bg-purple);
    border-color: var(--border-purple);
}

.toast.loading .toast-icon {
    background: rgba(139, 92, 246, 0.15);
    color: var(--purple);
}

.toast.loading .toast-message {
    color: var(--text-purple);
}

.toast.loading .toast-close {
    display: none;
}

/* ================================
   PROGRESS BAR (auto-dismiss indicator)
   ================================ */
.toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: currentColor;
    opacity: 0.2;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    animation: toastProgress 3s linear forwards;
    transform-origin: left;
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.toast.persistent::after {
    display: none;
}

/* ================================
   ANIMATIONS
   ================================ */
@keyframes toastBounceIn {
    0% {
        opacity: 0;
        transform: translateY(100%) scale(0.7);
    }
    50% {
        transform: translateY(-10px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastSlideOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
}

.toast.animate-in {
    animation: toastBounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.toast.animate-out {
    animation: toastSlideOut 0.3s ease-in forwards;
}

/* ================================
   STACKING MULTIPLE TOASTS
   ================================ */
.toast-container .toast:nth-child(n+2) {
    transform: translateY(0) scale(0.95);
}

.toast-container .toast:nth-child(n+3) {
    transform: translateY(0) scale(0.9);
    opacity: 0.9;
}

/* ================================
   RESPONSIVE
   ================================ */
@media (max-width: 480px) {
    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
        transform: none;
        max-width: none;
    }

    .toast-container[data-position="bottom-center"],
    .toast-container[data-position="top-center"] {
        left: var(--space-md);
        right: var(--space-md);
        transform: none;
    }

    .toast {
        min-width: 100%;
        max-width: 100%;
    }

    .toast-message {
        font-size: var(--text-sm);
    }
}

/* ================================
   ACCESSIBILITY
   ================================ */
.toast:focus {
    outline: 2px solid var(--purple);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: opacity 0.2s ease;
    }

    .toast.animate-in,
    .toast.animate-out {
        animation: none;
    }

    .toast::after {
        animation: none;
    }
}

@media (prefers-contrast: high) {
    .toast {
        border-width: 2px;
    }
}