/* Shared styling for the dumb PDF form-fill pages
   (CellarWorkRequestFormPage + BottlingRequestFormPage). */

.wmf-page {
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    background: var(--surface-subtle);
}

.wmf-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem var(--space-lg); /* 0.6rem off-scale (dense toolbar) */
    border-bottom: 1px solid var(--border-default);
    background: var(--surface-default);
    position: sticky;
    top: 0;
    z-index: var(--z-raised);
}

.wmf-toolbar h5 { margin: 0; font-size: 1.05rem; font-weight: var(--font-weight-semibold); } /* 1.05rem off-scale */
.wmf-toolbar .wmf-subtitle { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; } /* 0.78rem off-scale */
.wmf-toolbar .wmf-actions { display: flex; gap: var(--space-sm); align-items: center; }
.wmf-toolbar .wmf-dirty-dot {
    display: inline-block;
    width: 8px; height: 8px;
    background: var(--orange-500);
    border-radius: 50%;
    margin-right: 0.4rem; /* off-scale */
    vertical-align: middle;
}

.wmf-shortcut-hint {
    font-size: var(--font-size-xs);
    color: var(--text-disabled);
    margin-left: var(--space-sm);
}
.wmf-shortcut-hint kbd {
    background: var(--surface-emphasis);
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    padding: 1px 5px;
    font-family: var(--font-family-mono);
    font-size: var(--font-size-xs);
}

/* Body layout. The preview column is width-driven via the --wmf-preview-pct
   custom property (0–80, default 60). Form column takes the rest via flex: 1
   so dragging the resizer redistributes space without measuring two children.
   The form intentionally keeps its multi-column structure across desktop
   widths so it stays visually aligned with the PDF preview — single-column
   collapse only fires on real mobile viewports (see @media block below). */
.wmf-body { flex: 1; display: flex; min-height: 0; }
.wmf-body > .wmf-form-col {
    flex: 1;
    overflow: auto;
    padding: var(--space-lg) 1.25rem;
    min-width: 0;
    position: relative;
}
.wmf-body > .wmf-preview-col {
    flex: 0 0 var(--wmf-preview-pct, 60%);
    width: var(--wmf-preview-pct, 60%);
    border-left: 1px solid var(--border-default);
    background: #f5f5f5; /* off-scale gray between --gray-50 and --gray-100 */
    min-width: 0;
    transition: flex-basis var(--transition-slow), width var(--transition-slow);
    position: relative;
}
.wmf-body > .wmf-preview-col.collapsed {
    flex: 0 0 0;
    width: 0;
    border-left-width: 0;
    overflow: hidden;
}

/* Drag handle between form + preview columns. Active hit area is wider than
   the visual line so it's easy to grab even on touchpads. */
