/* ═══════════════════════════════════════════════════════════
   GLOBAL TOAST NOTIFICATIONS - Furobox Design System
   ═══════════════════════════════════════════════════════════ */

/* Base toast - AT TOP */
/* Base toast - AT TOP */
.furobox-toast {
    position: fixed !important;
    left: 50% !important;
    top: 24px;
    bottom: auto !important;
    transform: translateX(-50%) !important;
    z-index: 10000 !important;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 14px;
    max-width: 90%;
    animation: toastSlideDown 0.3s ease-out;
    transition: top 0.3s ease, left 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
}

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

/* Desktop - Sidebar collapsed (closed) - Center on remaining space */
@media (min-width: 769px) {
    body:not(.sidebar-open) .furobox-toast {
        /* Sidebar is 60px when collapsed */
        left: calc(50% + 30px) !important; /* Shift right by half of collapsed sidebar (60px / 2 = 30px) */
    }
}

/* Desktop - Sidebar expanded (open) - Center on remaining space */
@media (min-width: 769px) {
    body.sidebar-open .furobox-toast {
        /* Sidebar is 250px when expanded */
        left: calc(50% + 125px) !important; /* Shift right by half of expanded sidebar (250px / 2 = 125px) */
    }
}

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

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

    /* Mobile sidebar doesn't affect toast position - always centered */
    body.sidebar-open .furobox-toast,
    body:not(.sidebar-open) .furobox-toast {
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
}

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

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

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

/* Toast message text */
.toast-message {
    flex: 1;
    line-height: 1.4;
}

/* Action buttons/links */
.toast-action {
    color: inherit;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: inherit;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.toast-action:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Close button */
.toast-close {
    background: transparent;
    border: 0;
    font-size: 18px;
    line-height: 1;
    margin-left: 6px;
    cursor: pointer;
    padding: 0 4px;
    transition: opacity 0.2s ease;
    color: inherit;
    opacity: 0.7;
}

.toast-close:hover {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════
   TOAST TYPES - Different themes
   ═══════════════════════════════════════════════════════════ */

/* Guest/Default - Dark theme */
.furobox-toast-guest,
.furobox-toast-info {
    background: #111;
    color: #fff;
}

.furobox-toast-guest .toast-action,
.furobox-toast-info .toast-action {
    color: #fff;
}

/* Success - Green theme */
.furobox-toast-success {
    background: #059669;
    color: #fff;
}

.furobox-toast-success .toast-action {
    color: #fff;
}

/* Warning - Orange/Yellow theme */
.furobox-toast-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
}

.furobox-toast-warning .toast-action {
    color: #fff;
}

/* Error - Red theme */
.furobox-toast-error {
    background: #dc2626;
    color: #fff;
}

.furobox-toast-error .toast-action {
    color: #fff;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE - Mobile
   ═══════════════════════════════════════════════════════════ */

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

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

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

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

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

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

/* ═══════════════════════════════════════════════════════════
   STACKING (when multiple toasts) - DYNAMIC POSITIONING
   ═══════════════════════════════════════════════════════════ */

/* Positions are now set dynamically by JavaScript */
/* No need for nth-of-type rules anymore */

/* Add subtle shadow to distinguish stacked toasts */
.furobox-toast ~ .furobox-toast {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25),
                0 -2px 8px rgba(0, 0, 0, 0.1);
}

/* Smooth transition when toasts reposition */
.furobox-toast {
    transition: top 0.3s ease, left 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
}

/* Override any safe area adjustments for stacking - JS handles this now */
@supports (padding: max(0px)) {
    .furobox-toast {
        /* First toast respects safe area */
        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 currentColor;
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .furobox-toast {
        border: 2px solid currentColor;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .furobox-toast {
        animation: none;
    }

    .furobox-toast {
        transition: left 0s, transform 0s, opacity 0.3s ease;
    }
}

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

/* Override any old .guest-toast or #modelSwitchToast styles */
.guest-toast,
#modelSwitchToast,
#guestToast,
#genericToast {
    top: 24px !important;
    bottom: auto !important;
}

/* Desktop - old toasts also adjust for sidebar */
@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;
    }
}

/* Mobile - old toasts stay centered */
@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
   ======================================== */

/* Dim the page slightly when offline */
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;
}

/* Style disabled elements when offline */
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;
}

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