/* Shared utility classes — included by every Trunk app's index.html
   via `<link data-trunk rel="css" href="../../../crates/ui/style/shared.css" />`.
   Each app's own main.css keeps the app-specific palette, components,
   and layout; this file holds the cross-app primitives.

   CSP note: the codebase keeps inline `style="..."` only for live
   per-tenant CSS-variable bindings, set programmatically via
   NodeRef + `style.set_property(...)`. Static styles all flow through
   classes defined here or in app-local main.css.

   Naming convention:
     .{component}-{element}   for compound components (e.g. .list-row-name)
     .{purpose}               for utilities    (e.g. .mono, .hidden)
     .muted-*                 mute variants
*/

/* ----- Type / utility primitives ----- */
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.hidden { display: none; }
.button-disabled-look {
    opacity: 0.6;
    pointer-events: none;
}

/* ----- Muted notes (spacing variants for legend lines) ----- */
.muted-note          { margin: 0.5rem 0 0; }
.muted-note-small    { margin: 0.5rem 0 0; font-size: 0.85rem; }
.muted-note-mini     { margin: 0.25rem 0 0; font-size: 0.85rem; }
.muted-note-tight    { margin-top: 0.5rem; font-size: 0.85rem; }
.muted-note-top      { margin-top: 0.5rem; }

/* ----- Layout helpers ----- */
.action-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}
/* The type-to-confirm gate (ConfirmDestructive): stack its reason/prompt/input/
   button with even spacing so the action button never clings to the input.
   Lives here (not web.css) so the mobile app — which only loads shared.css —
   gets it too. */
.confirm-gate {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--muted);
}
.form-spaced { margin-top: 0.75rem; }
.section-h3 {
    margin-top: 1rem;
    font-size: 0.95rem;
}

/* ----- Bordered list-row primitive ----- */
/* Generic two-line list item with right-aligned actions. Originally
   added for Mit-Logger lists; the name stays neutral so other list
   components can adopt it without renaming. */
.list-row-bordered {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.list-row-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.list-row-name { font-weight: 600; }
.list-row-meta {
    font-size: 0.875rem;
    color: var(--muted);
}

/* ===== Guided BCS wizard (Spec §5.3) =====
   Shared between customer and vet apps. Uses the per-app theme
   variables (--accent, --border, --bg, --bg-soft). */
.bcs-fieldset {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem 1rem;
    margin: 0.5rem 0;
}
.bcs-legend {
    font-weight: 600;
    padding: 0 0.4rem;
}
.bcs-hint {
    margin: 0.25rem 0 0.5rem;
    font-size: 0.875rem;
}
.bcs-options {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.bcs-option {
    /* `flex-direction: row` is explicit because the consuming apps
     * (web-customer + app-ui) both have a global `label { flex-
     * direction: column }` rule for stacked form fields. Without
     * the override the radio sits above its caption instead of
     * next to it. */
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 120ms;
    min-height: 2.75rem;
}
.bcs-option:hover { background: var(--bg-soft); }
.bcs-option input[type="radio"] {
    margin: 0;
    width: 1.15rem;
    height: 1.15rem;
    flex-shrink: 0;
}
.bcs-option > span {
    flex: 1;
    line-height: 1.3;
}
/* BCS-scale badge (1–2 / 3–4 / 5 / 6–7 / 8–9) tying each answer to a number.
   Fixed-width + tabular figures so the badges line up; the more-specific
   selector beats the `flex: 1` on plain option spans above. */
.bcs-option > span.bcs-option-score {
    flex: 0 0 2.8rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    background: var(--bg-soft);
    border-radius: var(--radius-control);
    padding: 0.15rem 0.35rem;
    line-height: 1.3;
}
.bcs-option-selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--bg));
}
.bcs-preview {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-soft);
    border-radius: 0.375rem;
}
.bcs-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
    gap: 0.5rem;
    font-size: 0.875rem;
}
.bcs-preview-label { margin-right: 0.25rem; }
.bcs-preview-total {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--border);
}
.bcs-preview-total-value {
    font-weight: 700;
    font-size: 1.2rem;
}
.bcs-previous {
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
}
.bcs-history-row {
    padding: 0.25rem 0;
}
.bcs-history-axes {
    font-size: 0.85rem;
    margin-top: 0.1rem;
}
.bcs-sparkline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.4rem 0 0;
}
.bcs-sparkline-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.bcs-sparkline-dot { fill: var(--accent); cursor: help; }
.bcs-sparkline-dot-old { opacity: 0.55; }
.bcs-sparkline-caption { font-size: 0.8rem; }

