/**
 * WP Stories Modern Toast Notifications
 * Replaces old alert() popups with stylish notifications
 */

/* Toast Container */
.wp-stories-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 400px;
}

/* Individual Toast */
.wp-stories-toast {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 320px;
    max-width: 420px;
    pointer-events: all;
    transform: translateX(440px);
    animation: slideIn 0.4s cubic-bezier(0.68, -0.55, 0.25, 1.35) forwards;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Toast Animation */
@keyframes slideIn {
    to {
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(420px);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.wp-stories-toast.removing {
    animation: slideOut 0.3s ease-in forwards;
}

/* Progress Bar */
.wp-stories-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.3;
    animation: progress var(--toast-duration, 6s) linear forwards;
    transition: width 0.1s linear;
}

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

/* Toast Icon */
.wp-stories-toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-stories-toast-icon svg {
    width: 100%;
    height: 100%;
}

/* Toast Content */
.wp-stories-toast-content {
    flex: 1;
}

.wp-stories-toast-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 5px 0;
    color: #1a1a1a;
    line-height: 1.4;
}

.wp-stories-toast-message {
    font-size: 14px;
    color: #555;
    margin: 0;
    line-height: 1.5;
    opacity: 0.9;
}

/* Close Button */
.wp-stories-toast-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.wp-stories-toast-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

.wp-stories-toast-close svg {
    width: 14px;
    height: 14px;
}

/* Success Toast */
.wp-stories-toast.success {
    border-left: 4px solid #4CAF50;
}

.wp-stories-toast.success .wp-stories-toast-icon {
    color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 50%;
    padding: 4px;
}

.wp-stories-toast.success .wp-stories-toast-progress {
    background: #4CAF50;
}

/* Error Toast */
.wp-stories-toast.error {
    border-left: 4px solid #f44336;
}

.wp-stories-toast.error .wp-stories-toast-icon {
    color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    border-radius: 50%;
    padding: 4px;
}

.wp-stories-toast.error .wp-stories-toast-progress {
    background: #f44336;
}

/* Warning Toast */
.wp-stories-toast.warning {
    border-left: 4px solid #ff9800;
}

.wp-stories-toast.warning .wp-stories-toast-icon {
    color: #ff9800;
    background: rgba(255, 152, 0, 0.1);
    border-radius: 50%;
    padding: 4px;
}

.wp-stories-toast.warning .wp-stories-toast-progress {
    background: #ff9800;
}

/* Info Toast */
.wp-stories-toast.info {
    border-left: 4px solid #2196F3;
}

.wp-stories-toast.info .wp-stories-toast-icon {
    color: #2196F3;
    background: rgba(33, 150, 243, 0.1);
    border-radius: 50%;
    padding: 4px;
}

.wp-stories-toast.info .wp-stories-toast-progress {
    background: #2196F3;
}

/* Loading Toast */
.wp-stories-toast.loading {
    border-left: 4px solid #9C27B0;
}

.wp-stories-toast.loading .wp-stories-toast-icon {
    color: #9C27B0;
    background: rgba(156, 39, 176, 0.1);
    border-radius: 50%;
    padding: 4px;
}

.wp-stories-toast.loading .wp-stories-toast-icon svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.wp-stories-toast.loading .wp-stories-toast-progress {
    display: none;
}

/* Mobile Responsive */
@media screen and (max-width: 480px) {
    .wp-stories-toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .wp-stories-toast {
        min-width: auto;
        max-width: none;
        width: 100%;
    }
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    .wp-stories-toast {
        background: #2a2a2a;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    
    .wp-stories-toast-title {
        color: #ffffff;
    }
    
    .wp-stories-toast-message {
        color: #b0b0b0;
    }
    
    .wp-stories-toast-close {
        color: #666;
    }
    
    .wp-stories-toast-close:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
    }
}

/* Celebration Animation for Success */
@keyframes celebrate {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.05) rotate(1deg);
    }
    75% {
        transform: scale(1.05) rotate(-1deg);
    }
}

.wp-stories-toast.success.celebrate {
    animation: slideIn 0.3s cubic-bezier(0.68, -0.55, 0.25, 1.35) forwards,
              celebrate 0.5s ease-in-out 0.3s;
}

/* Shake Animation for Errors */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-2px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(2px);
    }
}

.wp-stories-toast.error.shake {
    animation: slideIn 0.3s cubic-bezier(0.68, -0.55, 0.25, 1.35) forwards,
              shake 0.5s ease-in-out 0.3s;
}