.wmf-resizer {
    flex: 0 0 6px;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    user-select: none;
    touch-action: none;
}
.wmf-resizer::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 2px;
    width: 2px;
    background: var(--border-default);
    transition: background 0.15s;
}
.wmf-resizer:hover::after,
.wmf-resizer.dragging::after { background: #2563eb; } /* Tailwind blue-600, used as resizer accent */
.wmf-resizer.dragging {
    /* While dragging, lock the cursor app-wide and disable iframe pointer
       events so a moving cursor over the PDF iframe doesn't steal mousemove. */
    cursor: col-resize;
}
body.wmf-resizing { cursor: col-resize !important; user-select: none; }
body.wmf-resizing iframe { pointer-events: none; }

/* Preview column header strip — holds the collapse toggle. Sits above the
   PdfPreviewPane status bar so the toggle is reachable even when the iframe
   is loading. */
.wmf-preview-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.2rem 0.4rem; /* off-scale dense toolbar */
    background: #fafafa; /* off-scale gray */
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.wmf-preview-toggle {
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.wmf-preview-toggle:hover {
    background: var(--surface-emphasis);
    color: var(--text-primary);
}

/* When the preview column is collapsed, surface a slim "Show preview" button
   pinned to the right edge of the form column so the user can re-open it. */
.wmf-preview-show {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    z-index: 4; /* in-flow stacking — below sticky toolbar */
    background: var(--surface-default);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    font-size: 0.72rem; /* off-scale */
    padding: 0.2rem var(--space-sm);
    border-radius: var(--radius-xs);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background var(--transition-fast);
}
.wmf-preview-show:hover { background: #f0f4ff; } /* off-scale blue tint */

/* Mobile-only single-column collapse. The form layout intentionally mirrors
   the PDF preview's column structure on desktop — collapsing to a single
   column on a wide screen (because the user shrunk the preview pane and the
   form column went narrow) was disorienting since the PDF doesn't reflow.
   So column-collapse only fires on actual mobile viewports, not on a
   container-width that happens to be narrow on desktop. */
@media (max-width: 640px) {
    .wmf-section .col-md-2,
    .wmf-section .col-md-3,
    .wmf-section .col-md-4,
    .wmf-section .col-md-5,
    .wmf-section .col-md-6,
    .wmf-section .col-md-8,
    .wmf-section .col-md-12 {
        flex: 0 0 auto;
        width: 100%;
    }
    .wmf-section { padding: 0.7rem 0.8rem; }
    .wmf-toolbar { padding: 0.5rem 0.6rem; }
}

/* Section card */
.wmf-section {
    background: var(--surface-default);
    border: 1px solid #e3e6ea; /* near-miss border-subtle */
    border-radius: var(--radius-md);
    padding: var(--space-lg) 1.1rem;
    margin-bottom: 0.9rem; /* off-scale */
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.wmf-section-title {
    font-size: 0.72rem; /* off-scale */
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-widest);
    color: var(--accent-burgundy);
    margin: 0 0 0.7rem 0;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--surface-muted);
}

.wmf-section .form-label {
    font-size: 0.78rem; /* off-scale */
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.wmf-section .form-control,
.wmf-section .form-select {
    font-size: var(--font-size-md);
    padding: 0.32rem 0.6rem; /* off-scale */
}

.wmf-section .form-check { padding-left: 1.6em; }
.wmf-section .form-check-input { margin-top: 0.3rem; }
.wmf-section .form-check-label { font-size: 0.83rem; } /* off-scale */

.wmf-section .row + .row { margin-top: 0.35rem; }

/* Repeating-row group (Additions etc.) */
.wmf-row-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.45rem; /* off-scale */
}
.wmf-row-group h6 {
    font-size: 0.72rem; /* off-scale */
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-widest);
    color: var(--accent-burgundy);
    margin: 0;
}

/* Inline pill row (radio/checkbox sets) */
.wmf-pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    align-items: center;
}

/* Save panel emphasis */
.wmf-toolbar .btn-primary { min-width: 90px; }
.wmf-toolbar .btn-outline-primary { min-width: 130px; }

/* Hide the "Preview updated HH:mm:ss" status bar — single-page forms don't need it.
   Error and loading states are still shown via the parent toolbar. */
.wmf-preview-col .pdf-preview-status { display: none; }

/* Empty-preview placeholder */
.wmf-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: var(--font-size-base);
    padding: var(--space-2xl);
    text-align: center;
}

