/* The panel's own stylesheet, on top of MudBlazor's: the page frame (top bar, tenant side menu), the login form
   (static SSR, plain HTML) and the few things MudBlazor has no component for. */
:root {
    --ink: #1a1d21;
    --muted: #55606b;
    --line: #dfe4ea;
    --paper: #ffffff;
    --ground: #f3f5f7;
    --accent: #0b5cad;
    --danger: #b3261e;
    --bar: #12222f;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--ground);
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.2; font-weight: 600; margin: 0 0 1rem; }
h1:focus { outline: none; } /* focused by FocusOnNavigate for screen readers, not a control */
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 .75rem; }
h3 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 .5rem; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .92em; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Read by screen readers only: the text of a notice that sighted users get as a snackbar. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---- Top bar (static SSR) ---- */
.top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1.5rem;
    min-height: 3.5rem;
    padding: .5rem 1.25rem;
    background: var(--bar);
    color: #fff;
}
.top a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; }
.brand span { font-weight: 400; font-size: .85rem; opacity: .75; margin-left: .35rem; }
.top nav { display: flex; gap: 1rem; }
.top nav a { padding: .35rem .75rem; border-radius: 999px; opacity: .85; }
.top nav a:hover { background: rgb(255 255 255 / .1); opacity: 1; }
.top nav a.active { background: rgb(255 255 255 / .16); opacity: 1; font-weight: 600; }
.session { display: flex; align-items: center; gap: .75rem; margin-left: auto; font-size: .9rem; }
.session span { overflow-wrap: anywhere; opacity: .85; }
.session button {
    font: inherit;
    min-height: 2.25rem;
    padding: .25rem .9rem;
    color: #fff;
    background: transparent;
    border: 1px solid rgb(255 255 255 / .5);
    border-radius: 6px;
    cursor: pointer;
}
.session button:hover { background: rgb(255 255 255 / .12); }

