body {
    background: #f7f8fb;
}

.hero-card {
    border: 0;
    border-radius: 1.25rem;
    background: linear-gradient(135deg, #0d6efd 0%, #4f8cff 45%, #7ca7ff 100%);
    color: #fff;
}

.card {
    border-radius: 1rem;
}

.context-box {
    white-space: pre-wrap;
    max-height: 220px;
    overflow: auto;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: .75rem;
    padding: .75rem;
}

.answer-box {
    white-space: pre-wrap;
}

.badge-soft {
    background: #eef4ff;
    color: #0d6efd;
}

.document-list-scroll {
    max-height: 360px;
    overflow-y: auto;
    overflow-x: hidden;
}

.document-list-scroll .fw-semibold,
.document-list-scroll .small {
    overflow-wrap: anywhere;
}

@media (min-width: 992px) {
    .document-list-scroll {
        max-height: 520px;
    }
}



.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(6px);
}

.loading-panel {
    width: min(760px, 100%);
    min-height: 430px;
    border-radius: 1.5rem;
    background: #ffffff;
    padding: 2rem;
    text-align: center;
}

.loading-spinner {
    width: 5.5rem;
    height: 5.5rem;
    margin: 0 auto;
    border: .55rem solid #e9ecef;
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: loading-spin .9s linear infinite;
}

.loading-progress {
    height: 2.1rem;
    border-radius: 999px;
    overflow: hidden;
    background: #e9ecef;
}

.loading-progress .progress-bar {
    font-weight: 700;
    transition: width .5s ease;
}


#loadingStepText {
    display: block;
    min-height: 2.6rem;
    line-height: 1.3rem;
}

.loading-note {
    border-radius: .85rem;
    background: #f8f9fa;
    color: #6c757d;
    padding: .85rem 1rem;
}

body.loading-active {
    overflow: hidden;
}

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

@media (min-width: 768px) {
    .loading-panel {
        padding: 2.75rem;
    }
}

/* =======================
   Document Management Search
   ======================= */
.document-library-page {
    background: #f3f6fb;
    color: #172033;
}

.library-hero {
    border: 1px solid #dfe7f3;
    border-radius: 1.5rem;
    padding: clamp(1.5rem, 3vw, 3rem);
    background:
        radial-gradient(circle at top right, rgba(13, 110, 253, .13), transparent 34%),
        linear-gradient(135deg, #ffffff 0%, #f7faff 100%);
}

.library-kicker {
    color: #0d6efd;
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .14em;
}

.library-search-shell {
    border: 1px solid #dfe7f3;
    border-radius: 1.25rem;
    background: #fff;
    padding: 1.25rem;
}

.library-search-shell .input-group-text,
.library-search-shell .form-control,
.library-search-shell .form-select,
.library-search-shell .btn {
    min-height: 46px;
}

.library-search-shell .form-control:focus {
    box-shadow: none;
    border-color: #dee2e6;
}

.library-stat-card {
    border: 1px solid #dfe7f3;
    border-radius: 1rem;
    background: #fff;
    padding: 1.1rem 1.25rem;
}

.library-stat-label {
    color: #6b7588;
    font-size: .82rem;
    font-weight: 600;
}

.library-stat-value {
    margin-top: .25rem;
    color: #172033;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
}

.library-results-shell {
    overflow: hidden;
    border: 1px solid #dfe7f3;
    border-radius: 1.25rem;
    background: #fff;
}

.library-results-header {
    padding: 1.2rem 1.4rem;
    border-bottom: 1px solid #e8edf5;
    background: #fbfcfe;
}

.document-result-row {
    display: flex;
    gap: 1rem;
    padding: 1.3rem 1.4rem;
    border-bottom: 1px solid #edf1f6;
}

.document-result-row:last-child {
    border-bottom: 0;
}

.document-result-row:hover {
    background: #fafcff;
}

.document-file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    width: 48px;
    height: 58px;
    border-radius: .65rem;
    background: #fff0f0;
    color: #c62828;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
}

.document-result-content,
.min-w-0 {
    min-width: 0;
}

.document-result-content {
    flex: 1;
}

.document-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem 1.1rem;
}

.document-meta-row span {
    position: relative;
}

.document-meta-row span:not(:last-child)::after {
    content: "•";
    position: absolute;
    right: -.7rem;
    color: #b0b8c6;
}

.document-snippet {
    max-width: 1050px;
    border-left: 3px solid #9ec5fe;
    border-radius: .25rem .65rem .65rem .25rem;
    background: #f7faff;
    color: #4f5b70;
    padding: .8rem 1rem;
    font-size: .9rem;
    line-height: 1.55;
}

.library-empty-state {
    padding: 4rem 1.5rem;
    text-align: center;
}

.library-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 86px;
    margin: 0 auto 1.25rem;
    border-radius: .9rem;
    background: #eef4ff;
    color: #0d6efd;
    font-weight: 800;
}

@media (max-width: 767.98px) {
    .document-result-row {
        padding: 1rem;
    }

    .document-file-icon {
        flex-basis: 40px;
        width: 40px;
        height: 50px;
    }

    .document-actions {
        width: 100%;
    }
}
