/* ============================================================================
   Dark theme - component layer for the Blazor apps
   ----------------------------------------------------------------------------
   The palette itself lives in app.css (html.dark / body.dark token blocks) and
   is the analysis SPA's ramp, so the Blazor apps and the Beam / Frame / Truss /
   Strut-and-Tie SPA read as one product:

       page    #101010      column  #191919      card   #1f1f1f
       raised  #262626      field   #232323      hover  #2a2a2a
       line    rgba(255,255,255,.13)   strong line rgba(255,255,255,.22)
       text    #e4e4e4      label   #b4b4b4      muted  #8a8a8a
       accent  #2a7b8c (fill, white ink)   #3a9bb0 (line)   #7fd3e3 (ink)

   Most of app.css / appstyle.css already reads those tokens. This file is for
   the rules that paint a LITERAL light colour (a #fff card, a #f5f7fa band, a
   #1a2535 heading) and so stay light in dark mode. It is linked LAST in every
   index.html so it wins over appstyle.css without !important where possible.

   Contract (shared with EagleI.Analysis.App accountMenu.ts / dark.css):
     localStorage "settings".theme = "light" | "dark" | "system" (absent = system)
     -  class "dark" on <html> and <body>.
   If you add a light surface to app.css or appstyle.css, add its dark pair here.
   ========================================================================== */

/* ── Header theme switch - identical to the SPA's .acct-theme ─────────────── */
.acct-theme {
    width: 30px;
    height: 30px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font: inherit;
    color: #5a6a7e;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
}

.acct-theme:hover { background: #f4f6fa; border-color: #d8e0ec; }

/* Clear of the app title on pages where the button cluster follows it directly (home). */
.menu-container-buttons .acct-theme { margin: 0 4px 0 8px; }

.acct-theme .theme-toggle-track {
    position: relative;
    width: 18px;
    height: 18px;
    transition: transform .15s ease;
}

.acct-theme:active .theme-toggle-track { transform: scale(0.85); }

.acct-theme .theme-ico {
    position: absolute;
    inset: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    will-change: transform, opacity;
    transition: opacity .3s ease, transform .45s cubic-bezier(.34, 1.56, .64, 1);
}

.acct-theme .theme-ico-moon { opacity: 1; transform: rotate(0deg) scale(1); }
.acct-theme .theme-ico-sun { opacity: 0; transform: rotate(180deg) scale(0.4); }
html.dark .acct-theme .theme-ico-moon { opacity: 0; transform: rotate(-180deg) scale(0.4); }
html.dark .acct-theme .theme-ico-sun { opacity: 1; transform: rotate(0deg) scale(1); }

html.dark .acct-theme { color: #a3a3a3; }
html.dark .acct-theme:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.3); }

/* Light / Dark / System menu opened by the theme button. Portalled to <body> and
   fixed-positioned under the button (top/right set at open time). Same rules in
   EagleI.Blazor/wwwroot/css/dark.css and EagleI.Analysis.App analysis-common.css. */
.theme-menu {
    position: fixed;
    z-index: 9000;
    min-width: 9.5rem;
    padding: 5px;
    background: #fff;
    border: 1px solid #d8e0ec;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(11, 36, 68, 0.18);
    font-family: inherit;
}

.theme-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 10px;
    font: inherit;
    font-size: 12.5px;
    color: #1a2535;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
}

