/* =========================================
   1. Toast Container
   ========================================= */
#toast-container {
    position: fixed;
    z-index: 1050;
    pointer-events: none; /* Allows clicking through the container */
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* Positioning variants */
.toast-top-right { top: 20px; right: 20px; }
.toast-top-left { top: 20px; left: 20px; }
.toast-bottom-right { bottom: 20px; right: 20px; }
.toast-bottom-left { bottom: 20px; left: 20px; }

/* =========================================
   2. General Toast Styles
   ========================================= */
.toast {
    /* Base Shape & Layout */
    width: 100%; /* Ensures it fills container width up to max-width */
    min-width: 320px;
    max-width: 420px;
    border-radius: 5px;
    padding: 12px 15px; /* Slightly adjusted for better vertical spacing */
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
    overflow: hidden;

    /* Glassmorphism & Colors */
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); /* Safari support */
    box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.15);
    border-left: 5px solid transparent;
    color: white;
    opacity: 0.95;

    /* Typography */
    font-size: 16px;
    font-weight: 500;

    /* Animations & Interaction */
    transition: all 0.3s ease-in-out;
    animation: fadeInUp 0.4s ease-in-out;
    pointer-events: auto; /* CRITICAL FIX: Allows clicking the close button */
}

/* Hover Effect */
.toast:hover {
    transform: scale(1.02); /* Reduced slightly for subtler effect */
    box-shadow: 0px 15px 40px rgba(255, 255, 255, 0.2);
    opacity: 1;
}

/* =========================================
   3. Toast Types & Gradients
   ========================================= */
/* Success */
.toast-success {
    border-left-color: #22c55e;
    background: linear-gradient(135deg, rgba(22, 163, 74, 0.9) 0%, rgba(74, 222, 128, 0.9) 100%);
}
/* Error */
.toast-error {
    border-left-color: #ef4444;
    background: linear-gradient(135deg, rgba(185, 28, 28, 0.9) 0%, rgba(248, 113, 113, 0.9) 100%);
}
/* Info */
.toast-info {
    border-left-color: #3b82f6;
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.9) 0%, rgba(96, 165, 250, 0.9) 100%);
}
/* Warning */
.toast-warning {
    border-left-color: #eab308;
    background: linear-gradient(135deg, rgba(180, 83, 9, 0.9) 0%, rgba(250, 204, 21, 0.9) 100%);
}

/* =========================================
   4. Iconography (Bootstrap Icons)
   ========================================= */
.toast::before {
    font-family: "Bootstrap-icons";
    font-size: 24px;
    flex-shrink: 0; /* Prevents icon from shrinking on long text */
}

.toast-success::before { content: "\F270"; } /* check-circle */
.toast-error::before { content: "\F333"; }   /* exclamation-triangle */
.toast-info::before { content: "\F44A"; }    /* info-circle */
.toast-warning::before { content: "\F33B"; } /* exclamation-circle */

/* =========================================
   5. Content & Close Button
   ========================================= */
.toast-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.toast-title {
    font-weight: 700;
    font-size: 17px;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 15px;
    word-wrap: break-word;
    line-height: 1.4;
}

.toast-message a {
    color: #fff;
    font-weight: 600;
    text-decoration: underline;
}
.toast-message a:hover {
    color: #ddd;
}

.toast-close-button {
    position: absolute;
    right: 12px;
    top: 12px;
    font-size: 18px;
    opacity: 0.7;
    cursor: pointer; /* UX Fix */
    transition: opacity 0.2s, transform 0.2s;
    color: white;
    background: none;
    border: none;
    padding: 0;
}

.toast-close-button:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* =========================================
   6. Progress Bar
   ========================================= */
.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.5);
    width: 100%;
    transform-origin: left;
    /* Animation name matches keyframes below */
    animation: progressBar linear forwards;
}

/* CRITICAL FIX: Missing Keyframes for Progress */
@keyframes progressBar {
    0% { transform: scaleX(1); }
    100% { transform: scaleX(0); }
}

/* =========================================
   7. Animations (Enter & Exit)
   ========================================= */
@keyframes fadeInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 0.95;
    }
}

@keyframes fadeOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-20px);
        opacity: 0;
    }
}

/* =========================================
   8. Responsive Design
   ========================================= */
@media (max-width: 480px) {
    #toast-container {
        top:auto;
        bottom: 20px; /* Force bottom on mobile usually looks better */
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        align-items: center;
    }

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