﻿/* ============================================================
   XMPFormViewer.css
   Theme: XManagementPro — refined professional, slate/blue
   Structural classes: .fv-*   (matches XMPFormViewer.razor)
   Button modifiers:   .xfv-btn-*
   FieldOverlay:       .fo-*
   CSS variables:      --fv-*
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

/* ── Design Tokens ── */
:root {
    --fv-bg: #f0f2f8;
    --fv-surface: #ffffff;
    --fv-surface2: #f6f8fc;
    --fv-surface3: #edf0f7;
    --fv-border: #d4daea;
    --fv-border-light: #bcc5d9;
    --fv-accent: #5b8dee;
    --fv-accent-dark: #3a6fd8;
    --fv-accent-soft: #e8f0fd;
    --fv-green: #27b08b;
    --fv-green-soft: #e6f7f3;
    --fv-green-dark: #1d8f70;
    --fv-warning: #e8943a;
    --fv-warning-soft: #fef3e7;
    --fv-danger: #e05c6a;
    --fv-danger-soft: #fdeef0;
    --fv-purple: #7c5cbf;
    --fv-purple-soft: #f0ebfb;
    --fv-text: #1e2a45;
    --fv-text-muted: #6b7a99;
    --fv-text-dim: #a0aabf;
    --fv-canvas-bg: #182848;
    --fv-radius: 6px;
    --fv-radius-lg: 10px;
    --fv-shadow-sm: 0 1px 4px rgba(30,42,69,0.08);
    --fv-shadow: 0 4px 16px rgba(30,42,69,0.12);
    --fv-shadow-lg: 0 8px 32px rgba(30,42,69,0.18);
    --fv-transition: 0.16s ease;
}

/* ─────────────────────────────────────────────────────────────────────────────
   ROOT SHELL
   ───────────────────────────────────────────────────────────────────────────── */
.xfv-root {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--fv-text);
    background: var(--fv-bg);
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 500px;
    border-radius: var(--fv-radius-lg);
    border: 1px solid var(--fv-border);
    box-shadow: var(--fv-shadow);
    overflow: hidden;
    position: relative;
}

    .xfv-root * {
        box-sizing: border-box;
    }

/* ─────────────────────────────────────────────────────────────────────────────
   HEADER  (.fv-header)
   ───────────────────────────────────────────────────────────────────────────── */
.fv-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    background: linear-gradient(135deg, #2c3e72 0%, #3a5298 100%);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.fv-header-title {
    flex: 1;
    min-width: 0;
}

    .fv-header-title h1 {
        font-size: 14px;
        font-weight: 600;
        margin: 0;
        color: #ffffff;
        letter-spacing: 0.01em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .fv-header-title p {
        font-size: 11px;
        color: rgba(255,255,255,0.6);
        margin: 2px 0 0;
    }

.fv-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Header buttons — glass style override */
.fv-header .fv-btn {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.22);
    color: rgba(255,255,255,0.9);
    font-size: 11px;
    padding: 4px 10px;
}

    .fv-header .fv-btn:hover {
        background: rgba(255,255,255,0.22);
        border-color: rgba(255,255,255,0.35);
        color: #fff;
    }

    .fv-header .fv-btn.xfv-btn-primary {
        background: #fff;
        border-color: #fff;
        color: var(--fv-accent-dark);
    }

        .fv-header .fv-btn.xfv-btn-primary:hover {
            background: rgba(255,255,255,0.88);
        }

/* Mode toggle pill */
.fv-mode-toggle {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px;
    padding: 2px;
}

.fv-mode-btn {
    padding: 4px 12px;
    border-radius: 16px;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    color: rgba(255,255,255,0.7);
    background: transparent;
    transition: all var(--fv-transition);
    white-space: nowrap;
}

    .fv-mode-btn.active {
        background: #ffffff;
        color: var(--fv-accent-dark);
        box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    }

    .fv-mode-btn:hover:not(.active) {
        color: #ffffff;
        background: rgba(255,255,255,0.15);
    }