.theme-menu-item span { flex: 1; }
.theme-menu-item i { font-size: 16px; line-height: 1; color: #5a6a7e; }
.theme-menu-item:hover,
.theme-menu-item:focus-visible { background: #f4f6fa; outline: none; }
.theme-menu-item .theme-menu-check { visibility: hidden; color: #2a7b8c; }
.theme-menu-item[aria-checked="true"] { font-weight: 600; }
.theme-menu-item[aria-checked="true"] .theme-menu-check { visibility: visible; }

html.dark .theme-menu { background: #202020; border-color: rgba(255, 255, 255, 0.25); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); }
html.dark .theme-menu-item { color: #ededed; }
html.dark .theme-menu-item i { color: #a3a3a3; }
html.dark .theme-menu-item:hover,
html.dark .theme-menu-item:focus-visible { background: rgba(255, 255, 255, 0.14); }
html.dark .theme-menu-item .theme-menu-check { color: #7fd3e3; }

/* ── Loading screen (index.html) ──────────────────────────────────────────── */
html.dark #app h3 { color: #e4e4e4; }

/* ── Literal light colours in app.css / appstyle.css ──────────────────────────
   One dark pair per rule that paints a hard-coded light surface, dark ink or a light
   border, mapped mechanically onto the ramp above (the same method as the SPA's
   src/style/dark.css):
       white                      -> var(--panelbackground)
       light grey                 -> #262626 (a raised surface), or
                                     var(--containerbackground) on a column / group well
       tinted light (ok / warn /
       hover / selected)          -> the same hue as a 16% tint
       black / near-black ink     -> #e4e4e4      mid-grey ink -> #b4b4b4
       coloured ink (error, link) -> the same hue, lifted to stay legible
       light border               -> rgba(255,255,255,.13)
   !important is carried over wherever the light rule had it. Hand-tuned rules follow
   this block and win over it where both touch the same element. */
body.dark .datagrid .property-table .empty-cell {
    background-color: #262626 !important;
    border: 0.5px solid rgba(255, 255, 255, 0.13) !important;
}

body.dark .home-page.thumbnails {
    background-color: var(--containerbackground);
}

body.dark td.display-true {
    background-color: var(--panelbackground) !important;
}

body.dark .property-error .tooltip {
    color: #e4e4e4;
}

body.dark .property-group-list-container {
    border: 1px solid rgba(255, 255, 255, 0.13);
}

body.dark .property-table tr:has(:hover, :focus) td {
    background: rgba(51, 153, 204, 0.16);
    background: rgba(51, 153, 204, 0.16) !important;
}

body.dark .property-table tr:has(:hover, :focus) input {
    background: rgba(51, 153, 204, 0.16);
}

body.dark .navigation-view-item.highlight {
    background-color: #262626;
}

body.dark .datagrid .property-table-header .button {
    background-color: var(--panelbackground) !important;
}

body.dark .form {
    background-color: var(--panelbackground);
}

body.dark .graphic-tooltip {
    background-color: var(--panelbackground);
}

body.dark .app-group {
    color: #b4b4b4;
}

body.dark .app-group-header {
    color: #b4b4b4;
}

body.dark .app-details {
    background-color: #262626;
}

body.dark .app-thumbnail.disabled {
    background-color: #262626;
}

body.dark .app-thumbnail a {
    color: #e4e4e4;
}

body.dark .app-user-stats {
    background-color: var(--panelbackground);
}

body.dark .app-user-stats-body {
    background-color: #262626;
}

body.dark .analysis .right-panel {
    background: var(--containerbackground);
}

body.dark .info .info-container {
    background-color: rgba(51, 204, 51, 0.16);
}

body.dark .info.warning .info-container {
    background-color: rgba(204, 128, 51, 0.16);
}

body.dark .button.user-menu-button .property-group-list-body > .button.license-pill,
body.dark .button.user-menu-button .property-group-list-body > div > .button.license-pill {
    background-color: rgba(51, 204, 132, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.13);
}

body.dark .button.user-menu-button.ismenu .property-list-container {
    background-color: var(--panelbackground);
}

body.dark .eaglei-link {
    background-color: var(--panelbackground);
    border: 1px solid rgba(255, 255, 255, 0.13);
}

body.dark .fea-matrices-splitter::before {
    background: #262626;
}

body.dark .fea-matrices-selectorlabel {
    color: #b4b4b4;
}

body.dark .fea-matrices-selector {
    border: 1px solid rgba(255, 255, 255, 0.13);
    background: var(--panelbackground);
}

body.dark .fea-matrices-workinglabel {
    color: #b4b4b4;
}

body.dark .fea-notation-block {
    background: var(--panelbackground);
    border: 1px solid rgba(255, 255, 255, 0.13);
}

body.dark .fea-notation-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.13);
    color: #b4b4b4;
}

body.dark .fea-notation-list dt {
    color: #e4e4e4;
}

body.dark .fea-notation-list dd {
    color: #b4b4b4;
}

body.dark .fea-matrices-body .fea-matrices-symbolic td,
body.dark .fea-matrices-body .fea-matrices-substituted td {
    color: #b4b4b4;
    background: #262626;
}

body.dark .fea-matrices-legendlabel {
    color: #b4b4b4;
}

body.dark .fea-matrices-legendchip {
    border: 1px solid rgba(255, 255, 255, 0.13);
    color: #e4e4e4;
}

body.dark .fea-maxdef-block {
    background: var(--panelbackground);
    border: 1px solid rgba(255, 255, 255, 0.13);
}

body.dark .fea-maxdef-text {
    color: #b4b4b4;
}

body.dark .fea-maxdef-eqn {
    background: var(--panelbackground);
}

body.dark .fea-maxdef-list {
    color: #b4b4b4;
}

body.dark .fea-maxdef-result {
    background: rgba(204, 167, 51, 0.16);
    color: #e4d095;
}

body.dark .fea-matrices-body .fea-dof-label {
    color: #b4b4b4;
}

body.dark .fea-matrices-body table.has-row-labels tbody td:first-child,
body.dark .fea-matrices-body table.has-row-labels thead th:first-child {
    background: #262626 !important;
    border-right: 2px solid rgba(255, 255, 255, 0.13);
}

body.dark .fea-matrices-body table thead th {
    background: #262626;
    border-bottom: 2px solid rgba(255, 255, 255, 0.13);
}

body.dark .fea-matrices-body .datatable td {
    border: 1px solid rgba(255, 255, 255, 0.13);
}

body.dark .strut-and-tie .right-panel {
    background: var(--containerbackground);
}

body.dark .workflow-report-panel .right-panel .property-groups {
    background: var(--containerbackground);
}

body.dark .workflow-report-panel .right-panel .property-group {
    background: var(--panelbackground);
    border: 1px solid rgba(255, 255, 255, 0.13);
}

body.dark .workflow-report-panel .right-panel .property-group-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

body.dark .workflow-report-panel .right-panel .property-group-header-text {
    color: #e4e4e4;
}

body.dark .workflow-step {
    background-color: var(--panelbackground);
    color: #e4e4e4;
    background-color: #262626 !important;
    color: #e4e4e4 !important;
}

body.dark .workflow-step.stale {
    background-color: rgba(204, 168, 51, 0.16) !important;
    color: #e4b295 !important;
}

body.dark .workflow-step.active:not(.current) {
    background-color: var(--panelbackground) !important;
}

body.dark .help-reenable-btn {
    background: var(--panelbackground);
    color: #e4e4e4;
}

body.dark .help-reenable-btn:hover {
    background: #262626;
}

body.dark #eagle-video-gallery.help-popup {
    background: var(--panelbackground);
    color: #e4e4e4;
}

body.dark #eagle-video-gallery .help-gallery-title {
    color: #e4e4e4;
}

body.dark #eagle-video-gallery .help-gallery-item {
    background: #262626;
}

body.dark #eagle-video-gallery .help-gallery-item video,
body.dark #eagle-video-gallery .help-gallery-item img {
    background: #262626;
}

body.dark #eagle-video-gallery .help-close,
body.dark #eagle-video-gallery .help-gallery-back {
    color: #b4b4b4;
}

