/* The loading overlay's rules (LoadingOverlay.razor). Global, not scoped: scoped CSS would add the scope attribute to
   the overlay's markup, which the Workspace goldens record. index.html links this file after app.css and
   spreadsheet.css, the order the rules had in app.css. */

/* ========== Loading Overlay ========== */
@keyframes loading-overlay-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes loading-overlay-spin {
    to { transform: rotate(360deg); }
}

/* Compact engineering-style loading experience. */
.loading-overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 99999;
    backdrop-filter: blur(3px);
    animation: loading-overlay-fadein 0.2s ease-out;
}

.loading-overlay-card {
    width: min(760px, calc(100vw - 48px));
    min-width: 0;
    max-width: none;
    max-height: min(680px, calc(100vh - 48px));
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    color: #17233c;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.3);
    animation: loading-overlay-slidein 0.2s ease-out;
}

@keyframes loading-overlay-slidein {
    from { opacity: 0; transform: translateY(8px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.loading-overlay-header {
    min-height: 84px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
    background: linear-gradient(115deg, #10213f 0%, #152c4e 100%);
}

.loading-overlay-file-icon {
    width: 44px;
    height: 48px;
    flex: 0 0 44px;
    display: grid;
    place-items: center;
    color: #73d7df;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 9px;
}

.loading-overlay-file-icon svg {
    width: 27px;
    height: 31px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.loading-overlay-heading {
    min-width: 0;
    flex: 1;
}

.loading-overlay-title {
    margin: 0;
    color: #fff;
    font-size: 1.08rem;
    line-height: 1.3;
    font-weight: 650;
    text-align: left;
}

.loading-overlay-subtitle {
    margin: 4px 0 0;
    overflow: hidden;
    color: #b8c7db;
    font-size: 0.82rem;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading-overlay-phase-counter {
    flex: 0 0 auto;
    color: #d5deea;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}

.loading-overlay-phases {
    display: flex;
    align-items: flex-start;
    margin: 0;
    padding: 20px 38px 18px;
    list-style: none;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.loading-overlay-phase {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    color: #7b8798;
    font-size: 0.75rem;
    text-align: center;
}

.loading-overlay-phase::before {
    content: "";
    position: absolute;
    z-index: 0;
    top: 13px;
    right: 50%;
    width: 100%;
    height: 2px;
    background: #d5dce5;
    transform: translateY(-50%);
}

.loading-overlay-phase:first-child::before {
    display: none;
}

.loading-overlay-phase.completed::before,
.loading-overlay-phase.active::before {
    background: #38a169;
}

.loading-overlay-phase-marker {
    position: relative;
    z-index: 1;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    color: #697586;
    background: #fff;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 650;
}

.loading-overlay-phase-marker svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.loading-overlay-phase.completed .loading-overlay-phase-marker {
    color: #fff;
    background: #38a169;
    border-color: #38a169;
}

.loading-overlay-phase.completed .loading-overlay-phase-label {
    color: #334155;
}

.loading-overlay-phase.active {
    color: #087c8c;
    font-weight: 600;
}

.loading-overlay-phase.active .loading-overlay-phase-marker {
    color: #fff;
    background: #168da0;
    border-color: #168da0;
    box-shadow: 0 0 0 4px rgba(22, 141, 160, 0.12);
}

.loading-overlay-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 24px;
    padding: 22px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.loading-overlay-status-panel {
    min-width: 0;
}

.loading-overlay-status {
    margin: 0 0 13px;
    color: #17233c;
    font-size: 1rem;
    line-height: 1.35;
    font-weight: 650;
    text-align: left;
}

.loading-overlay-progress {
    width: 100%;
    display: block;
}

.loading-overlay-progress-bar {
    width: 100%;
    height: 7px;
    overflow: hidden;
    background: #e3e8ef;
    border-radius: 999px;
}

.loading-overlay-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1593a4, #27a8b8);
    background-size: 180% 100%;
    border-radius: inherit;
    transition: width 0.35s ease-out;
    animation: loading-overlay-progress-pulse 1.8s ease-in-out infinite;
}

@keyframes loading-overlay-progress-pulse {
    0%, 100% { background-position: 0 0; }
    50% { background-position: 100% 0; }
}

.loading-overlay-progress-text {
    display: block;
    min-width: 0;
    margin-top: 7px;
    color: #718096;
    font-size: 0.72rem;
    text-align: left;
}

.loading-overlay-metrics {
    display: flex;
    gap: 10px;
}

.loading-overlay-metric {
    min-width: 92px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 24px 1fr;
    grid-template-rows: auto auto;
    column-gap: 7px;
    background: #f8fafc;
    border: 1px solid #d8e0e8;
    border-radius: 9px;
}

.loading-overlay-metric-icon {
    grid-row: 1 / 3;
    align-self: center;
    color: #168da0;
}

.loading-overlay-metric-icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.loading-overlay-metric-value {
    color: #17233c;
    font-size: 0.95rem;
    line-height: 1.1;
    font-weight: 700;
}

.loading-overlay-metric-label {
    margin-top: 3px;
    color: #667085;
    font-size: 0.68rem;
    line-height: 1.1;
}

.loading-overlay-activity {
    min-height: 0;
    background: #fff;
}

.loading-overlay-items {
    width: 100%;
    padding: 0;
    margin: 0;
    max-height: 220px;
    overflow-y: auto;
    list-style: none;
}

.loading-overlay-item {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 24px;
    color: #475569;
    font-size: 0.78rem;
    border-bottom: 1px solid #edf0f4;
}

.loading-overlay-item > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading-overlay-item.completed {
    color: #475569;
}

.loading-overlay-item-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    display: grid;
    place-items: center;
    color: #2f9e5b;
    border: 1.5px solid currentColor;
    border-radius: 50%;
}

.loading-overlay-item-icon svg {
    width: 13px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.loading-overlay-item.active {
    color: #087c8c;
    font-weight: 600;
}

.loading-overlay-item-spinner {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 2px dotted #168da0;
    border-radius: 50%;
    animation: loading-overlay-spin 0.8s linear infinite;
}

.loading-overlay-footer {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 20px;
    background: #fbfcfd;
}

.loading-overlay-details-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 5px;
    color: #087c8c;
    background: transparent;
    border: 0;
    font: inherit;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
}

.loading-overlay-details-button:hover {
    color: #075e6b;
}

.loading-overlay-details-button:focus-visible {
    outline: 2px solid #168da0;
    outline-offset: 2px;
    border-radius: 4px;
}

.loading-overlay-details-button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    transition: transform 0.2s ease;
}

.loading-overlay-details-button svg.expanded {
    transform: rotate(180deg);
}

@media (max-width: 720px) {
    .loading-overlay-backdrop { padding: 12px; }
    .loading-overlay-card {
        width: min(100%, 620px);
        max-height: calc(100vh - 24px);
    }
    .loading-overlay-header { padding: 14px 16px; }
    .loading-overlay-phases { padding: 17px 14px 15px; }
    .loading-overlay-phase-label { font-size: 0.65rem; }
    .loading-overlay-body {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 18px 16px;
    }
    .loading-overlay-metrics { overflow-x: auto; }
    .loading-overlay-metric { flex: 1 0 92px; }
    .loading-overlay-item { padding-inline: 16px; }
}

@media (max-width: 480px) {
    .loading-overlay-file-icon { display: none; }
    .loading-overlay-phase-counter {
        align-self: flex-start;
        font-size: 0.7rem;
    }
    .loading-overlay-phase-label {
        overflow: hidden;
        max-width: 52px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .loading-overlay-backdrop,
    .loading-overlay-card,
    .loading-overlay-item-spinner,
    .loading-overlay-progress-fill {
        animation: none;
    }
    .loading-overlay-progress-fill,
    .loading-overlay-details-button svg {
        transition: none;
    }
}