/* ─────────────────────────────────────────────────────────────────────────────
   TOOLBAR  (.fv-toolbar)
   ───────────────────────────────────────────────────────────────────────────── */
.fv-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 18px;
    background: var(--fv-surface);
    border-bottom: 1px solid var(--fv-border);
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 38px;
}

.fv-toolbar-sep {
    width: 1px;
    height: 18px;
    background: var(--fv-border);
    margin: 0 4px;
    flex-shrink: 0;
}

.fv-toolbar-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--fv-text-muted);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* Page nav */
.fv-page-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

    .fv-page-nav span {
        font-size: 11px;
        color: var(--fv-text-muted);
        min-width: 55px;
        text-align: center;
    }

/* Zoom */
.fv-zoom-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.fv-zoom-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--fv-text);
    min-width: 36px;
    text-align: center;
}

/* Field type palette */
.fv-field-palette {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.fv-palette-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 12px;
    border: 1px solid var(--fv-border);
    background: var(--fv-surface2);
    color: var(--fv-text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--fv-transition);
    user-select: none;
}

    .fv-palette-chip:hover {
        border-color: var(--fv-accent);
        color: var(--fv-accent);
        background: var(--fv-accent-soft);
    }

    .fv-palette-chip.active {
        border-color: var(--fv-accent);
        background: var(--fv-accent);
        color: #fff;
    }

/* Scope toggle */
.fv-scope-toggle {
    display: flex;
    align-items: center;
    background: var(--fv-surface3);
    border: 1px solid var(--fv-border);
    border-radius: 14px;
    padding: 2px;
}

.fv-scope-btn {
    padding: 3px 10px;
    border-radius: 11px;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    background: transparent;
    color: var(--fv-text-muted);
    transition: all var(--fv-transition);
    white-space: nowrap;
}

    .fv-scope-btn.active-form {
        background: var(--fv-accent);
        color: #fff;
        box-shadow: var(--fv-shadow-sm);
    }

    .fv-scope-btn.active-matter {
        background: var(--fv-purple);
        color: #fff;
        box-shadow: var(--fv-shadow-sm);
    }

/* ─────────────────────────────────────────────────────────────────────────────
   BODY: 3-COLUMN LAYOUT
   ───────────────────────────────────────────────────────────────────────────── */
.fv-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Left panel: thumbnails.
   When the viewer is hosted inside .fvp-main (XMPFormViewerPage),
   the parent shell provides a real bounded height and height:100%
   works correctly — XMPFormViewerPage.css overrides max-height there.
   When used standalone (e.g. in a modal or a page without the shell),
   the dvh fallback keeps the panel from overflowing the viewport. */
.fv-panel-left {
    width: 130px;
    flex-shrink: 0;
    background: var(--fv-surface);
    border-right: 1px solid var(--fv-border);
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 120px);
    overflow-y: auto;
    overflow-x: hidden;
}

    .fv-panel-left::-webkit-scrollbar {
        width: 4px;
    }

    .fv-panel-left::-webkit-scrollbar-track {
        background: var(--fv-bg);
    }

    .fv-panel-left::-webkit-scrollbar-thumb {
        background: var(--fv-border);
        border-radius: 2px;
    }

.fv-thumb-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 8px;
}

.fv-thumb-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--fv-radius);
    border: 2px solid transparent;
    transition: all var(--fv-transition);
}

    .fv-thumb-item:hover {
        background: var(--fv-surface3);
        border-color: var(--fv-border-light);
    }

    .fv-thumb-item.active {
        border-color: var(--fv-accent);
        background: var(--fv-accent-soft);
    }

    .fv-thumb-item img {
        width: 100%;
        border-radius: 3px;
        display: block;
        box-shadow: var(--fv-shadow-sm);
    }