body.dark #eagle-video-gallery .help-close:hover,
body.dark #eagle-video-gallery .help-gallery-back:hover {
    color: #e4e4e4;
}

body.dark #eagle-video-gallery .help-title {
    color: #e4e4e4;
}

body.dark .form.import-dialog .import-warning {
    color: #e49a95;
}

body.dark .file-dropzone-error {
    color: #e49a95;
}

body.dark .beam-span .datagrid .property.property-table tbody tr.selected td,
body.dark .beam-span .datagrid .property.property-table tbody tr.selected td *,
body.dark .beam-span .datagrid .property.property-table tbody tr.selected .property,
body.dark .beam-span .datagrid .property.property-table tbody tr.selected .property.display {
    background-color: rgba(51, 131, 204, 0.16) !important;
}

body.dark .beam-deflection .beam-span-actions .has-top-header thead tr:first-child th {
    background: #262626 !important;
}

body.dark .beam-deflection .beam-span-actions td.readonly-true,
body.dark .beam-deflection .beam-span-actions td.readonly-true .property-value,
body.dark .beam-deflection .beam-span-actions td.readonly-true .property-input {
    background-color: #262626 !important;
}

body.dark .beam-deflection .beam-span-actions td.readonly-false,
body.dark .beam-deflection .beam-span-actions td.readonly-false .property-value,
body.dark .beam-deflection .beam-span-actions td.readonly-false .property-input {
    background-color: var(--panelbackground) !important;
}

body.dark .beam-deflection .beam-deflection-diagram {
    border: 1px solid rgba(255, 255, 255, 0.13);
    background: var(--panelbackground);
}

body.dark .beam-deflection .beam-deflection-diagram .property-group-body {
    border: 1px solid rgba(255, 255, 255, 0.13);
    background-color: var(--panelbackground);
}

body.dark .beam-deflection .beam-deflection-diagram > .property-group-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.13);
    background: var(--panelbackground);
}

body.dark .beam-deflection .beam-deflection-diagram .group-toolbar .button.beam-diagram-tab-button {
    color: #b4b4b4;
}

body.dark .beam-deflection .beam-deflection-diagram .group-toolbar .button.beam-diagram-tab-button:hover {
    background: #262626;
}

body.dark .beam-deflection .beam-deflection-diagram .group-toolbar .button:not(.beam-diagram-tab-button):hover {
    border-color: rgba(255, 255, 255, 0.13);
    background: #262626;
}

body.dark .beam-deflection .beam-deflection-stiffness-pane {
    border: 1px solid rgba(255, 255, 255, 0.13);
    background: var(--panelbackground);
}

