/* ═══════════════════════════════════════════════════════════
   GLOBAL TOAST NOTIFICATIONS - Furobox Design System
   Matches mobile app: dark glass pill, blur, colored dot accent
   ═══════════════════════════════════════════════════════════ */

/* Base toast */
.furobox-toast {
    position: fixed !important;
    left: 50% !important;
    top: 24px;
    bottom: auto !important;
    transform: translateX(-50%) !important;
    z-index: 10000 !important;

    /* Glass pill — matches Flutter mobile */
    border-radius: 40px;
    padding: 11px 16px;
    background: rgba(0, 0, 0, 0.82) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.20) !important;
    color: #ffffff !important;

    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    max-width: 420px;
    min-width: 200px;

    animation: toastSlideDown 0.28s ease-out;
    transition: top 0.28s ease, left 0.28s ease, transform 0.28s ease, opacity 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════
   ALL TYPES — same dark glass base, only dot color differs
   ═══════════════════════════════════════════════════════════ */

.furobox-toast-guest,
.furobox-toast-info,
.furobox-toast-success,
.furobox-toast-warning,
.furobox-toast-error {
    background: rgba(0, 0, 0, 0.82) !important;
    color: #ffffff !important;
}

/* ═══════════════════════════════════════════════════════════
   TOAST CONTENT ELEMENTS
   ═══════════════════════════════════════════════════════════ */

.toast-message {
    flex: 1;
    line-height: 1.4;
    color: #ffffff;
    font-size: 13px;
}

.toast-action {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.toast-action:hover {
    opacity: 0.8;
}

.toast-close {
    background: transparent;
    border: 0;
    font-size: 14px;
    line-height: 1;
    margin-left: 2px;
    cursor: pointer;
    padding: 2px 4px;
    transition: opacity 0.2s ease;
    color: rgba(255, 255, 255, 0.45);
    opacity: 1;
    flex-shrink: 0;
}

.toast-close:hover {
    color: rgba(255, 255, 255, 0.9);
}

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════ */

@keyframes toastSlideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR ADJUSTMENTS - Desktop only
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 769px) {
    body:not(.sidebar-open) .furobox-toast {
        left: calc(50% + 30px) !important;
    }
}

@media (min-width: 769px) {
    body.sidebar-open .furobox-toast {
        left: calc(50% + 125px) !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE - Always centered
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .furobox-toast {
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    body.sidebar-open .furobox-toast,
    body:not(.sidebar-open) .furobox-toast {
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
}

@media (max-width: 576px) {
    .furobox-toast {
        top: 16px;
        bottom: auto !important;
        font-size: 12px;
        padding: 10px 14px;
        max-width: calc(100% - 32px);
    }

    .toast-message {
        font-size: 12px;
    }

    .toast-close {
        font-size: 13px;
    }
}

/* ═══════════════════════════════════════════════════════════
   SAFE AREA INSETS (notched devices)
   ═══════════════════════════════════════════════════════════ */

@supports (padding: max(0px)) {
    .furobox-toast:first-of-type {
        top: max(24px, env(safe-area-inset-top));
    }

    @media (max-width: 576px) {
        .furobox-toast:first-of-type {
            top: max(16px, env(safe-area-inset-top));
        }
    }
}

/* ═══════════════════════════════════════════════════════════
   STACKING — dynamic positioning via JS
   ═══════════════════════════════════════════════════════════ */

.furobox-toast ~ .furobox-toast {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.20),
                0 -2px 8px rgba(0, 0, 0, 0.08);
}

@supports (padding: max(0px)) {
    .furobox-toast {
        top: max(24px, env(safe-area-inset-top));
    }

    @media (max-width: 576px) {
        .furobox-toast {
            top: max(16px, env(safe-area-inset-top));
        }
    }
}

/* ═══════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════ */

.furobox-toast:focus-within {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

@media (prefers-contrast: high) {
    .furobox-toast {
        border: 1px solid rgba(255, 255, 255, 0.4);
    }
}

@media (prefers-reduced-motion: reduce) {
    .furobox-toast {
        animation: none;
        transition: left 0s, transform 0s, opacity 0.3s ease;
    }
}

/* ═══════════════════════════════════════════════════════════
   OVERRIDE OLD TOAST STYLES (backward compatibility)
   ═══════════════════════════════════════════════════════════ */

.guest-toast,
#modelSwitchToast,
#guestToast,
#genericToast {
    top: 24px !important;
    bottom: auto !important;
}

@media (min-width: 769px) {
    body:not(.sidebar-open) .guest-toast,
    body:not(.sidebar-open) #modelSwitchToast,
    body:not(.sidebar-open) #guestToast,
    body:not(.sidebar-open) #genericToast {
        left: calc(50% + 30px) !important;
    }

    body.sidebar-open .guest-toast,
    body.sidebar-open #modelSwitchToast,
    body.sidebar-open #guestToast,
    body.sidebar-open #genericToast {
        left: calc(50% + 125px) !important;
    }
}

@media (max-width: 768px) {
    .guest-toast,
    #modelSwitchToast,
    #guestToast,
    #genericToast {
        left: 50% !important;
        transform: translateX(-50%) !important;
        top: 16px !important;
        bottom: auto !important;
    }
}

/* ========================================
   OFFLINE STATE STYLING
   ======================================== */

body.app-offline::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.03);
    pointer-events: none;
    z-index: 9998;
}

body.app-offline button:not(.toast-close):not(.toast-action):not(.btn-close),
body.app-offline .icon-btn,
body.app-offline .icon-btn1 {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

body.app-offline button[type="submit"]::after,
body.app-offline .icon-btn1::after {
    content: '[WARN]';
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 12px;
}
