/* ====================================================================
   zTreatment palette tokens
   Exposed for components that want the coral accent or pastel category
   chips. MudBlazor's Primary/Secondary/etc. are set in MainLayout.razor;
   these are extras the framework doesn't cover.
   ==================================================================== */
:root {
    --zt-bg-canvas:   #CDE8DD; /* mint page background */
    --zt-bg-sidebar:  #DCEEE6; /* slightly lighter mint */
    --zt-ink-primary: #1F3A3D; /* deep teal */
    --zt-ink-muted:   #5B7578; /* muted blue-gray */
    --zt-accent:      #F5A58E; /* coral — single hot accent, use sparingly */
    --zt-chip-peach:  #FFE1C4;
    --zt-chip-mint:   #D4F0D2;
    --zt-chip-blush:  #FBD5CC;
    --zt-chip-butter: #FFE9A8;
    --zt-leaf:        #4CAF50;
}

/* ====================================================================
   MudBlazor v9 compatibility overrides
   MudBlazor 9.0.0 introduced CSS changes that affect layout and borders.
   These rules restore v8 visual behavior where needed.
   ==================================================================== */

/* Fix: MudBlazor v9 adds flex-grow:1 to .mud-tabs-rounded .mud-tabs-panels,
   causing tab panels to stretch to fill all available vertical space.
   Resetting flex-grow keeps panels sized to their content. */
.mud-tabs-panels {
    flex-grow: 0 !important;
}

/* Fix: MudBlazor v9 adds overflow-y:auto to .mud-collapse-wrapper inside tab panels,
   which creates a scroll context that breaks position:sticky on child elements.
   The wrapper has no fixed height so overflow-y:auto has no visual effect anyway. */
.mud-tabs-panels .mud-collapse-wrapper {
    overflow: visible !important;
}

/* Fix: MudTabs with ApplyEffectsToContainer sets overflow:hidden on .mud-tabs-rounded
   to clip content to rounded corners. This breaks position:sticky on child elements.
   Override to visible — the rounded corners still render via border-radius. */
.mud-tabs-rounded {
    overflow: visible !important;
}

/* Fix: During tab switches, MudBlazor v9 briefly expands the tab bar from
   48px to ~332px while Blazor re-renders the new panel content. The tooltip
   wrappers around each tab grow to fill the transient height, creating a
   visible "giant tab" flash for ~500ms. Clamping the tab bar height prevents
   the flash entirely. */
.mud-tabs-tabbar {
    max-height: 48px;
    overflow: hidden;
}

/* Fix: MudBlazor v9 changed outlined button borders from fully opaque to
   semi-transparent via --mud-palette-border-opacity. This makes outlined
   buttons in MudButtonGroup appear borderless. Override the opacity variable
   within button groups to restore visible borders. */
.mud-button-group-root .mud-button-root {
    --mud-palette-border-opacity: 0.5;
}

/* ====================================================================
   End MudBlazor v9 compatibility overrides
   ==================================================================== */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44Nzc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Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1F3A3D;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Treatment Plan Panel */
