/**
 * Toast Notifications & Loading States
 * Provides visual feedback for errors, success, and loading
 */

/* ==================== TOAST NOTIFICATIONS ==================== */

/* Legacy toasts still fired by utils.js global error handlers (network / storage
 * / uncaught). Kept on-system (cream card, hairline, ink text) so an error never
 * throws the old neon Bootstrap slab in a different corner from the real toasts. */
.error-toast,
.success-toast {
    position: fixed;
    top: 80px;
    right: 24px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #F6F4EE;
    border: 1px solid var(--b2-line-2, #D1D5DB);
    box-shadow: 0 3px 10px rgba(17, 18, 22, 0.07), 0 1px 2px rgba(17, 18, 22, 0.04);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--b2-ink, #111216);
    max-width: 400px;
    z-index: 10001;   /* one above the live .toast stack (now the same corner) so it never hides under it */
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.2, 0, 0, 1);
    pointer-events: none;
}

.error-toast.show,
.success-toast.show {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* One accent moment, matching the main toast's tinted-glyph logic. */
.error-toast { color: var(--b2-err, #DC2626); }
.success-toast { color: var(--b2-ink, #111216); }

/* ==================== LOADING STATES ==================== */

.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 14px;
    animation: none;
}

/* While a panel is loading, hide its existing children so the user only
   sees the centered "Loading..." overlay — never the previous
   conversation's stale tree dimmed at opacity 0.6, and never a brief
   "No files yet" / "No case files available" flash before the real
   data lands. ::after stays visible because it's a pseudo-element
   (not a child) and is what we want to show. */
.loading > * {
    visibility: hidden;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Button loading state */
button.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

button.loading::before {
    content: '...';
    display: inline-block;
    margin-right: 4px;
    animation: none;
}

/* ==================== PAGE LOADER ==================== */

.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.page-loader.show {
    opacity: 1;
    visibility: visible;
}

.loader-spinner {
    color: #666;
    font-size: 16px;
    animation: none;
}

/* ==================== SKELETON LOADING ==================== */

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin: 8px 0;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin: 12px 0;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* ==================== DISABLED STATE ==================== */

[aria-busy="true"] {
    cursor: wait;
    opacity: 0.6;
}

.disabled,
[disabled] {
    opacity: 0.5;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* ==================== SCREEN READER ONLY ==================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