.fv-thumb-label {
    font-size: 10px;
    color: var(--fv-text-muted);
    font-weight: 500;
}

.fv-thumb-item.active .fv-thumb-label {
    color: var(--fv-accent-dark);
    font-weight: 600;
}

/* Center panel: canvas */
.fv-panel-center {
    flex: 1;
    overflow: auto;
    background: var(--fv-canvas-bg);
    display: flex;
    justify-content: flex-start; /* don't center — centering clips left side on wide zoom */
    padding: 20px;
    min-width: 0;
}

    .fv-panel-center::-webkit-scrollbar {
        width: 5px;
        height: 5px;
    }

    .fv-panel-center::-webkit-scrollbar-track {
        background: var(--fv-canvas-bg);
    }

    .fv-panel-center::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.2);
        border-radius: 3px;
    }

        .fv-panel-center::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.3);
        }

.fv-canvas-wrap {
    position: relative;
    flex-shrink: 0;
    align-self: flex-start;
    margin: 0 auto; /* center horizontally when canvas fits; scrollable when it doesn't */
}

    .fv-canvas-wrap canvas {
        display: block;
        border-radius: 2px;
        box-shadow: 0 4px 32px rgba(0,0,0,0.5);
    }

    .fv-canvas-wrap.design-active {
        cursor: crosshair;
    }

