/* ==========================================================================
   Modern Editorial Toast Notification System (Airtable / Linear Aesthetic)
   ========================================================================== */

#toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 105000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    width: 100%;
    pointer-events: none;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (max-width: 576px) {
    #toast-container {
        top: 14px;
        right: 14px;
        left: 14px;
        max-width: none;
        width: auto;
        gap: 8px;
    }
}

/* Toast Card */
.hd-toast {
    position: relative;
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 14px 16px 16px 16px;
    background: #ffffff;
    color: #181d26;
    border-radius: 12px;
    border: 1px solid rgba(24, 29, 38, 0.08);
    box-shadow: 
        0 20px 32px -8px rgba(24, 29, 38, 0.12),
        0 8px 16px -4px rgba(24, 29, 38, 0.06),
        0 1px 3px rgba(24, 29, 38, 0.04);
    overflow: hidden;
    cursor: default;
    user-select: none;
    transform: translateX(115%) scale(0.96);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), 
                opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                margin 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                padding 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 220px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.hd-toast.hd-toast-visible {
    transform: translateX(0) scale(1);
    opacity: 1;
}

.hd-toast.hd-toast-hiding {
    transform: translateX(115%) scale(0.96);
    opacity: 0;
}

.hd-toast.hd-toast-collapsed {
    max-height: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    opacity: 0 !important;
    border-width: 0 !important;
    pointer-events: none;
}