.plan-recommendation-banner {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: linear-gradient(135deg, #D4F0D2 0%, #FFE1C4 100%);
    border-left: 4px solid var(--mud-palette-primary);
    border-radius: 4px;
    font-size: 0.875rem;
    color: #1F3A3D;
}

.plan-field-modified .mud-input-outlined .mud-input-outlined-border {
    border-color: var(--mud-palette-warning) !important;
    border-width: 2px;
}

/* Consultation page container - constrain stepper and title to match panel width */
.consultation-page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

/* Assessment panel container - fill parent width (centering handled by page container) */
.assessment-panel-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

/* Measurements panel - narrower fixed width, centered.
   Lives in global app.css (not scoped) because Blazor's scoped CSS attribute
   is not forwarded onto MudPaper's rendered div. */
.measurements-panel-narrow {
    width: 100%;
    max-width: 550px;
}

/* Editable Limb Diagram - Paired layout */
.limb-diagrams-pair {
    display: flex;
    justify-content: center;
}

.limb-diagrams-pair > .limb-diagram-layout + .limb-diagram-layout {
    margin-left: -4px;
}

.limb-diagrams-pair > .limb-diagram-layout.bodypart-foot + .limb-diagram-layout.bodypart-foot {
    margin-left: 20px;
}

/* Label positioning */
.limb-label {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.15s;
    z-index: 10;
}

.limb-label:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.limb-label.has-data {
    background: rgba(0, 123, 255, 0.08);
}

.limb-label.selected {
    background: rgba(0, 123, 255, 0.15);
    box-shadow: 0 0 0 1px #007bff;
}

/* Right limb: labels on left, right-edge anchored at column boundary */
.limb-label-right {
    justify-content: flex-end;
    transform: translate(-100%, -50%);
}

.limb-label-right .label-text { order: 1; }
.limb-label-right .label-badges { order: 2; }

/* Left limb: labels on right, left-edge anchored at column boundary */
.limb-label-left {
    justify-content: flex-start;
    transform: translateY(-50%);
}

.limb-label-left .label-badges { order: 1; }
.limb-label-left .label-text { order: 2; }

.limb-label .label-text {
    font-size: 12px;
    font-weight: bold;
    color: #777;
}

.limb-label .label-badges {
    display: flex;
    gap: 1.5px;
}

/* Badge styling is owned by Components/Shared/BadgeRow.razor.css */

/* Full-body diagram labels — overlaid directly on the image */
.limb-label.full-body-label {
    background: white;
}

.limb-label.full-body-label:hover {
    background: white;
}

.limb-label.full-body-label.has-data {
    background: white;
}

.limb-label.full-body-label.selected {
    background: white;
    box-shadow: 0 0 0 1.5px #007bff;
}

/* Measurement diagram labels — show value text instead of badge row */
.limb-label.measurement-label .label-text {
    font-size: 12px;
    color: #888;
}

/* When a measurement has data, show the value in a bolder, darker style */
.limb-label.measurement-label .label-text.label-value {
    font-weight: 600;
    color: #333;
}

/* Mini-popover centered within .assessment-panel-container */
.mini-popover-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    pointer-events: auto;
    /* Disable iOS 300ms double-tap-zoom detection for reliable taps inside popovers */
    touch-action: manipulation;
}

/* Shared mini-popover styles (Signs + Symptoms) */
.mini-popover-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-bottom: 4px;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 6px;
}

.mini-popover-title {
    font-weight: bold;
    font-size: 12px;
    color: #333;
}

.pop-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 6px;
    border: 2px solid;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
}

.pop-badge.selected {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.cascade-badge {
    height: 32px;
    min-height: 32px;
    font-size: 16px;
}

/* Footer row for Reset / Apply All buttons */
.mini-popover-footer {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding-top: 6px;
    margin-top: 4px;
    border-top: 1px solid #e0e0e0;
}

.popover-action-btn {
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid #bbb;
    background: #fff;
    color: #555;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
}

.popover-action-btn:hover {
    background: #f0f0f0;
    border-color: #999;
    color: #333;
}

.reset-btn:hover {
    border-color: #e53935;
    color: #e53935;
}

.apply-all-btn:hover {
    border-color: #1976d2;
    color: #1976d2;
}

/* Help toggle button */
.help-toggle {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px solid #999;
    background: #fff;
    color: #999;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.help-toggle:hover {
    border-color: #555;
    color: #555;
    background: #f5f5f5;
}

.help-mode .help-toggle {
    border-color: #1976d2;
    color: #fff;
    background: #1976d2;
}

/* Help labels — hidden in normal mode, revealed in help mode */
.help-label {
    display: none;
}

.help-mode .help-label {
    display: block;
}

.help-col-header {
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    line-height: 1.15;
    padding: 0 2px 2px;
}

/* Skin Condition and Pulses panel - legacy centered style */
.skin-condition-panel {
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
}

.skin-condition-header {
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    text-align: center;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 0.9rem;
}

.skin-condition-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 6px 12px;
    gap: 4px 24px;
}

.skin-condition-field {
    display: flex;
    align-items: center;
    gap: 4px;
}

.skin-condition-label {
    font-size: 0.875rem;
    white-space: nowrap;
}

.skin-condition-value {
    flex-shrink: 0;
}

.skin-condition-value .mud-input-control.mud-input-control-boolean-input .mud-radio-group,
.skin-condition-inline .mud-input-control.mud-input-control-boolean-input .mud-radio-group {
    flex-flow: row wrap;
    align-items: center;
    gap: 4px;
}

/* Utility: hidden on screen, visible only when printing */
.print-only {
    display: none;
}

/* Body diagram + legend sidebar row — legend sits to the right of the body/foot diagrams */
.overview-content-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
}
.overview-content-row > .overview-body {
    flex: 1 1 auto;
    min-width: 0;
}
.overview-legend-col {
    flex: 0 0 auto;
    position: sticky;
    top: 180px;
    align-self: flex-start;
}

/* Legend wrapper: always in DOM, hidden on screen unless toggled on, always shown on print */
.legend-screen-hidden {
    display: none;
}