/* Right panel: properties */
.fv-panel-right {
    width: 220px;
    flex-shrink: 0;
    background: var(--fv-surface);
    border-left: 1px solid var(--fv-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

    .fv-panel-right::-webkit-scrollbar {
        width: 4px;
    }

    .fv-panel-right::-webkit-scrollbar-track {
        background: var(--fv-bg);
    }

    .fv-panel-right::-webkit-scrollbar-thumb {
        background: var(--fv-border);
        border-radius: 2px;
    }

.fv-props-header {
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--fv-border);
    background: linear-gradient(180deg, #f6f8fc 0%, #edf0f7 100%);
    flex-shrink: 0;
}

    .fv-props-header h3 {
        font-size: 11px;
        font-weight: 600;
        color: var(--fv-text-muted);
        margin: 0;
        text-transform: uppercase;
        letter-spacing: 0.07em;
    }

.fv-props-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.fv-props-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 32px 16px;
    color: var(--fv-text-dim);
    font-size: 11px;
    text-align: center;
}

.fv-props-empty-icon {
    font-size: 22px;
    opacity: 0.4;
}

.fv-prop-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fv-prop-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--fv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.fv-prop-value {
    font-size: 12px;
    color: var(--fv-text);
    padding: 5px 7px;
    background: var(--fv-surface2);
    border: 1px solid var(--fv-border);
    border-radius: var(--fv-radius);
    word-break: break-word;
}

.fv-prop-input {
    font-size: 12px;
    color: var(--fv-text);
    padding: 5px 7px;
    background: #fff;
    border: 1px solid var(--fv-border);
    border-radius: var(--fv-radius);
    font-family: 'Inter', sans-serif;
    outline: none;
    width: 100%;
    transition: border-color var(--fv-transition), box-shadow var(--fv-transition);
}

    .fv-prop-input:focus {
        border-color: var(--fv-accent);
        box-shadow: 0 0 0 3px rgba(91,141,238,0.15);
    }

.fv-prop-row2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.fv-prop-divider {
    height: 1px;
    background: var(--fv-border);
    margin: 2px 0;
}

.fv-props-actions {
    padding: 10px 12px;
    border-top: 1px solid var(--fv-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

/* Field type badge */
.fv-field-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
}

    .fv-field-badge.text {
        background: var(--fv-accent-soft);
        color: var(--fv-accent-dark);
    }

    .fv-field-badge.date {
        background: var(--fv-green-soft);
        color: var(--fv-green-dark);
    }

    .fv-field-badge.check {
        background: var(--fv-warning-soft);
        color: var(--fv-warning);
    }

    .fv-field-badge.radio {
        background: var(--fv-warning-soft);
        color: var(--fv-warning);
    }

    .fv-field-badge.choice {
        background: var(--fv-purple-soft);
        color: var(--fv-purple);
    }

    .fv-field-badge.sig {
        background: var(--fv-danger-soft);
        color: var(--fv-danger);
    }

/* Scope badge */
.fv-scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

    .fv-scope-badge.form {
        background: var(--fv-accent-soft);
        color: var(--fv-accent-dark);
    }

    .fv-scope-badge.matter {
        background: var(--fv-purple-soft);
        color: var(--fv-purple);
    }

    .fv-scope-badge.parsed {
        background: var(--fv-surface3);
        color: var(--fv-text-muted);
    }

/* Mapper panel */
.fv-mapper-panel {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.fv-mapper-select {
    font-size: 12px;
    color: var(--fv-text);
    padding: 6px 8px;
    background: #fff;
    border: 1px solid var(--fv-border);
    border-radius: var(--fv-radius);
    font-family: 'Inter', sans-serif;
    outline: none;
    width: 100%;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7a99'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
    cursor: pointer;
    transition: border-color var(--fv-transition), box-shadow var(--fv-transition);
}

    .fv-mapper-select:focus {
        border-color: var(--fv-accent);
        box-shadow: 0 0 0 3px rgba(91,141,238,0.15);
    }

/* ─────────────────────────────────────────────────────────────────────────────
   BUTTONS  (.fv-btn  +  .xfv-btn-* modifiers)
   ───────────────────────────────────────────────────────────────────────────── */
.fv-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: var(--fv-radius);
    border: 1px solid var(--fv-border);
    background: var(--fv-surface);
    color: var(--fv-text);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--fv-transition), border-color var(--fv-transition), color var(--fv-transition), box-shadow var(--fv-transition);
    white-space: nowrap;
    user-select: none;
    line-height: 1;
    flex-shrink: 0;
}

    .fv-btn:hover {
        background: var(--fv-surface3);
        border-color: var(--fv-border-light);
    }

    .fv-btn:active {
        transform: translateY(1px);
    }

.xfv-btn-sm {
    padding: 4px 9px !important;
    font-size: 11px !important;
}

.xfv-btn-icon {
    padding: 4px 7px !important;
    min-width: 28px;
    justify-content: center;
}

.xfv-btn-primary {
    background: var(--fv-accent);
    border-color: var(--fv-accent);
    color: #fff;
}

    .xfv-btn-primary:hover {
        background: var(--fv-accent-dark);
        border-color: var(--fv-accent-dark);
    }

.xfv-btn-success {
    background: var(--fv-green);
    border-color: var(--fv-green);
    color: #fff;
}

    .xfv-btn-success:hover {
        background: var(--fv-green-dark);
        border-color: var(--fv-green-dark);
    }

.xfv-btn-danger {
    background: transparent;
    border-color: var(--fv-danger);
    color: var(--fv-danger);
}

    .xfv-btn-danger:hover {
        background: var(--fv-danger-soft);
    }

.xfv-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--fv-text-muted);
}

    .xfv-btn-ghost:hover {
        background: var(--fv-surface3);
        color: var(--fv-text);
        border-color: var(--fv-border);
    }

/* ─────────────────────────────────────────────────────────────────────────────
   STATUS BAR  (.fv-status-bar)
   ───────────────────────────────────────────────────────────────────────────── */
.fv-status-bar {
    padding: 4px 18px;
    background: var(--fv-surface);
    border-top: 1px solid var(--fv-border);
    font-size: 10px;
    color: var(--fv-text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.fv-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--fv-green);
    flex-shrink: 0;
}

    .fv-status-dot.design {
        background: var(--fv-accent);
    }

    .fv-status-dot.matter {
        background: var(--fv-purple);
    }

    .fv-status-dot.warning {
        background: var(--fv-warning);
    }

