/**
 * @file
 * Custom styling for Bootstrap Barrio Toasts.
 *
 * Enhances the default Bootstrap Barrio toast styles with
 * a modern, vibrant, and premium design.
 */

/* Toast container positioning */
.toast-container {
    z-index: 1100 !important;
    top: 1rem !important;
    right: 1rem !important;
}

/* Base Toast Styling */
.toast-container .toast {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    overflow: hidden;
    border: none;
    border-left: 6px solid transparent;
    background-color: #ffffff;
    font-family: 'Inter', sans-serif;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

/* Header & Body Unified Layout */
.toast-container .toast .toast-header {
    background: transparent;
    border-bottom: none;
    padding: 1rem 1rem 0.25rem 1rem;
    font-size: 0.95rem;
    color: #1f2937;
}

.toast-container .toast .toast-body {
    padding: 0.25rem 1rem 1rem 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #4b5563;
}

/* Remove default SVG square if present, and style icon/strong */
.toast-container .toast .toast-header svg.bd-placeholder-img {
    display: none;
}

.toast-container .toast .toast-header strong {
    font-weight: 700;
    font-size: 1rem;
    margin-right: auto;
}

/* Close Button Styling */
.toast-container .toast .btn-close {
    opacity: 0.4;
    transition: opacity 0.2s ease, transform 0.2s ease;
    filter: grayscale(100%);
}

.toast-container .toast .btn-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

/* VARIANT: SUCCESS (Green) */
/* Selector logic: Find toast containing svg with green fill OR specific class */
.toast-container .toast:has(rect[fill="#28a745"]),
.toast-container .toast:has(.text-success),
.toast-container .toast.toast-success {
    border-left-color: #10b981;
    background: linear-gradient(to right, #ecfdf5, #ffffff);
}

.toast-container .toast:has(rect[fill="#28a745"]) .toast-header strong,
.toast-container .toast.toast-success .toast-header strong {
    color: #065f46;
}

/* VARIANT: WARNING (Yellow/Orange) */
.toast-container .toast:has(rect[fill="#ffc107"]),
.toast-container .toast:has(.text-warning),
.toast-container .toast.toast-warning {
    border-left-color: #f59e0b;
    background: linear-gradient(to right, #fffbeb, #ffffff);
}

.toast-container .toast:has(rect[fill="#ffc107"]) .toast-header strong,
.toast-container .toast.toast-warning .toast-header strong {
    color: #92400e;
}

/* VARIANT: ERROR/DANGER (Red) */
.toast-container .toast:has(rect[fill="#dc3545"]),
.toast-container .toast:has(.text-danger),
.toast-container .toast.toast-danger {
    border-left-color: #ef4444;
    background: linear-gradient(to right, #fef2f2, #ffffff);
}

.toast-container .toast:has(rect[fill="#dc3545"]) .toast-header strong,
.toast-container .toast.toast-danger .toast-header strong {
    color: #991b1b;
}

/* VARIANT: INFO (Blue) */
.toast-container .toast:has(rect[fill="#17a2b8"]),
.toast-container .toast:has(.text-info),
.toast-container .toast.toast-info {
    border-left-color: #3b82f6;
    background: linear-gradient(to right, #eff6ff, #ffffff);
}

.toast-container .toast:has(rect[fill="#17a2b8"]) .toast-header strong,
.toast-container .toast.toast-info .toast-header strong {
    color: #1e40af;
}

/* Fallbacks for older browsers via simple class checks if :has is not supported sufficiently, 
   though modern browsers support it. Drupal usually adds classes to the container too. */


/* Animations */
.toast-container .toast.showing, 
.toast-container .toast.show {
    animation: toastSlideInElastic 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-container .toast.hide {
    animation: toastFadeOut 0.3s ease-in forwards;
}

@keyframes toastSlideInElastic {
    0% {
        opacity: 0;
        transform: translateX(100%) scale(0.9);
    }
    60% {
        opacity: 1;
        transform: translateX(-10px) scale(1.02);
    }
    100% {
        transform: translateX(0) scale(1);
    }
}

@keyframes toastFadeOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* Responsive */
@media (max-width: 576px) {
    .toast-container {
        width: calc(100% - 2rem);
        max-width: none;
        left: 1rem;
        right: 1rem;
    }
    .toast-container .toast {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}