/* ===== TrendChart (weight / BCS line chart) ===== */
.trend-chart { margin: 0.4rem 0; }
.trend-svg { width: 100%; max-width: 28rem; height: auto; display: block; }
.trend-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.trend-dot { fill: var(--accent); cursor: help; }
.trend-dot-last { stroke: var(--bg); stroke-width: 1; }
.trend-axis { stroke: var(--border); stroke-width: 1; }
.trend-axis-label { fill: var(--muted); font-size: 8px; }
.trend-axis-label-y { text-anchor: end; }
.trend-axis-label-end { text-anchor: end; }
.trend-ref { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 3 2; opacity: 0.8; }
.trend-ref-label { fill: var(--warn); font-size: 8px; }
.trend-caption { font-size: 0.8rem; }

/* ===== EntryPhotos (per-entry thumbnails) ===== */
.entry-photos { display: flex; flex-direction: column; gap: 0.5rem; }
.entry-photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.entry-photo-thumb {
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    overflow: hidden;
    background: var(--bg);
    cursor: pointer;
    line-height: 0;
}
.entry-photo-thumb img {
    width: 4rem;
    height: 4rem;
    object-fit: cover;
    display: block;
}

/* ===== Locale picker (TopBar) ===== */
.locale-picker {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-right: 0.5rem;
    font-size: 0.85rem;
    color: #fff;
}
.locale-picker-label { opacity: 0.85; }
.locale-picker select {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 0.25rem;
    padding: 0.15rem 0.4rem;
    font-size: 0.85rem;
}
.locale-picker option { color: #111827; }

/* Practice switcher mirrors the locale picker (lives in the same TopBar
   slot, same on-coloured-bar treatment). */
.practice-switcher {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-right: 0.5rem;
    font-size: 0.85rem;
    color: #fff;
}
.practice-switcher-label { opacity: 0.85; }
.practice-switcher select {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 0.25rem;
    padding: 0.15rem 0.4rem;
    font-size: 0.85rem;
}
.practice-switcher option { color: #111827; }

/* CSP-safe spacing/utility classes — replace inline `style=` attributes so
   a strict `style-src` (no 'unsafe-inline') stays possible. */
.mt-sm { margin-top: 0.75rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.25rem; }
.mt-xl { margin-top: 1.5rem; }
.my-sm { margin-top: 0.75rem; margin-bottom: 0.75rem; }
.no-margin { margin: 0; }
.is-clickable { cursor: pointer; }
.text-underline { text-decoration: underline; }
.note-fine { font-size: 0.85rem; }

/* ===== Design-Tokens, die die geteilten `ui`-Komponenten unten brauchen.
   Hier (von ALLEN SPAs inkl. Mobile geladen) mit denselben Werten wie das
   :root in web.css — so lösen die Komponenten-Styles auch auf app-ui auf.
   web.css deklariert sie für die Web-SPAs erneut; identische Werte → dort
   keine Änderung. (app-ui nutzte var(--border,#e5e7eb) bisher per Fallback.) */
:root {
    --muted: #6b7280;
    --bg-soft: #f5f5f7;
    --border: #e5e7eb;
    --focus: var(--primary);
    --radius-control: 0.5rem;
}

/* ===== Geteilte `ui`-Komponenten-Styles (Web + Mobile). Vorher web-only in
   web.css → auf app-ui (lädt web.css nicht) war z.B. AssetGallery ungestylt. */
.list-reset { list-style: none; padding: 0; margin: 0; }

.asset-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
}
.asset-tile { text-align: center; }
.asset-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: var(--radius-control);
    border: 1px solid var(--border);
    background: var(--bg-soft);
}
.asset-label {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.25rem;
}
.asset-tile-button {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    width: 100%;
    cursor: pointer;
    color: inherit;
    text-align: inherit;
    font: inherit;
}
.asset-tile-button:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--radius-control);
}

/* In-app "new version available" banner (VersionWatcher). Fixed bottom bar; a
   gap keeps the reload button off the text (controls-never-touch). Styled via a
   class — the CSP is style-src 'self', so no inline styles. */
.version-banner {
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
}
.version-banner__reload {
    padding: 0.4rem 0.9rem;
    border: 1px solid #fff;
    border-radius: var(--radius-control);
    background: #fff;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
}
