/* Critical first-paint shell for QChat session restore.
   This stylesheet is intentionally tiny and loaded before the preload script,
   so the loading surface is already positioned before the body can paint. */

#qchatBootLoading {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10050;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 1.25rem;
    background: #fff;
    color: #212529;
}

html.qchat-session-restore-pending #qchatBootLoading,
html[data-qchat-session-restore-pending="1"] #qchatBootLoading {
    display: flex;
}

#qchatBootLoading[hidden] {
    display: none !important;
}

.qchat-boot-loading-card {
    box-sizing: border-box;
    width: min(92vw, 360px);
    padding: 1.75rem 1.5rem;
    text-align: center;
}

.qchat-boot-loading-logo {
    display: inline-flex;
    min-height: 2rem;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0 0 1.25rem;
    font: 600 1.65rem/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #0d6efd;
}

.qchat-boot-loading-logo-icon {
    display: block;
    width: 2rem;
    height: 2rem;
    flex: 0 0 2rem;
}

.qchat-boot-loading-spinner {
    display: block;
    box-sizing: border-box;
    width: 2rem;
    height: 2rem;
    margin: 0 auto 1rem;
    border: 0.25rem solid rgba(13, 110, 253, 0.22);
    border-right-color: #0d6efd;
    border-radius: 50%;
    animation: qchat-boot-spin 0.75s linear infinite;
}

.qchat-boot-loading-title {
    font: 600 1rem/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #212529;
}

.qchat-boot-loading-detail {
    min-height: 1.25rem;
    margin-top: 0.35rem;
    font: 400 0.875rem/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #6c757d;
}

html.qchat-session-restore-pending #authSection,
html[data-qchat-session-restore-pending="1"] #authSection {
    display: none !important;
    visibility: hidden !important;
}

@keyframes qchat-boot-spin {
    to { transform: rotate(360deg); }
}

html[data-qchat-boot-theme="dark"] #qchatBootLoading {
    background: #0d1117;
    color: #f8f9fa;
}

html[data-qchat-boot-theme="dark"] .qchat-boot-loading-title {
    color: #f8f9fa;
}

html[data-qchat-boot-theme="dark"] .qchat-boot-loading-detail {
    color: #adb5bd;
}

@media (prefers-color-scheme: dark) {
    html:not([data-qchat-boot-theme="light"]):not([data-qchat-boot-theme="dark"]) #qchatBootLoading,
    html[data-qchat-boot-theme="auto"] #qchatBootLoading {
        background: #0d1117;
        color: #f8f9fa;
    }

    html:not([data-qchat-boot-theme="light"]):not([data-qchat-boot-theme="dark"]) .qchat-boot-loading-title,
    html[data-qchat-boot-theme="auto"] .qchat-boot-loading-title {
        color: #f8f9fa;
    }

    html:not([data-qchat-boot-theme="light"]):not([data-qchat-boot-theme="dark"]) .qchat-boot-loading-detail,
    html[data-qchat-boot-theme="auto"] .qchat-boot-loading-detail {
        color: #adb5bd;
    }
}

@media (prefers-reduced-motion: reduce) {
    .qchat-boot-loading-spinner {
        animation-duration: 1.5s;
    }
}