main { max-width: 90rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* ---- A tenant's screens: side menu next to the content; above it, as a scrolling row, on a narrow screen ---- */
.shell { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
/* No tenant (a foreign id, or still loading): no side menu, the content takes the whole width. */
.shell-plain { grid-template-columns: minmax(0, 1fr); }
.shell-side { position: sticky; top: 1rem; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: .75rem .5rem; }
.shell-tenant { padding: .25rem .75rem .75rem; border-bottom: 1px solid var(--line); margin-bottom: .5rem; overflow-wrap: anywhere; }
.shell-tenant strong { display: block; }
.shell-main { min-width: 0; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: 0 0 .5rem; padding: 0; list-style: none; color: var(--muted); font-size: .9rem; }
.crumbs li + li::before { content: "›"; margin-right: .35rem; }
.shell-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1rem; }
.shell-head h1 { margin: 0; }

.subnav { display: flex; flex-direction: column; gap: .15rem; list-style: none; margin: 0; padding: 0; }
.subnav a { display: flex; align-items: center; gap: .65rem; min-height: 2.75rem; padding: .4rem .75rem; border-radius: 8px; color: var(--ink); text-decoration: none; }
.subnav a:hover { background: var(--ground); }
.subnav a[aria-current="page"] { background: #e3effb; color: var(--accent); font-weight: 600; }
.subnav .mud-icon-root { flex: none; }
.subnav .subnav-label { margin-top: .6rem; padding: .3rem .75rem; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted, #5b6470); }

@media (max-width: 60rem) {
    .shell { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
    .shell-side { position: static; padding: .5rem; }
    .shell-tenant { display: none; }
    .subnav { flex-direction: row; overflow-x: auto; }
    .subnav a { white-space: nowrap; }
}

/* ---- Content blocks ---- */
.meta { color: var(--muted); overflow-wrap: anywhere; }
.stack { display: grid; gap: 1.25rem; }
.stack > * { min-width: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem 1rem; align-items: start; }
.color-field { display: flex; align-items: center; gap: .5rem; }
.color-field > :last-child { flex: 1; min-width: 0; }
.color-swatch { flex: none; width: 2rem; height: 2rem; border-radius: 6px; border: 1px solid #d0d7de; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.card-pad { padding: 1.25rem; }
.card-pad > h2 { margin-bottom: 1rem; }
.card-pad > .actions, .card-pad > form > .actions { margin-top: 1rem; }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }
/* A plain list of rows with their actions on the right (knowledge entries). */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { padding: .35rem .25rem; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows .shell-head { margin: 0; flex-wrap: nowrap; }
/* Text in a table cell that may be long (a knowledge entry, a form message) wraps instead of widening the table. */
.wrap { overflow-wrap: anywhere; white-space: pre-line; }
.mud-table-cell .actions { flex-wrap: nowrap; gap: .25rem; }

/* Stays in view while the screen scrolls: the form that caused an error can be far below the heading. */
.messages { position: sticky; top: 0; z-index: 2; }
.messages:focus { outline: none; }
.messages .mud-alert { margin-bottom: 1rem; background: var(--paper); }

/* ---- Login: static SSR, so plain HTML controls ---- */
.login { max-width: 24rem; margin: 3rem auto 0; padding: 1.75rem; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgb(18 34 47 / .08); }
.login label { display: block; font-weight: 600; margin: .9rem 0 .25rem; }
.login input { width: 100%; min-height: 2.75rem; padding: .4rem .6rem; font: inherit; color: inherit; background: var(--paper); border: 1px solid #7b8794; border-radius: 6px; }
.login button { width: 100%; min-height: 2.75rem; margin-top: 1.25rem; font: inherit; font-weight: 600; color: #fff; background: var(--accent); border: 0; border-radius: 6px; cursor: pointer; }
.login button:hover { background: #084a8c; }
.login .error { margin: 0 0 .5rem; padding: .6rem .8rem; border-left: 4px solid var(--danger); color: var(--danger); background: #fdf1f0; }

/* ---- The page screen: the preview next to its tools on a wide screen, above them on a narrow one ---- */
.editor { display: grid; gap: 1.5rem; }
.editor > * { min-width: 0; }
@media (min-width: 80rem) {
    main:has(.editor) { max-width: 120rem; }
    .editor { grid-template-columns: minmax(0, 1fr) 26rem; }
}
iframe { display: block; width: 100%; height: 80vh; margin-inline: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
iframe.mobile { width: 390px; max-width: 100%; }

/* Embed code and imported text: monospace, kept as text. */
.code textarea, textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: .92rem; }

#components-reconnect-modal, #blazor-error-ui { display: none; }
#blazor-error-ui,
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    position: fixed;
    inset: auto 1rem 1rem 1rem;
    z-index: 2000;
    padding: .25rem 1rem;
    background: var(--paper);
    border: 2px solid var(--danger);
    border-radius: 6px;
}
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected { display: block; }

/* The few native controls left (a select inside a table row, the field that confirms a deletion). */
select.plain, input.plain { min-height: 2.5rem; padding: .3rem .6rem; font: inherit; color: inherit; background: var(--paper); border: 1px solid #9aa5b1; border-radius: 6px; }
input.plain { display: block; width: 100%; max-width: 24rem; margin: .35rem 0 1rem; }

/* The media file picker: Blazor's own file input, with its button drawn like the panel's outlined buttons. */
label[for="media-file"] { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
#media-file { display: block; width: 100%; font: inherit; }
#media-file::file-selector-button { font: inherit; font-weight: 600; min-height: 2.5rem; margin-right: .75rem; padding: .3rem 1rem; color: var(--accent); background: var(--paper); border: 1px solid var(--accent); border-radius: 8px; cursor: pointer; }
#media-file::file-selector-button:hover { background: #e3effb; }
#media-file + .meta, #media-file ~ small { display: block; margin-top: .35rem; color: var(--muted); font-size: .85rem; }

/* Phase 19: the site profile on the Knowledge screen. */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; }
.swatch { display: inline-block; width: 1rem; height: 1rem; margin-right: .25rem; border: 1px solid var(--line); border-radius: 3px; vertical-align: text-bottom; }
