/* =============================================================================
   Agent Meeko - Medical form widgets (body chart, pain scale, outcome measure,
   before and after photos, booking request)

   Loaded by the app (builder preview and staff answer view), form.html and
   the client portal. Each page names its tokens differently, so every colour
   falls back through the app's theme token, then the public pages' own, then
   a neutral. Severity colours on pins are fixed in the script on purpose.
   ============================================================================= */

.mfw {
    --mfw-text: var(--text-primary, var(--text, #0f1115));
    --mfw-muted: var(--text-muted, var(--muted, #8b929b));
    --mfw-border: var(--border-default, var(--border, #e3e7ea));
    --mfw-strong: var(--border-strong, #c9ced6);
    --mfw-subtle: var(--surface-subtle, var(--subtle, var(--bg, #f7f8f9)));
    --mfw-surface: var(--surface-panel, var(--card, #ffffff));
    --mfw-accent: var(--accent, #19213b);
    --mfw-danger: var(--status-danger, var(--danger, #d92d20));
    --mfw-radius: 10px;
    color: var(--mfw-text);
    font-size: 14px;
    line-height: 1.45;
}

.mfw-hint { margin: 0 0 8px; font-size: 12.5px; color: var(--mfw-muted); }
.mfw-muted { color: var(--mfw-muted); font-size: 12.5px; }
.mfw-problem { margin: 6px 0 0; font-size: 12.5px; color: var(--mfw-danger); }

.mfw .mfw-input {
    display: block; width: 100%; box-sizing: border-box;
    padding: 10px 12px; margin: 0;
    border: 1px solid var(--mfw-border); border-radius: var(--mfw-radius);
    background: var(--mfw-surface); color: var(--mfw-text);
    font: inherit; font-size: 14px;
}
.mfw .mfw-input:focus { outline: none; border-color: var(--mfw-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mfw-accent) 18%, transparent); }

.mfw-link {
    border: 0; background: none; padding: 4px 6px; margin: 0;
    font: inherit; font-size: 12.5px; font-weight: 600;
    color: var(--mfw-accent); cursor: pointer; border-radius: 6px;
}
.mfw-link:hover { background: var(--mfw-subtle); }
.mfw-link--danger { color: var(--mfw-danger); }

/* ---- body chart --------------------------------------------------------- */

.mfw-chart__head {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    margin-bottom: 8px;
}
.mfw-chart__turn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 0; margin: 0;
    border: 1px solid var(--mfw-border); border-radius: 999px;
    background: var(--mfw-surface); color: var(--mfw-muted); cursor: pointer;
}
.mfw-chart__turn:hover { color: var(--mfw-text); border-color: var(--mfw-strong); }
.mfw-chart__centre { min-width: 112px; text-align: center; }
.mfw-chart__title { font-size: 13px; font-weight: 650; }
.mfw-chart__dots { display: flex; justify-content: center; gap: 5px; margin-top: 5px; }
.mfw-chart__dot {
    width: 6px; height: 6px; padding: 0; margin: 0; border: 0; border-radius: 999px;
    background: var(--mfw-strong); cursor: pointer; transition: width .15s ease;
}
.mfw-chart__dot--on { width: 16px; background: var(--mfw-accent); }
/* The client portal styles every button's hover; the dots keep their own. */
.mfw .mfw-chart__dot:hover { background: var(--mfw-muted); }
.mfw .mfw-chart__dot--on:hover { background: var(--mfw-accent); }

.mfw-chart__stage { display: flex; justify-content: center; }
.mfw-chart__stage .mfw-chart__svg {
    width: 100%; max-width: 230px; height: auto;
    border: 1px solid var(--mfw-border); border-radius: 12px;
    background: var(--mfw-surface);
}
.mfw-chart__stage--input .mfw-chart__svg { cursor: crosshair; touch-action: manipulation; }
.mfw .mfw-body { fill: var(--mfw-subtle); stroke: var(--mfw-strong); }
.mfw-pin { cursor: pointer; }
.mfw-chart__empty { margin: 6px 0 0; text-align: center; font-size: 12px; color: var(--mfw-muted); min-height: 1em; }

.mfw-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mfw-chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 4px 11px 4px 4px; margin: 0;
    border: 1px solid var(--mfw-border); border-radius: var(--radius-chip, 4px);
    background: var(--mfw-surface); color: var(--mfw-text);
    font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.mfw-chip:hover { border-color: var(--mfw-strong); }
.mfw-chip--on { border-color: var(--mfw-text); }
.mfw-chip__num {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 20px; height: 20px; border-radius: 999px;
    color: #ffffff; font-size: 10.5px; font-weight: 700;
}
.mfw-chip__score { font-weight: 700; }

.mfw-editor {
    margin-top: 10px; padding: 12px;
    border: 1px solid var(--mfw-strong); border-radius: 12px;
    background: var(--mfw-surface);
}
.mfw-editor__top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mfw-editor__name { flex: 1; font-weight: 650; }
.mfw-editor__view { font-weight: 400; font-size: 12px; color: var(--mfw-muted); }
.mfw-levels { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.mfw-level {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 2px; margin: 0;
    border: 1px solid var(--mfw-border); border-radius: 8px;
    background: var(--mfw-surface); color: var(--mfw-muted);
    font: inherit; cursor: pointer; min-height: 44px;
}
.mfw-level:hover { border-color: var(--mfw-strong); }
.mfw-level--on { color: #ffffff; }
.mfw-level__num { font-size: 14px; font-weight: 700; line-height: 1; }
.mfw-level__label { font-size: 10px; line-height: 1.15; text-align: center; }

/* ---- pain scale --------------------------------------------------------- */

.mfw .mfw-pain__range {
    display: block; width: 100%; margin: 6px 0 4px; padding: 0;
    border: 0; background: none; box-shadow: none; accent-color: var(--mfw-accent);
}
.mfw-pain:not(.mfw-pain--answered) .mfw-pain__range { opacity: .7; }
.mfw-pain__row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12px; color: var(--mfw-muted); }
.mfw-pain__end--max { text-align: right; }
.mfw-pain__value { font-size: 14px; font-weight: 650; color: var(--mfw-text); white-space: nowrap; }

.mfw-pain-view { display: flex; align-items: center; gap: 12px; }
.mfw-meter { flex: 1; max-width: 180px; height: 6px; border-radius: 999px; background: var(--mfw-subtle); overflow: hidden; }
.mfw-meter__fill { height: 100%; background: var(--mfw-accent); border-radius: inherit; }

/* ---- outcome measure ---------------------------------------------------- */

.mfw-outcome__measure {
    display: inline-block; margin: 0 0 6px; padding: 2px 9px;
    border-radius: 999px; background: var(--mfw-subtle);
    font-size: 12px; font-weight: 600; color: var(--mfw-muted);
}
.mfw-outcome__input { max-width: 220px; }
.mfw-outcome-view { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mfw-outcome-view .mfw-outcome__measure { margin: 0; }

/* ---- before and after photos -------------------------------------------- */

.mfw-photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mfw-photo__label {
    margin-bottom: 5px; font-size: 11px; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase; color: var(--mfw-muted);
}
.mfw-photo__box {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 150px; padding: 8px; box-sizing: border-box;
    border: 1.5px dashed var(--mfw-strong); border-radius: 12px;
    background: var(--mfw-subtle); text-align: center;
}
.mfw-photo__box--view { border-style: solid; border-width: 1px; }
.mfw-photo__add {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    width: 100%; min-height: 132px; padding: 10px; margin: 0;
    border: 0; background: none; color: var(--mfw-muted); font: inherit; cursor: pointer; border-radius: 10px;
}
.mfw-photo__add:disabled { cursor: default; }
.mfw-photo__add:not(:disabled):hover { color: var(--mfw-text); }
.mfw-photo__add-title { font-size: 13.5px; font-weight: 600; color: var(--mfw-text); }
.mfw-photo__add-hint { font-size: 11.5px; }
.mfw-photo__img { display: block; max-width: 100%; max-height: 220px; border-radius: 8px; object-fit: contain; }
.mfw-photo__done, .mfw-photo__busy { font-size: 13px; color: var(--mfw-muted); }
.mfw-photo__actions { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }

/* ---- booking request ---------------------------------------------------- */

.mfw-booking { display: grid; gap: 6px; }
.mfw-booking__label { display: block; margin: 4px 0 0; font-size: 12.5px; font-weight: 600; color: var(--mfw-muted); }
.mfw-booking-view { display: grid; gap: 2px; }

/* ---- staff view of a body chart ----------------------------------------- */

.mfw-chart-view__grid { display: flex; flex-wrap: wrap; gap: 12px; }
.mfw-chart-view__fig { flex: 1 1 110px; max-width: 160px; }
.mfw-chart-view__label {
    margin-bottom: 4px; text-align: center; font-size: 10.5px; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase; color: var(--mfw-muted);
}
.mfw-chart-view__svg .mfw-chart__svg {
    display: block; width: 100%; height: auto;
    border: 1px solid var(--mfw-border); border-radius: 10px; background: var(--mfw-surface);
}
.mfw-chart-view__list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 7px; }
.mfw-chart-view__item { display: flex; align-items: flex-start; gap: 8px; }
.mfw-chart-view__line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.mfw-chart-view__name { font-weight: 600; }
.mfw-chart-view__where { font-size: 12px; color: var(--mfw-muted); }
.mfw-chart-view__note { margin: 2px 0 0; font-size: 12.5px; color: var(--mfw-muted); white-space: pre-wrap; }

/* ---- builder palette and canvas ----------------------------------------- */

.doc-palette__blocks--medical { margin-top: 2px; }
.doc-field__medical { margin-top: 8px; padding: 10px; border: 1px dashed var(--border-default, #e3e7ea); border-radius: 10px; }
.doc-field__medical-note { margin: 6px 0 0; font-size: 11.5px; color: var(--text-muted, #8b929b); }

/* Phones: 16px stops iOS zooming into a focused field. */
@media (max-width: 560px) {
    .mfw .mfw-input { font-size: 16px; }
}
@media (max-width: 420px) {
    .mfw-photos { grid-template-columns: minmax(0, 1fr); }
    .mfw-level__label { font-size: 9px; }
}