/* Icon Squircle */
.hd-toast-icon-wrap {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hd-toast:hover .hd-toast-icon-wrap {
    transform: scale(1.08);
}

.hd-toast-icon-wrap svg {
    width: 20px;
    height: 20px;
    display: block;
}

.hd-toast-icon-wrap i {
    font-size: 20px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Body Content */
.hd-toast-content {
    flex: 1;
    min-width: 0;
    padding-right: 4px;
}

.hd-toast-title {
    font-size: 13.5px;
    font-weight: 650;
    line-height: 1.35;
    margin-bottom: 3px;
    letter-spacing: -0.01em;
}

.hd-toast-msg {
    font-size: 13px;
    font-weight: 450;
    line-height: 1.45;
    color: #4b5563;
    word-break: break-word;
}

/* Close Button */
.hd-toast-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    padding: 6px;
    margin: -4px -4px 0 0;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.hd-toast-close svg {
    width: 14px;
    height: 14px;
    display: block;
}

.hd-toast-close:hover {
    color: #111827;
    background-color: rgba(0, 0, 0, 0.06);
    transform: scale(1.1);
}

/* Progress Countdown Bar */
.hd-toast-progress-track {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.05);
}

.hd-toast-progress {
    height: 100%;
    width: 100%;
    transform-origin: left;
    transition: transform linear;
    border-bottom-left-radius: 12px;
}

/* ==========================================================================
   LIGHT MODE VARIANTS (With Signature Accent Borders & Gradients)
   ========================================================================== */

/* Success */
.hd-toast-success {
    border-color: rgba(16, 185, 129, 0.25);
    border-left: 4px solid #10b981;
}
.hd-toast-success .hd-toast-icon-wrap {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.14) 0%, rgba(5, 150, 105, 0.22) 100%);
    border: 1px solid rgba(16, 185, 129, 0.32);
    color: #059669;
}
.hd-toast-success .hd-toast-title {
    color: #065f46;
}
.hd-toast-success .hd-toast-progress {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

/* Danger / Error */
.hd-toast-danger,
.hd-toast-error {
    border-color: rgba(239, 68, 68, 0.25);
    border-left: 4px solid #ef4444;
}
.hd-toast-danger .hd-toast-icon-wrap,
.hd-toast-error .hd-toast-icon-wrap {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.14) 0%, rgba(220, 38, 38, 0.22) 100%);
    border: 1px solid rgba(239, 68, 68, 0.32);
    color: #dc2626;
}
.hd-toast-danger .hd-toast-title,
.hd-toast-error .hd-toast-title {
    color: #991b1b;
}
.hd-toast-danger .hd-toast-progress,
.hd-toast-error .hd-toast-progress {
    background: linear-gradient(90deg, #f87171 0%, #dc2626 100%);
}

/* Warning */
.hd-toast-warning {
    border-color: rgba(245, 158, 11, 0.28);
    border-left: 4px solid #f59e0b;
}
.hd-toast-warning .hd-toast-icon-wrap {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.16) 0%, rgba(217, 119, 6, 0.24) 100%);
    border: 1px solid rgba(245, 158, 11, 0.34);
    color: #d97706;
}
.hd-toast-warning .hd-toast-title {
    color: #92400e;
}
.hd-toast-warning .hd-toast-progress {
    background: linear-gradient(90deg, #fbbf24 0%, #d97706 100%);
}

/* Info */
.hd-toast-info {
    border-color: rgba(37, 99, 235, 0.25);
    border-left: 4px solid #2563eb;
}
.hd-toast-info .hd-toast-icon-wrap {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.14) 0%, rgba(29, 78, 216, 0.22) 100%);
    border: 1px solid rgba(37, 99, 235, 0.32);
    color: #2563eb;
}
.hd-toast-info .hd-toast-title {
    color: #1e40af;
}
.hd-toast-info .hd-toast-progress {
    background: linear-gradient(90deg, #60a5fa 0%, #2563eb 100%);
}

/* ==========================================================================
   DARK MODE OVERRIDES ([data-bs-theme="dark"])
   (Do NOT use [data-startbar="dark"] as it styles the sidebar only)
   ========================================================================== */
[data-bs-theme="dark"] .hd-toast,
body.dark-mode .hd-toast {
    background: rgba(24, 31, 42, 0.96);
    color: #f8fafc;
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 
        0 24px 42px -6px rgba(0, 0, 0, 0.55),
        0 10px 20px -4px rgba(0, 0, 0, 0.35);
}

[data-bs-theme="dark"] .hd-toast-title,
body.dark-mode .hd-toast-title {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .hd-toast-msg,
body.dark-mode .hd-toast-msg {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .hd-toast-close,
body.dark-mode .hd-toast-close {
    color: #94a3b8;
}

[data-bs-theme="dark"] .hd-toast-close:hover,
body.dark-mode .hd-toast-close:hover {
    color: #f8fafc;
    background-color: rgba(255, 255, 255, 0.12);
}

[data-bs-theme="dark"] .hd-toast-progress-track,
body.dark-mode .hd-toast-progress-track {
    background: rgba(255, 255, 255, 0.06);
}

/* Dark Mode Variants */
[data-bs-theme="dark"] .hd-toast-success,
body.dark-mode .hd-toast-success {
    border-left-color: #34d399 !important;
}
[data-bs-theme="dark"] .hd-toast-success .hd-toast-icon-wrap,
body.dark-mode .hd-toast-success .hd-toast-icon-wrap {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.4);
    color: #34d399;
}
[data-bs-theme="dark"] .hd-toast-success .hd-toast-progress,
body.dark-mode .hd-toast-success .hd-toast-progress {
    background: #34d399;
}

[data-bs-theme="dark"] .hd-toast-danger,
[data-bs-theme="dark"] .hd-toast-error,
body.dark-mode .hd-toast-danger,
body.dark-mode .hd-toast-error {
    border-left-color: #f87171 !important;
}
[data-bs-theme="dark"] .hd-toast-danger .hd-toast-icon-wrap,
[data-bs-theme="dark"] .hd-toast-error .hd-toast-icon-wrap,
body.dark-mode .hd-toast-danger .hd-toast-icon-wrap,
body.dark-mode .hd-toast-error .hd-toast-icon-wrap {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}
[data-bs-theme="dark"] .hd-toast-danger .hd-toast-progress,
[data-bs-theme="dark"] .hd-toast-error .hd-toast-progress,
body.dark-mode .hd-toast-danger .hd-toast-progress,
body.dark-mode .hd-toast-error .hd-toast-progress {
    background: #f87171;
}

[data-bs-theme="dark"] .hd-toast-warning,
body.dark-mode .hd-toast-warning {
    border-left-color: #fbbf24 !important;
}
[data-bs-theme="dark"] .hd-toast-warning .hd-toast-icon-wrap,
body.dark-mode .hd-toast-warning .hd-toast-icon-wrap {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}
[data-bs-theme="dark"] .hd-toast-warning .hd-toast-progress,
body.dark-mode .hd-toast-warning .hd-toast-progress {
    background: #fbbf24;
}

[data-bs-theme="dark"] .hd-toast-info,
body.dark-mode .hd-toast-info {
    border-left-color: #60a5fa !important;
}
[data-bs-theme="dark"] .hd-toast-info .hd-toast-icon-wrap,
body.dark-mode .hd-toast-info .hd-toast-icon-wrap {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    color: #60a5fa;
}
[data-bs-theme="dark"] .hd-toast-info .hd-toast-progress,
body.dark-mode .hd-toast-info .hd-toast-progress {
    background: #60a5fa;
}