/* ====================================================================
   Print styles — Ctrl+P on patient page produces clean output
   ==================================================================== */
@media print {
    /* Lock paper size + margins so the browser doesn't apply its own
       fit-to-page scaling on top of our zoom. */
    @page {
        size: letter portrait;
        margin: 0.35in;
    }

    /* Zero out every top-edge wrapper between the page and the patient header.
       Browser page header is outside our control; this eliminates every pixel on our side. */
    html,
    body,
    #app,
    .mud-layout,
    .mud-main-content,
    .main-content,
    .mud-container {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* MudTabs internal wrappers — all can contribute vertical spacing */
    .mud-tabs,
    .mud-tabs-content,
    .mud-tabs-panels,
    .mud-tabs-panels-wrapper,
    .mud-tabs-tabbar-wrapper,
    .mud-tabs-tabbar-inner {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    .mud-tabpanel,
    .mud-tabpanel:first-of-type {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* Print-header: kill its own top margin so it butts against page top */
    .print-header {
        margin-top: 0 !important;
    }

    /* Always reveal the legend on print, even when not toggled on screen */
    .legend-screen-hidden {
        display: block !important;
    }

    /* On print, keep body + legend side-by-side but drop the legend to
       the bottom of the row so its bottom edge lines up with the feet.
       Reset the on-screen sticky positioning so it doesn't offset the print layout. */
    .overview-legend-col {
        align-self: flex-end !important;
        position: static !important;
        top: auto !important;
    }

    /* Shrink the body + legend row so it fits one printed page.
       The body diagram has a fixed height (~1018px including the foot
       section) that's always taller than one portrait page at 100%,
       so the scale is unconditional. `zoom` (not `transform: scale`)
       resizes the layout box itself so page-break math matches paint. */
    .print-fit-row {
        zoom: 0.75;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Show print-only elements */
    .print-only {
        display: block !important;
    }

    /* Hide overview navigation panel (visit selector, nav buttons, progress) */
    .overview-nav-panel {
        display: none !important;
    }

    /* Kill the MudPaper container box around tabs (Elevation="2" Rounded="true").
       Need border, border-radius, box-shadow, and background transparent so no
       rectangular outline appears around the body content in print. */
    .mud-tabs,
    .mud-tabs-content,
    .mud-tabs-panels,
    .mud-tabs-panels-wrapper {
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
        background-color: transparent !important;
    }

    /* Reduce tab panel padding for print */
    .mud-tabpanel {
        padding: 8px 0 !important;
    }

    /* Keep body diagram and foot sections from splitting across pages */
    .overview-body-diagram {
        page-break-inside: avoid;
    }

    .overview-foot-section {
        page-break-inside: avoid;
    }
    /* Show the print-only patient header — name left, DOB right, same line */
    .print-header {
        display: flex !important;
    }

    /* Hide UI chrome */
    .mud-appbar,
    .mud-tabs-tabbar,
    .visit-history-controls,
    .visit-download-col,
    .visit-show-all,
    .care-metrics-panel,
    .structured-note-narrative,
    .print-hide {
        display: none !important;
    }

    /* Hide edit pencil icons in tables */
    .mud-table .mud-iconbutton-root {
        display: none !important;
    }

    /* Remove elevation shadows, borders, rounded corners, and tinted backgrounds
       so no paper container box outlines the printed body content. */
    .mud-paper {
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
        background-color: transparent !important;
    }

    /* Remove top padding that accommodates the fixed nav bar */
    .main-content {
        padding-top: 0 !important;
    }

    /* Prevent table overflow clipping */
    .mud-table-container {
        overflow: visible !important;
    }

    /* Preserve background colors (chips, badges) */
    * {
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    /* Prevent rows from splitting across pages */
    .mud-table-row {
        page-break-inside: avoid;
    }
}

/* NotesField: expose native vertical drag-handle on the underlying textarea.
   MudBlazor filters `style` out of UserAttributes, so we apply via class. */
.notes-field textarea.mud-input-slot {
    resize: vertical;
}
/* ====================================================================
   Boot splash overlay
   Shown while WASM downloads / Blazor starts. Sits above #app with a
   fade-out transition. See index.html boot script for lifecycle.
   ==================================================================== */
#splash-overlay {
    position: fixed;
    inset: 0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 400ms ease;
}

#splash-overlay .splash-video {
    width: 200px;
    height: 200px;
    object-fit: contain;
}

/* When the app has already booted once in this session, skip the splash entirely.
   Set by the head inline script reading sessionStorage. */
html.boot-cached #splash-overlay { display: none; }
