:root {
    /* Use min() to ensure it doesn't overflow mobile screens */
    --toast-width: min(400px, 90vw);
    --toast-bg: #ffffff;
    --toast-text: #333333;
    --success-color: #2ecc71;
    --error-color: #e74c3c;
    --warning-color: #f1c40f;
    --info-color: #3498db;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --confirmation-width: min(450px, 90vw);
    --primary-color: #007bff;
    --danger-color: #dc3545;
}

/* --- NOTIFICATION CONTAINER --- */
#toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    /* Ensure container doesn't block clicks when empty */
    pointer-events: none;
}

/* --- THE TOAST --- */
.toast {
    width: var(--toast-width);
    background: var(--toast-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    /* Better alignment for long text */
    padding: 15px 20px;
    position: relative;
    overflow: hidden;
    /* Re-enable pointer events for the toasts themselves */
    pointer-events: auto;
    animation: slideInRight 0.4s ease forwards;
    border-left: 6px solid;
    backdrop-filter: blur(10px);
}

/* Toast Types Colors */
.toast.success {
    border-color: var(--success-color);
}

.toast.error {
    border-color: var(--error-color);
}

.toast.warning {
    border-color: var(--warning-color);
}

.toast.info {
    border-color: var(--info-color);
}

/* Icon Wrapper */
.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 24px;
    margin-top: 2px;
    /* Visual alignment fix */
    flex-shrink: 0;
    /* Prevent icon from shrinking */
}

.toast.success .toast-icon {
    color: var(--success-color);
}

.toast.error .toast-icon {
    color: var(--error-color);
}

.toast.warning .toast-icon {
    color: var(--warning-color);
}

.toast.info .toast-icon {
    color: var(--info-color);
}

/* Content */
.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    margin-bottom: 4px;
    color: #111;
    font-size: 16px;
}

.toast-message {
    font-size: 14px;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

/* Close Button */
.toast-close {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: #aaa;
    padding: 0;
    margin-left: 10px;
    margin-top: -2px;
    min-width: auto;
    /* Override button generic style */
    width: auto;
    flex: 0 0 auto;
    transition: color 0.3s;
}

.toast-close:hover {
    color: #333;
}

/* Progress Bar */
.progress-track {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background: rgba(0, 0, 0, 0.05);
}

.progress-bar {
    height: 100%;
    width: 100%;
    /* Colors handled via JS/CSS specificity */
}

.toast.success .progress-bar {
    background-color: var(--success-color);
}

.toast.error .progress-bar {
    background-color: var(--error-color);
}

.toast.warning .progress-bar {
    background-color: var(--warning-color);
}

.toast.info .progress-bar {
    background-color: var(--info-color);
}

/* --- ANIMATIONS --- */

/* Desktop Animation (Slide from Right) */
@keyframes slideInRight {
    from {
        transform: translateX(110%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Mobile Animation (Slide from Top) */
@keyframes slideInTop {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

@keyframes timer {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

.toast:hover .progress-bar {
    animation-play-state: paused;
}

/* --- MOBILE RESPONSIVENESS --- */
@media screen and (max-width: 480px) {
    #toast-container {
        right: 0;
        left: 50px;
        /* Center container */
        top: 80px;
        align-items: center;
        /* Center items inside */
        width: 100%;
        pointer-events: none;
    }

    .toast {
        /* On mobile, slide down from top */
        animation: slideInTop 0.4s ease forwards;
        width: 60%;
        /* Slight margin on sides */
        margin: 0 auto;
    }
}

/* --- CONFIRMATION MODAL --- */

.confirmation-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.confirmation-backdrop.show {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    opacity: 1;
}

.confirmation-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: var(--confirmation-width);
    background: var(--toast-bg);
    border-radius: 12px;
    box-shadow: var(--shadow), 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
    pointer-events: none;
}

.confirmation-modal.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.confirmation-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.confirmation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
}

.confirmation-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111;
}

.confirmation-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
    margin-left: 15px;
}

.confirmation-close:hover {
    color: #333;
}

.confirmation-body {
    padding: 20px;
    flex: 1;
}

.confirmation-message {
    margin: 0;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.confirmation-footer {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #e9ecef;
    justify-content: flex-end;
}

.confirmation-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 90px;
}

.confirmation-cancel {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #dee2e6;
}

.confirmation-cancel:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.confirmation-primary {
    background: var(--primary-color);
    color: white;
}

.confirmation-primary:hover {
    background: #0056b3;
}

.confirmation-danger {
    background: var(--danger-color);
    color: white;
}

.confirmation-danger:hover {
    background: #c82333;
}

.confirmation-btn:active {
    transform: scale(0.98);
}

.confirmation-btn:focus {
    outline: 2px solid var(--info-color);
    outline-offset: 2px;
}

/* Mobile responsiveness */
@media (max-width: 576px) {
    .confirmation-modal {
        width: 90vw;
        max-width: 100%;
    }

    .confirmation-header {
        padding: 15px;
    }

    .confirmation-body {
        padding: 15px;
    }

    .confirmation-footer {
        padding: 12px 15px;
        flex-wrap: wrap;
    }

    .confirmation-btn {
        flex: 1;
        min-width: 70px;
    }
}
    }
}
