/*
 * Finished module application-theme bridge.
 *
 * Presentation only. Build/deploy endpoints, action identifiers, readiness
 * state, history persistence and generated output remain unchanged.
 */

body.finished-body {
    --fin-bg: var(--pp-app-bg, #f5f6fa);
    --fin-surface: var(--pp-surface, #ffffff);
    --fin-raised: var(--pp-surface-raised, #ffffff);
    --fin-soft: var(--pp-surface-soft, #f8fafc);
    --fin-muted-surface: var(--pp-surface-muted, #f1f5f9);
    --fin-border: var(--pp-border, #dbe3ee);
    --fin-border-strong: var(--pp-border-strong, #c7d2e0);
    --fin-text: var(--pp-text, #172033);
    --fin-muted: var(--pp-text-muted, #64748b);
    --fin-shadow: 0 8px 24px var(--pp-shadow-color, rgba(15, 23, 42, .10));
    color-scheme: light;
}

html[data-pp-theme="dark"] body.finished-body { color-scheme: dark; }

body.finished-body .right-workspace {
    min-width: 0;
    min-height: 0;
    background: var(--fin-bg);
    color: var(--fin-text);
}
body.finished-body .finished-toolbar {
    box-sizing: border-box;
    min-height: 54px;
    background: var(--fin-surface);
    border-color: var(--fin-border);
    color: var(--fin-text);
}
body.finished-body .finished-toolbar h6 { color: var(--fin-text); }
/* Guide button (matches the module's accent, works in light + dark) */
body.finished-body .fin-guide-btn {
    display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
    padding: 5px 12px; border-radius: 9px; cursor: pointer;
    font-size: 12.5px; font-weight: 600;
    color: var(--pp-accent, #059669);
    background: color-mix(in srgb, var(--pp-accent, #059669) 12%, var(--fin-surface));
    border: 1px solid color-mix(in srgb, var(--pp-accent, #059669) 35%, var(--fin-border));
    transition: .15s;
}
body.finished-body .fin-guide-btn:hover {
    background: var(--pp-accent, #059669);
    border-color: var(--pp-accent, #059669);
    color: var(--pp-accent-contrast, #fff);
}
body.finished-body :is(.text-muted, .card-text, .stat-label, .health-value) { color: var(--fin-muted) !important; }

body.finished-body .finished-content {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    background: var(--fin-bg);
}
/* Readiness banner keeps semantic meaning in both colour modes. */
body.finished-body .status-banner {
    border: 1px solid var(--fin-border);
    color: var(--fin-text);
    box-shadow: 0 2px 8px var(--pp-shadow-color, rgba(15, 23, 42, .06));
}
body.finished-body .status-banner.healthy { background: #ecfdf5; border-color: #a7f3d0; border-left-color: #10b981; }
body.finished-body .status-banner.warning { background: #fffbeb; border-color: #fde68a; border-left-color: #f59e0b; }
body.finished-body .status-banner.failed { background: #fef2f2; border-color: #fecaca; border-left-color: #ef4444; }
body.finished-body .status-banner.never { background: var(--fin-soft); border-color: var(--fin-border); border-left-color: #64748b; }
html[data-pp-theme="dark"] body.finished-body .status-banner.healthy { background: #102a25; border-color: #1d5b4d; border-left-color: #34d399; }
html[data-pp-theme="dark"] body.finished-body .status-banner.warning { background: #302711; border-color: #66551c; border-left-color: #fbbf24; }
html[data-pp-theme="dark"] body.finished-body .status-banner.failed { background: #341a22; border-color: #69303b; border-left-color: #fb7185; }

body.finished-body .stat-card {
    height: 100%;
    background: var(--fin-surface);
    border-color: var(--fin-border);
    color: var(--fin-text);
    box-shadow: 0 2px 7px var(--pp-shadow-color, rgba(15, 23, 42, .05));
}
body.finished-body .stat-card .stat-value { color: var(--fin-text); }

body.finished-body .action-card {
    min-height: 84px;
    height: 100%;
    background: var(--fin-surface);
    border-color: var(--fin-border);
    color: var(--fin-text) !important;
    box-shadow: 0 2px 7px var(--pp-shadow-color, rgba(15, 23, 42, .05));
}
body.finished-body .action-card:hover {
    background: var(--fin-raised);
    border-color: #60a5fa;
    box-shadow: var(--fin-shadow);
}
body.finished-body .action-card:focus-visible {
    outline: 3px solid rgba(59, 130, 246, .32);
    outline-offset: 2px;
}
body.finished-body .action-card .card-icon {
    display: inline-flex;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: var(--fin-soft);
}
body.finished-body .action-card .card-title { color: var(--fin-text); }

body.finished-body .finished-content .card {
    overflow: hidden;
    background: var(--fin-surface);
    border-color: var(--fin-border);
    color: var(--fin-text);
    box-shadow: 0 4px 14px var(--pp-shadow-color, rgba(15, 23, 42, .07)) !important;
}
body.finished-body .finished-content .card-header {
    min-height: 46px;
    background: var(--fin-soft);
    border-color: var(--fin-border);
    color: var(--fin-text);
}
body.finished-body .finished-section-toggle {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 2px;
    border: 0;
    background: transparent;
    color: var(--fin-text);
    font-size: .875rem;
    font-weight: 650;
    text-align: left;
}
body.finished-body .finished-section-toggle:hover { color: #2563eb; }
body.finished-body .finished-section-toggle:focus-visible {
    border-radius: 6px;
    outline: 3px solid rgba(59, 130, 246, .3);
    outline-offset: 2px;
}
body.finished-body .finished-section-chevron {
    flex: 0 0 auto;
    color: var(--fin-muted);
    font-size: 12px;
    transition: transform .2s ease;
}
body.finished-body .finished-section-toggle[aria-expanded="true"] .finished-section-chevron {
    transform: rotate(180deg);
}
body.finished-body .finished-clear-btn { flex: 0 0 auto; margin-left: 8px; }
body.finished-body :is(#buildHistoryPanel, #systemHealthPanel) { border-top: 1px solid var(--fin-border); }
body.finished-body .finished-content .card-body,
body.finished-body .table-responsive { background: var(--fin-surface); }
body.finished-body #historyTable {
    --bs-table-bg: var(--fin-surface);
    --bs-table-color: var(--fin-text);
    --bs-table-border-color: var(--fin-border);
    --bs-table-hover-bg: var(--fin-soft);
    --bs-table-hover-color: var(--fin-text);
    color: var(--fin-text);
}
body.finished-body #historyTable :is(th, td) { border-color: var(--fin-border); }
body.finished-body #historyTable thead,
body.finished-body #historyTable thead th { background: var(--fin-soft) !important; color: var(--fin-text) !important; }
body.finished-body #historyTable .badge.bg-light {
    background: var(--fin-muted-surface) !important;
    color: var(--fin-text) !important;
    border: 1px solid var(--fin-border);
}

body.finished-body .health-item { border-color: var(--fin-border); color: var(--fin-text); }
body.finished-body .health-name { color: var(--fin-text); }
body.finished-body code {
    background: var(--fin-muted-surface);
    color: #4f46e5;
    border-radius: 5px;
    padding: 1px 5px;
}
html[data-pp-theme="dark"] body.finished-body code { color: #c4b5fd; }

body.finished-body .action-overlay {
    background: color-mix(in srgb, var(--fin-bg) 76%, transparent);
    backdrop-filter: blur(3px);
}
body.finished-body #actionFeedback .toast {
    border: 1px solid rgba(255, 255, 255, .16) !important;
    box-shadow: 0 12px 28px var(--pp-shadow-color, rgba(15, 23, 42, .24));
}

/* SweetAlert is outside .finished-content but still belongs to this module. */
body.finished-body .swal2-popup {
    background: var(--fin-raised);
    color: var(--fin-text);
    border: 1px solid var(--fin-border);
}
body.finished-body :is(.swal2-title, .swal2-html-container) { color: var(--fin-text); }
body.finished-body .swal2-html-container .text-muted { color: var(--fin-muted) !important; }

@media (max-width: 767.98px) {
    body.finished-body .finished-content { padding: 12px !important; }
    body.finished-body .action-card { min-height: 76px; }
    body.finished-body .action-card .card-body { padding: .55rem .65rem; }
    body.finished-body .action-card .card-text { line-height: 1.25; }
}

@media (max-width: 480px) {
    body.finished-body .finished-content .col-6 { width: 100%; }
    body.finished-body #actionFeedback { right: .6rem; bottom: .6rem; left: .6rem; max-width: none; }
}

/* ── Pre-build gate: event-error report (blocks a broken build) ──────────── */
.pbg-ov { position: fixed; inset: 0; z-index: 10090; display: flex; align-items: center; justify-content: center;
    background: rgba(8, 12, 20, .55); backdrop-filter: blur(3px); padding: 1rem; }
.pbg-panel { width: min(680px, 100%); max-height: min(82vh, 760px); display: flex; flex-direction: column;
    background: var(--fin-raised, var(--pp-surface-raised, #fff)); color: var(--fin-text, var(--pp-text, #1e293b));
    border: 1px solid var(--fin-border, var(--pp-border, #e2e8f0)); border-radius: 16px; overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.pbg-head { display: flex; align-items: flex-start; gap: .8rem; padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--fin-border, var(--pp-border, #e2e8f0)); }
.pbg-ic { flex: 0 0 auto; width: 2.6rem; height: 2.6rem; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem;
    background: color-mix(in srgb, #d97706 16%, transparent); color: #d97706; }
.pbg-head h2 { font-size: 1.05rem; font-weight: 800; margin: 0; }
.pbg-head p { margin: .15rem 0 0; font-size: .82rem; color: var(--fin-muted, var(--pp-text-muted, #64748b)); }
.pbg-x { margin-left: auto; border: 0; background: transparent; color: var(--fin-muted, #94a3b8); cursor: pointer; padding: 4px 8px; border-radius: 8px; font-size: 1rem; }
.pbg-x:hover { background: var(--fin-soft, var(--pp-surface-soft, #f1f5f9)); }
.pbg-body { overflow-y: auto; padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: .6rem; }
.pbg-card { border: 1px solid var(--fin-border, var(--pp-border, #e2e8f0)); border-radius: 12px; overflow: hidden; }
.pbg-card-head { display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem;
    background: var(--fin-soft, var(--pp-surface-soft, #f1f5f9)); font-size: .9rem; }
.pbg-lang { font-size: .64rem; font-weight: 800; letter-spacing: .04em; border-radius: 5px; padding: 1px 6px;
    background: color-mix(in srgb, var(--pp-accent, #4f46e5) 16%, transparent); color: var(--pp-accent, #4f46e5); }
.pbg-lang.js { background: color-mix(in srgb, #d97706 18%, transparent); color: #b45309; }
.pbg-diag { display: flex; align-items: flex-start; gap: 8px; padding: .5rem .8rem; font-size: .84rem;
    border-top: 1px solid color-mix(in srgb, var(--fin-border, #e2e8f0) 55%, transparent); }
.pbg-diag i { color: #dc2626; margin-top: 1px; }
.pbg-loc { color: var(--fin-muted, #94a3b8); font-size: .74rem; font-weight: 600; white-space: nowrap; }
.pbg-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .8rem 1.2rem;
    border-top: 1px solid var(--fin-border, var(--pp-border, #e2e8f0)); flex-wrap: wrap; }