.fv-status-sep {
    color: var(--fv-border);
}

/* ─────────────────────────────────────────────────────────────────────────────
   TOAST  (.fv-toast)
   ───────────────────────────────────────────────────────────────────────────── */
.fv-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--fv-text);
    color: #fff;
    border-radius: var(--fv-radius);
    padding: 9px 14px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--fv-shadow-lg);
    z-index: 1000;
    max-width: 280px;
    border-left: 3px solid var(--fv-green);
    animation: fv-toast-in 0.18s ease;
    font-family: 'Inter', sans-serif;
}

    .fv-toast.warning {
        border-left-color: var(--fv-warning);
    }

    .fv-toast.error {
        border-left-color: var(--fv-danger);
    }

@keyframes fv-toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   CONTEXT MENU  (.fv-context-menu)
   ───────────────────────────────────────────────────────────────────────────── */
.fv-context-menu {
    position: absolute;
    background: var(--fv-surface);
    border: 1px solid var(--fv-border);
    border-radius: var(--fv-radius);
    box-shadow: var(--fv-shadow-lg);
    z-index: 500;
    padding: 4px 0;
    min-width: 160px;
    font-family: 'Inter', sans-serif;
    animation: fv-fade-in 0.1s ease;
}

@keyframes fv-fade-in {
    from {
        opacity: 0;
        transform: scale(0.97);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.fv-context-menu-header {
    padding: 5px 12px 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--fv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-bottom: 1px solid var(--fv-border);
    margin-bottom: 3px;
}

.fv-context-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--fv-text);
    cursor: pointer;
    transition: background var(--fv-transition);
    user-select: none;
}

    .fv-context-item:hover {
        background: var(--fv-surface3);
    }

    .fv-context-item.matter {
        color: var(--fv-purple);
    }

        .fv-context-item.matter:hover {
            background: var(--fv-purple-soft);
        }

.fv-context-sep {
    height: 1px;
    background: var(--fv-border);
    margin: 3px 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   MODAL  (.xfv-modal-*)
   ───────────────────────────────────────────────────────────────────────────── */
.xfv-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30,42,69,0.45);
    backdrop-filter: blur(2px);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fv-fade-in 0.14s ease;
}

.xfv-modal {
    background: #fff;
    border: 1px solid var(--fv-border);
    border-radius: var(--fv-radius-lg);
    box-shadow: var(--fv-shadow-lg);
    width: 100%;
    max-width: 400px;
    animation: fv-modal-in 0.18s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes fv-modal-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.xfv-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--fv-border);
    background: linear-gradient(180deg, #f6f8fc 0%, #edf0f7 100%);
    border-radius: var(--fv-radius-lg) var(--fv-radius-lg) 0 0;
}

    .xfv-modal-header h2 {
        font-size: 13px;
        font-weight: 600;
        margin: 0;
        color: var(--fv-text);
    }

.xfv-modal-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.xfv-modal-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--fv-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--fv-surface2);
    border-radius: 0 0 var(--fv-radius-lg) var(--fv-radius-lg);
}

