/* ====================================================================
   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: 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,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaW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NzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) 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: #C62828;
            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, #e3f2fd 0%, #f3e5f5 100%);
    border-left: 4px solid var(--mud-palette-primary);
    border-radius: 4px;
    font-size: 0.875rem;
    color: #333;
}

.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;
}

/* 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;
}

/* Transparent overlay behind mini-popover -- catches "click outside" to close popover.
   Covers entire viewport so clicks on buttons, labels, diagrams all dismiss the popover.
   Only the popover itself (z-index: 1001) sits above this overlay. */
.popover-click-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    background: transparent;
    cursor: default;
}

/* Mini-popover centered overlay (absolute within .assessment-panel-container) */
.mini-popover-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    pointer-events: auto;
}

/* 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;
    transition: all 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.pop-badge:active {
    transform: scale(0.95);
}

.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;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

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

.popover-action-btn:active {
    transform: scale(0.97);
}

.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;
    transition: all 0.15s ease;
}

.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;
}

/* ====================================================================
   Print styles — Ctrl+P on patient page produces clean output
   ==================================================================== */
@media print {
    /* Show print-only elements */
    .print-only {
        display: block !important;
    }

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

    /* Remove tab container border/rounding for clean print */
    .mud-tabs {
        border: none !important;
        border-radius: 0 !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 */
    .print-header {
        display: block !important;
    }

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

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

    /* Remove elevation shadows */
    .mud-paper {
        box-shadow: none !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;
    }
}