body.dark .beam-deflection .beam-deflection-stiffness-pane .paragraph.beam-deflection-chart-title,
body.dark .beam-deflection .beam-deflection-stiffness-pane .paragraph.beam-deflection-stiffness-readout {
    border-bottom: 1px solid rgba(255, 255, 255, 0.13);
    background: var(--panelbackground);
}

body.dark .beam-deflection .beam-deflection-stiffness-pane .paragraph.beam-deflection-chart-title .paragraph-text {
    color: #b4b4b4;
}

body.dark .beam-deflection .beam-deflection-html-viewer {
    background: var(--panelbackground);
}

body.dark .beam-sections .right-panel {
    background: var(--containerbackground);
}

/* ── Header ───────────────────────────────────────────────────────────────── */
/* The EagleI mark is navy artwork; on the dark bar it goes light, as the SPA's does. */
html.dark .menu-container-icon img[src$="eaglei.svg"],
html.dark .menu-container-icon img[src$="eaglei.png"],
html.dark .app-user-picture img[src$="eaglei.png"],
html.dark .app-user-picture img[src$="eaglei.svg"] { filter: brightness(0) invert(0.92); }

/* ── Parameter panel ──────────────────────────────────────────────────────── */
/* Light theme marks the chosen tile with the page grey; in dark that is a near-black
   hole on a card, so it takes the accent tint the SPA's selected beam-type tile uses. */
body.dark .property-enum-thumbnail .thumbnail.thumbnail-selected {
    background-color: rgba(58, 155, 176, 0.18);
}

/* ── Flowchart ────────────────────────────────────────────────────────────── */
/* Decision diamonds paint literal light fills (#eee, and #efeeb4 on the taken path) while
   their text follows --fontcolor, which is light in dark mode - so the diamonds go dark too.
   The taken path keeps its gold identity as a deep olive, the dark twin of #efeeb4. */
body.dark .flow-chart-shape {
    fill: #262626;
    stroke: #3a3a3a;
}

body.dark .flow-chart-shape.path {
    fill: #3b3714;
    stroke: #a39a2e;
}

/* Off-path equations are muted #555 on a light block; the same role on a dark block. */
body.dark .flow-chart-box {
    color: #8a8a8a;
}

/* ── Home (app launcher) ──────────────────────────────────────────────────── */
body.dark .app-group-header { color: #f4f4f4; }
body.dark .app-thumbnail { border: 1px solid rgba(255, 255, 255, 0.08); }
body.dark .app-thumbnail:hover { box-shadow: 0 0 0 1px rgba(58, 155, 176, 0.55), 0 6px 18px rgba(0, 0, 0, 0.5); }

/* ── Icons ─────────────────────────────────────────────────────────────────── */
/* Panel tab icons (Section / Report / Flowchart / Preferences / Properties / BOQ ...) are black
   artwork drawn unfiltered - fine on light, invisible on dark. Unselected ones take the theme's
   icon tint, the same --svgfilter the toolbar and property icons already use; the selected tab
   keeps its white knockout on the teal fill. */
body.dark .tab-header-item img { filter: var(--svgfilter); }
body.dark .tab-header-item.selected img { filter: brightness(0) invert(1); }

/* Phones draw the selected tab without the teal fill (and drop its filter), so there it is an
   ordinary icon on the panel and takes the tint too. */
@media only screen and (max-width: 600px) {
    body.dark .tab-header-item.selected img { filter: var(--svgfilter) !important; }
}

/* Option tiles (section shape, beam / frame type ...): the artwork sits on a white canvas and is
   blended with multiply, which on a dark tile wipes it out. Inverting lightness (hue kept by the
   180deg rotate) turns black lines light and the white canvas dark, and screen lets that dark
   canvas drop out over the tile. */
body.dark .thumbnail img {
    filter: invert(0.88) hue-rotate(180deg);
    mix-blend-mode: screen;
}

/* Expander chevrons (property lists, account / settings menus) are dark PNG artwork. */
body.dark .expander-header-icon img { filter: invert(0.85); }

/* Accent glyphs tinted to a DEEP teal / red for a light page - same hue, lifted for dark. */
body.dark .form.import-dialog:not(.import-csi):not(.import-excel) .button.import-download img,
body.dark .import-model .import-exporter-help .button.import-download img {
    filter: brightness(0) saturate(100%) invert(23%) sepia(90%) saturate(2000%) hue-rotate(190deg) brightness(94%) contrast(101%) brightness(2.4);
}

body.dark .form.import-dialog .import-warning .paragraph-icon img {
    filter: brightness(0) saturate(100%) invert(24%) sepia(64%) saturate(4260%) hue-rotate(354deg) brightness(93%) contrast(93%) brightness(1.9);
}