.xfv-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

    .xfv-field label {
        font-size: 11px;
        font-weight: 600;
        color: var(--fv-text-muted);
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

.xfv-input,
.xfv-select {
    background: #fff;
    border: 1px solid var(--fv-border);
    border-radius: var(--fv-radius);
    color: var(--fv-text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    padding: 7px 9px;
    outline: none;
    width: 100%;
    transition: border-color var(--fv-transition), box-shadow var(--fv-transition);
}

    .xfv-input:focus,
    .xfv-select:focus {
        border-color: var(--fv-accent);
        box-shadow: 0 0 0 3px rgba(91,141,238,0.15);
    }

/* ─────────────────────────────────────────────────────────────────────────────
   FIELD OVERLAY COMPONENT  (.fo-*)
   ───────────────────────────────────────────────────────────────────────────── */

/* Fill-mode inputs */
.fo-input {
    position: absolute;
    box-sizing: border-box;
    background: rgba(173,216,230,0.35);
    border: 1px solid rgba(99,155,191,0.55);
    border-radius: 2px;
    font-family: 'Courier New', Courier, monospace;
    font-size: calc(9px * var(--fo-scale, 1.5));
    font-weight: 600;
    color: var(--fv-text);
    padding: 1px 3px;
    outline: none;
    transition: border-color var(--fv-transition), box-shadow var(--fv-transition), background var(--fv-transition);
}

    .fo-input:focus {
        background: rgba(173,216,230,0.6);
        border-color: var(--fv-accent);
        box-shadow: 0 0 0 2px rgba(91,141,238,0.18);
        z-index: 10;
    }

.fo-textarea {
    resize: vertical;
    overflow-y: auto;
    /* line-height is set inline from LineSpacingFactor (PDF points → CSS px at current scale) */
}

.fo-select {
    cursor: pointer;
    appearance: auto;
}

.fo-date {
    cursor: pointer;
}

.fo-signature {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245,228,255,0.45);
    border: 1.5px dashed rgba(139,92,246,0.55);
    border-radius: 3px;
    cursor: pointer;
}

.fo-sig-label {
    font-size: calc(8px * var(--fo-scale, 1.5));
    color: rgba(139,92,246,0.8);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    pointer-events: none;
    white-space: nowrap;
}

/* Checkbox */
.fo-checkbox-wrap {
    display: block;
    position: absolute;
    cursor: pointer;
}

/* Comb text field — fixed-width character cells */
/* Comb modifier — only adds spacing behaviour, inherits all .fo-input visuals */
.fo-comb {
    overflow: hidden;
    /* Space characters evenly: gap between char centers = one cell width.    */
    /* letter-spacing = cellW - ~0.6em (monospace char width at current size) */
    letter-spacing: calc(var(--fo-cell-w, 14px) - 0.6em);
    /* Nudge first character to sit centred in cell 1                         */
    padding-left: calc(var(--fo-cell-w, 14px) * 0.2);
    padding-right: 0;
}

.fo-checkbox {
    position: relative;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background: PaleTurquoise;
    border: 1px solid #99AFC1;
    border-radius: 3px;
    transition: background 0.12s, border-color 0.12s;
}

    .fo-checkbox::after {
        content: "";
        display: block;
        position: absolute;
        width: calc(var(--fo-w, 14px) * 0.3);
        height: calc(var(--fo-h, 14px) * 0.55);
        border: solid #1e3a5f;
        border-width: 0 2.5px 2.5px 0;
        transform: rotate(45deg) scale(0);
        top: calc(var(--fo-h, 14px) * 0.1);
        left: calc(var(--fo-w, 14px) * 0.35);
        transition: transform 0.1s ease;
    }

    .fo-checkbox:checked {
        background: rgba(59,130,246,0.25);
        border-color: var(--fv-accent);
    }

        .fo-checkbox:checked::after {
            transform: rotate(45deg) scale(1);
        }

/* Radio — styled as square checkmark boxes matching AcroForm appearance */
.fo-radio-wrap {
    display: block;
    position: absolute;
    margin: 0;
    padding: 0;
    cursor: pointer;
    box-sizing: border-box;
}

.fo-radio {
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    padding: 0;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background: PaleTurquoise;
    border: 1px solid #99AFC1;
    border-radius: 3px;
    box-sizing: border-box;
    transition: background 0.12s, border-color 0.12s;
}

    .fo-radio::after {
        content: "";
        display: block;
        position: absolute;
        width: calc(var(--fo-w, 14px) * 0.3);
        height: calc(var(--fo-h, 14px) * 0.55);
        border: solid #1e3a5f;
        border-width: 0 2.5px 2.5px 0;
        transform: rotate(45deg) scale(0);
        top: calc(var(--fo-h, 14px) * 0.1);
        left: calc(var(--fo-w, 14px) * 0.35);
        transition: transform 0.1s ease;
    }

    .fo-radio:checked {
        background: rgba(59,130,246,0.25);
        border-color: var(--fv-accent);
    }

        .fo-radio:checked::after {
            transform: rotate(45deg) scale(1);
        }

/* Design-mode overlay tile */
.fo-overlay {
    position: absolute;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1.5px solid rgba(99,155,191,0.5);
    border-radius: 3px;
    background: rgba(173,216,230,0.28);
    cursor: pointer;
    user-select: none;
    transition: border-color var(--fv-transition), background var(--fv-transition), box-shadow var(--fv-transition);
}

    .fo-overlay:hover {
        border-color: var(--fv-accent);
        background: rgba(91,141,238,0.1);
        z-index: 2;
    }

    .fo-overlay.fo-selected {
        border-color: var(--fv-accent);
        background: rgba(91,141,238,0.15);
        box-shadow: 0 0 0 2px rgba(91,141,238,0.35), 0 2px 8px rgba(91,141,238,0.2);
        z-index: 3;
        animation: fo-pulse 1.8s ease-in-out infinite;
    }

@keyframes fo-pulse {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(91,141,238,0.35), 0 2px 8px rgba(91,141,238,0.2);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(91,141,238,0.18), 0 4px 14px rgba(91,141,238,0.28);
    }
}

