/*
 * SYSTEM BROADCASTS - the popup (wwwroot/js/components/systemBroadcast.js).
 * Scoped to .c5c-sysbc; follows FrontendThemeStyleGuide.md: Bootstrap tokens for surfaces and text, the brand
 * magenta in both themes, [data-bs-theme="dark"] for the dark surface. Loaded by _Layout, _LayoutApp and the
 * FiveRoom window.
 */

.c5c-sysbc {
    --sysbc-accent: #970250;
    --sysbc-accent-2: #c2185b;
    --sysbc-surface: var(--bs-body-bg, #fff);
    --sysbc-text: var(--bs-body-color, #212529);
    --sysbc-muted: #6c757d;
    --sysbc-border: var(--bs-border-color, #dee2e6);
    --sysbc-soft: rgba(151, 2, 80, 0.1);
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    font-family: inherit;
}

.c5c-sysbc[hidden] {
    display: none !important;
}

/* The app pages (_LayoutApp) are always dark and set no theme attribute. */
[data-bs-theme="dark"] .c5c-sysbc,
body.dark-mode .c5c-sysbc,
body.app-body .c5c-sysbc {
    --sysbc-surface: #202020;
    --sysbc-text: #e9ecef;
    --sysbc-muted: #9aa0a6;
    --sysbc-border: rgba(255, 255, 255, 0.12);
}

.c5c-sysbc-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 6, 10, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.22s ease;
}

.c5c-sysbc-dialog {
    position: relative;
    width: min(560px, 100%);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--sysbc-surface);
    color: var(--sysbc-text);
    border: 1px solid var(--sysbc-border);
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(151, 2, 80, 0.08);
    opacity: 0;
    transform: translateY(18px) scale(0.97);
    transition: opacity 0.22s ease, transform 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

/* The accent bar on top and the soft glow behind the header. */
.c5c-sysbc-dialog::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 5px;
    background: linear-gradient(90deg, var(--sysbc-accent), var(--sysbc-accent-2));
}

.c5c-sysbc-glow {
    position: absolute;
    top: -120px;
    left: -60px;
    width: 320px;
    height: 240px;
    background: radial-gradient(closest-side, var(--sysbc-soft), transparent);
    pointer-events: none;
}

.c5c-sysbc.is-open .c5c-sysbc-backdrop { opacity: 1; }
.c5c-sysbc.is-open .c5c-sysbc-dialog { opacity: 1; transform: none; }
.c5c-sysbc.is-leaving .c5c-sysbc-dialog { opacity: 0; transform: translateY(10px) scale(0.98); }

.c5c-sysbc-tone-success { --sysbc-accent: #198754; --sysbc-accent-2: #20c997; --sysbc-soft: rgba(25, 135, 84, 0.12); }
.c5c-sysbc-tone-warning { --sysbc-accent: #e8890c; --sysbc-accent-2: #f5b82e; --sysbc-soft: rgba(232, 137, 12, 0.14); }
.c5c-sysbc-tone-critical { --sysbc-accent: #c62828; --sysbc-accent-2: #970250; --sysbc-soft: rgba(198, 40, 40, 0.14); }

.c5c-sysbc-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--sysbc-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.c5c-sysbc-close:hover,
.c5c-sysbc-close:focus-visible {
    background: var(--sysbc-soft);
    color: var(--sysbc-text);
    outline: none;
}

.c5c-sysbc-head {
    position: relative;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 26px 56px 14px 24px;
}

.c5c-sysbc-icon {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    background: linear-gradient(135deg, var(--sysbc-accent), var(--sysbc-accent-2));
    box-shadow: 0 8px 20px var(--sysbc-soft);
    animation: c5c-sysbc-ring 1.6s ease 0.3s 2;
}

@keyframes c5c-sysbc-ring {
    0%, 100% { transform: rotate(0); }
    10%, 30% { transform: rotate(-12deg); }
    20%, 40% { transform: rotate(12deg); }
    50% { transform: rotate(0); }
}

.c5c-sysbc-headtext {
    min-width: 0;
}

.c5c-sysbc-eyebrow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-bottom: 6px;
    font-size: 0.78rem;
    color: var(--sysbc-muted);
}

.c5c-sysbc-pill {
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.68rem;
    color: var(--sysbc-accent);
    background: var(--sysbc-soft);
}

[data-bs-theme="dark"] .c5c-sysbc-pill,
body.dark-mode .c5c-sysbc-pill {
    color: #fff;
}

.c5c-sysbc-title {
    margin: 0;
    font-size: 1.3rem;
    line-height: 1.3;
    font-weight: 700;
    color: var(--sysbc-text);
    overflow-wrap: anywhere;
}

.c5c-sysbc-scroll {
    position: relative;
    overflow-y: auto;
    padding: 4px 24px 8px;
}

.c5c-sysbc-figure {
    display: block;
    margin: 4px 0 14px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--sysbc-border);
    background: var(--bs-secondary-bg, #e9ecef);
}

.c5c-sysbc-figure img {
    display: block;
    width: 100%;
    max-height: 46vh;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.c5c-sysbc-figure:hover img {
    transform: scale(1.015);
}

.c5c-sysbc-body {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--sysbc-text);
    overflow-wrap: anywhere;
}

.c5c-sysbc-body p { margin: 0 0 0.6em; }
.c5c-sysbc-body p:last-child { margin-bottom: 0; }
.c5c-sysbc-body h1, .c5c-sysbc-body h2, .c5c-sysbc-body h3 { font-size: 1.05rem; font-weight: 700; margin: 0.8em 0 0.4em; color: var(--sysbc-text); }
.c5c-sysbc-body ul, .c5c-sysbc-body ol { padding-left: 1.3em; margin: 0 0 0.6em; }
.c5c-sysbc-body a { color: var(--sysbc-accent); font-weight: 600; }
.c5c-sysbc-body img { max-width: 100%; height: auto; border-radius: 8px; }
.c5c-sysbc-body blockquote { margin: 0 0 0.6em; padding: 6px 12px; border-left: 3px solid var(--sysbc-accent); background: var(--sysbc-soft); border-radius: 0 8px 8px 0; }
.c5c-sysbc-body pre, .c5c-sysbc-body code { background: var(--bs-secondary-bg, #e9ecef); color: var(--sysbc-text); border-radius: 6px; padding: 1px 6px; }
.c5c-sysbc-body .ql-align-center { text-align: center; }
.c5c-sysbc-body .ql-align-right { text-align: right; }

[data-bs-theme="dark"] .c5c-sysbc-body a,
body.dark-mode .c5c-sysbc-body a {
    color: #ff6fae;
}

/* Text colours pasted from a light page stay readable on the dark surface. */
[data-bs-theme="dark"] .c5c-sysbc-body [style*="color: rgb(0, 0, 0)"],
[data-bs-theme="dark"] .c5c-sysbc-body [style*="color:#000"],
[data-bs-theme="dark"] .c5c-sysbc-body [style*="color: #000"] {
    color: var(--sysbc-text) !important;
}

.c5c-sysbc-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px 20px;
    border-top: 1px solid var(--sysbc-border);
}

.c5c-sysbc-count {
    font-size: 0.8rem;
    color: var(--sysbc-muted);
}

.c5c-sysbc-ok {
    border: 0;
    border-radius: 10px;
    padding: 9px 22px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #970250, #690136);
    box-shadow: 0 6px 16px rgba(151, 2, 80, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.c5c-sysbc-ok:hover,
.c5c-sysbc-ok:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(151, 2, 80, 0.38);
    outline: none;
}

@media (max-width: 575px) {
    .c5c-sysbc { padding: 10px; align-items: flex-end; }
    .c5c-sysbc-dialog { border-radius: 16px; max-height: calc(100vh - 20px); }
    .c5c-sysbc-head { padding: 22px 48px 12px 18px; }
    .c5c-sysbc-scroll { padding: 4px 18px 8px; }
    .c5c-sysbc-foot { padding: 12px 18px 16px; }
    .c5c-sysbc-ok { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    .c5c-sysbc-dialog, .c5c-sysbc-backdrop { transition: none; }
    .c5c-sysbc-icon { animation: none; }
}