/* ── Left column (Recent / Lots tabbed view) ── */
.wmf-body > .wmf-left-col {
    width: 280px;
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-default);
    background: var(--surface-default);
    overflow: hidden;
    min-height: 0;
}
.wmf-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #e0e0e0; /* near-miss border-subtle */
    background: var(--surface-subtle);
    flex-shrink: 0;
    padding: 0 0.4rem;
}
.wmf-tab {
    flex: 1;
    padding: 0.45rem 0;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: #888; /* off-scale gray */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    transition: color 0.15s, border-color 0.15s;
}
.wmf-tab:hover { color: #333; } /* off-scale gray */
.wmf-tab.active {
    color: #2563eb; /* Tailwind blue-600 — winemaking-forms tab accent */
    border-bottom-color: #2563eb;
}

/* Tab panel — both stay mounted; the inactive one gets .d-none. The active one
   needs to fill the remaining vertical space inside the column. */
.wmf-tab-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wmf-tab-panel.d-none { display: none !important; }

/* Recent submissions list (inside left column) */
.wmf-recent { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.wmf-recent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.65rem;
    border-bottom: 1px solid var(--border-subtle);
    background: #fafafa;
    flex-shrink: 0;
}
.wmf-recent-title {
    font-size: 0.68rem; /* off-scale */
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-widest);
    color: var(--accent-burgundy);
}
.wmf-recent-new {
    font-size: var(--font-size-lg);
    line-height: 1;
    color: var(--accent-burgundy);
    text-decoration: none;
    font-weight: var(--font-weight-semibold);
    padding: 0 0.2rem;
}
.wmf-recent-new:hover { color: var(--blue-500); }
.wmf-recent-search {
    padding: 0.4rem 0.55rem;
    border-bottom: 1px solid var(--surface-muted);
    background: var(--surface-default);
    flex-shrink: 0;
}
.wmf-recent-search .form-control { font-size: var(--font-size-sm); }
.wmf-recent-loading,
.wmf-recent-empty {
    padding: var(--space-md);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem; /* off-scale */
}
.wmf-recent-list { flex: 1; overflow-y: auto; }
.wmf-recent-row {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--surface-muted);
    padding: 0.45rem 0.65rem;
    cursor: pointer;
    transition: background 80ms;
}
.wmf-recent-row:hover { background: #f0f4ff; } /* off-scale blue tint */
.wmf-recent-row.active {
    background: var(--blue-100);
    border-left: 3px solid var(--blue-500);
    padding-left: calc(0.65rem - 3px);
}
.wmf-recent-row-head {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.wmf-recent-row-code {
    font-size: 0.78rem; /* off-scale */
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    letter-spacing: 0.04em;
}
.wmf-recent-row-lot {
    font-size: 0.72rem;
    color: var(--text-secondary);
    background: var(--surface-muted);
    border-radius: var(--radius-xs);
    padding: 0 0.3rem;
}
.wmf-recent-row-date {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-left: auto;
}
.wmf-recent-row-due {
    font-size: 0.7rem;
    color: var(--accent-burgundy);
    margin-top: 0.15rem;
}
.wmf-recent-row-desc {
    font-size: 0.7rem;
    color: #868e96; /* near-miss --text-muted (slightly lighter) */
    margin-top: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Description bar (internal notes above the form) ── */
.wmf-description-bar {
    padding: var(--space-sm) 1.25rem 0;
}
.wmf-description-input {
    width: 100%;
    border: none;
    border-bottom: 1px dashed var(--border-strong);
    background: transparent;
    font-size: 0.8rem; /* off-scale */
    color: var(--text-secondary);
    padding: 0.2rem 0.1rem;
    outline: none;
}
.wmf-description-input::placeholder { color: var(--text-disabled); font-style: italic; }
.wmf-description-input:focus { border-bottom-color: var(--blue-500); }

/* Available Lots panel */
.wmf-lots-panel { display: flex; flex-direction: column; height: 100%; }
.wmf-lots-panel-header {
    padding: 0.55rem var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-subtle);
}
.wmf-lots-panel-title {
    font-size: 0.72rem; /* off-scale */
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-widest);
    color: var(--accent-burgundy);
}
.wmf-lots-panel-empty {
    padding: var(--space-lg) var(--space-md);
    color: var(--text-muted);
    font-size: 0.82rem; /* off-scale */
    text-align: center;
}
.wmf-lots-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0;
}
.wmf-lots-panel-row {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--surface-muted);
    padding: 0.45rem var(--space-md);
    cursor: pointer;
    transition: background 100ms;
}
.wmf-lots-panel-row:hover { background: var(--surface-subtle); }
.wmf-lots-panel-row.selected {
    background: var(--blue-100);
    border-left: 3px solid var(--blue-500);
    padding-left: calc(0.75rem - 3px);
}
.wmf-lots-panel-row-code { font-weight: var(--font-weight-semibold); font-size: var(--font-size-md); color: var(--text-primary); }
.wmf-lots-panel-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}
.wmf-lots-panel-row-desc {
    font-size: var(--font-size-sm);
    margin-top: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