.fo-overlay.fo-mapped {
    border-color: rgba(91,141,238,0.65);
    background: rgba(91,141,238,0.12);
}

    .fo-overlay.fo-mapped:hover {
        background: rgba(91,141,238,0.22);
        border-color: var(--fv-accent);
    }

.fo-overlay.fo-matter {
    border-color: rgba(124,92,191,0.6);
    background: rgba(124,92,191,0.1);
    border-style: dashed;
}

    .fo-overlay.fo-matter:hover {
        background: rgba(124,92,191,0.2);
        border-color: var(--fv-purple);
    }

.fo-overlay.fo-user {
    border-style: dashed;
}

.fo-label {
    font-size: calc(7px * var(--fo-scale, 1.5));
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
    color: rgba(30,58,95,0.85);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 24px);
    pointer-events: none;
}

.fo-overlay.fo-mapped .fo-label {
    color: var(--fv-accent-dark);
}

.fo-overlay.fo-matter .fo-label {
    color: var(--fv-purple);
}

.fo-type-badge {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: calc(6px * var(--fo-scale, 1.5));
    font-weight: 800;
    line-height: 1;
    pointer-events: none;
    opacity: 0.7;
}

.fo-badge-text {
    color: #1e3a5f;
}

.fo-badge-date {
    color: var(--fv-green-dark);
}

.fo-badge-check {
    color: var(--fv-warning);
}

.fo-badge-radio {
    color: var(--fv-warning);
}

.fo-badge-choice {
    color: var(--fv-purple);
}

.fo-badge-sig {
    color: var(--fv-danger);
}

.fo-matter-badge {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: calc(6px * var(--fo-scale, 1.5));
    font-weight: 900;
    color: var(--fv-purple);
    background: rgba(124,92,191,0.15);
    border-radius: 2px;
    padding: 0 2px;
    pointer-events: none;
    line-height: 1.5;
}

.fo-drag-handle {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 10px;
    cursor: move;
    font-size: calc(7px * var(--fo-scale, 1.5));
    line-height: 10px;
    text-align: center;
    color: rgba(100,116,139,0.7);
    transition: color var(--fv-transition);
    z-index: 5;
}

    .fo-drag-handle:hover {
        color: var(--fv-accent);
    }

.fo-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 10px;
    height: 10px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(100,116,139,0.55) 50%);
    border-radius: 0 0 3px 0;
    z-index: 5;
    transition: background var(--fv-transition);
}

    .fo-resize-handle:hover {
        background: linear-gradient(135deg, transparent 50%, var(--fv-accent) 50%);
    }

/* ─────────────────────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .fv-panel-left {
        width: 90px;
    }

    .fv-panel-right {
        width: 180px;
    }
}

@media (max-width: 680px) {
    .fv-panel-left {
        display: none;
    }

    .fv-panel-right {
        display: none;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   PHASE 6 — MATTER MODE ADDITIONS
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Header: Reload Mapped button ───────────────────────────── */
.fv-btn-matter-reload {
    background: rgba(39,176,139,0.18);
    border-color: rgba(39,176,139,0.35);
    color: rgba(220,255,245,0.92);
}

    .fv-btn-matter-reload:hover {
        background: rgba(39,176,139,0.30);
        border-color: rgba(39,176,139,0.55);
        color: #fff;
    }

/* ── Reload confirm dialog: danger outline button ─────────────── */
.fv-btn-danger-outline {
    background: rgba(224,92,106,0.12);
    border-color: rgba(224,92,106,0.40);
    color: rgba(255,180,185,0.95);
}

    .fv-btn-danger-outline:hover {
        background: rgba(224,92,106,0.25);
        border-color: rgba(224,92,106,0.65);
        color: #fff;
    }

/* ── Mapped field: tinted border overlay ─────────────────────── */
/*
   .fo-map-indicator sits absolutely over the input.
   pointer-events: none so it never blocks input interaction.
   Blue  = actively mapped (value from DB, not overridden).
   Orange = user has manually overridden the mapped value.
*/
.fo-map-indicator {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid rgba(91,141,238,0.55);
    border-radius: 3px;
    background: rgba(91,141,238,0.06);
    pointer-events: none;
    z-index: 4;
    transition: border-color 0.15s, background 0.15s;
}

.fo-map-indicator--override {
    border-color: rgba(232,148,58,0.65);
    background: rgba(232,148,58,0.07);
}

/* ── Mapped field: ↺ load button ────────────────────────────── */
/*
   Absolutely positioned at the top-right of the field.
   Hidden (opacity: 0) until the canvas-wrap is hovered.
   16×16px — small and unobtrusive.
*/
.fo-map-load-btn {
    position: absolute;
    width: 18px;
    height: 18px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    line-height: 1;
    border-radius: 3px;
    border: 1px solid rgba(91,141,238,0.5);
    background: rgba(91,141,238,0.18);
    color: rgba(91,141,238,0.9);
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.15s, background 0.13s, color 0.13s;
    user-select: none;
}

    /* Reveal on canvas hover or button focus */
    .fv-canvas-wrap:hover .fo-map-load-btn,
    .fo-map-load-btn:focus {
        opacity: 1;
    }

    .fo-map-load-btn:hover {
        background: rgba(91,141,238,0.35);
        border-color: rgba(91,141,238,0.75);
        color: #fff;
    }

/* Override variant — orange palette */
.fo-map-load-btn--override {
    border-color: rgba(232,148,58,0.55);
    background: rgba(232,148,58,0.18);
    color: rgba(232,148,58,0.9);
}

    .fo-map-load-btn--override:hover {
        background: rgba(232,148,58,0.35);
        border-color: rgba(232,148,58,0.75);
        color: #fff;
    }

/* Above variant — floated above small fields (checkboxes, radio buttons)
   so the button never overlaps the input hit-target.
   A downward arrow connector shows which field it belongs to.          */
.fo-map-load-btn--above {
    width: 16px;
    height: 16px;
    font-size: 10px;
}

    .fo-map-load-btn--above::after {
        content: '';
        position: absolute;
        bottom: -5px;
        right: 3px;
        width: 0;
        height: 0;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 5px solid rgba(91,141,238,0.75);
        pointer-events: none;
    }

.fo-map-load-btn--override.fo-map-load-btn--above::after {
    border-top-color: rgba(232,148,58,0.75);
}
