﻿/* FullEdit application toolbar + FieldEditor + print isolation */

/* ── The strip is row content, not an overlay (issue #188, F1b) ────────────────────────────
   It used to be `position: fixed; top: 56px`, with `html.lf-full-edit { --lf-header-height:
   92px }` above it to reserve the room a fixed strip does not take. F0 turned the shell into a
   grid and that pair stopped adding up, twice over:

/* Row two of the header, not a bar floating over the page.
   It was `position: fixed; top: 56px` for as long as the navbar was `fixed-top` and <body>
   reserved room under both with a padding. Issue #188 F0 made the header a grid row and took
   that padding away (shell.css) — and a fixed strip inside a header that is now in the flow
   contributes nothing to the header's own height. So `--lf-header-height`, which shellDock.ts
   measures from <header>, lost this strip's forty pixels, and everything anchored to it — the
   chat, the notification panel, a section drawn fullscreen over <main> — sat forty pixels too
   high, underneath a toolbar that then took the clicks meant for theirs.
   `position: relative` only so the overflow panel and the split-button menus keep positioning
   against this row; the z-index is now inside the header's own stacking context. */
.lf-full-edit-toolbar {
  position: relative;
  z-index: 1029;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.75rem;
  /* One button (--lf-tb-btn-height) plus this strip's own padding: the row is exactly as
     tall as what it holds, whichever of the three button shapes is in use. */
  min-height: var(--lf-bar-height, calc(var(--lf-tb-btn-height, 2rem) + 0.5rem + 1px));
  box-sizing: border-box;
  background: #3d4348;
  border-bottom: 1px solid #2f3438;
  color: #f8f9fa;
}

.lf-fe-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* The size, padding and three shapes of `.lf-fe-btn` (and of `.lf-fe-label` and
   `.lf-fe-badge-icon` with it) are css/core/toolbar.css's: they are the same contract this
   strip and every view's own function bar both answer to, and keeping two copies of it is
   what made the two toolbars disagree in the first place. Only the pressed look, which is
   this strip's alone, stays here. */
.lf-fe-btn.active,
.lf-full-edit-toolbar .lf-split-btn.active > .btn {
  background: rgba(255, 255, 255, 0.18);
}

.lf-full-edit-toolbar .lf-split-btn-caret .fa-caret-down {
  font-size: 0.6rem;
}

/* Alone on the trailing edge: not a group, never travels into the overflow menu. */
.lf-fe-readonly {
  margin-left: auto;
  flex: 0 0 auto;
}

.section-full-edit-caption {
  min-height: 1.75rem;
}

.tree-full-edit-caption {
  min-height: 1.75rem;
}

.section-field-editor {
  box-sizing: border-box;
  background: #fff;
  box-shadow: 0 0 0 2px #0d6efd;
  overflow: hidden;
}

.section-field-editor-input {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* Neutralize Bootstrap form-control min-height/padding so the overlay matches the
   underlying form/grid value box (FK widgets already fill via .section-eip-fk). */
.section-field-editor-input.form-control,
.section-field-editor-input.form-control-sm {
  min-height: 0;
  height: 100%;
  padding: 0 0.2rem;
  font-size: inherit;
  line-height: inherit;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* Room for the native spin buttons plus a few digits, whatever the cell width. */
.section-field-editor.section-field-editor-number {
  min-width: calc(5ch + 1.6rem);
}

.section-field-editor .section-eip-fk {
  border: 0;
  height: 100%;
  min-width: 0;
}

.section-field-editor textarea.section-field-editor-input {
  resize: none;
  line-height: inherit;
  padding: 0.1rem 0.2rem;
}

.section-field-editor .section-fe-text {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: stretch;
  min-width: 0;
  gap: 0.15rem;
}

.section-field-editor .section-fe-text .section-field-editor-input {
  flex: 1 1 auto;
  min-width: 0;
}

.section-field-editor .section-fe-text-btn {
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  height: auto;
  padding: 0 0.25rem;
  line-height: 1;
  font-size: 0.7rem;
}

.section-text-expand-root {
  position: relative;
  z-index: 1092;
}

.section-text-expand-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;
  pointer-events: none;
}

.section-text-expand {
  position: fixed;
  z-index: 1093;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 0.5rem;
  box-sizing: border-box;
}

.section-text-expand-dialog {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.25);
  max-height: 100%;
  width: min(800px, 96%);
  min-height: 16rem;
}

.section-text-expand-dialog.section-text-expand-size-1 {
  width: min(1200px, 94%);
  height: min(42rem, 92%);
}

.section-text-expand-dialog.section-text-expand-size-2 {
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
}

.section-text-expand-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #dee2e6;
}

.section-text-expand-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-text-expand-window {
  flex: 0 0 auto;
  align-items: center;
}

.section-text-expand-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.75rem;
  display: flex;
}

.section-text-expand-input {
  flex: 1 1 auto;
  min-height: 10rem;
  resize: none;
}

.section-text-expand-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #dee2e6;
}

.section-field-dirty {
  outline: 1px dashed #fd7e14;
}

.section-field-error {
  outline: 1px solid #dc3545;
}

/* A row staged for deletion inside a Tree document (issue #165 T7): the record
   is still there until the document is saved, and saying so with a strike is
   the only honest state between "clicked Delete" and "the transaction ran".
   The three theme colours of the invalid cell are applied in theme.css, where
   the rest of the palette lives; this rule only has to say "struck through". */
.section-row-pending-delete {
  text-decoration: line-through;
  opacity: 0.6;
}

/* The same verdict seen from inside the open editor (issue #168). The cell's own outline is
   behind the overlay while the user is typing, so it is the control that has to carry the mark;
   both are set and cleared together by FieldEditor._applyValidity. */
.section-field-editor-invalid {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.15rem rgba(220, 53, 69, 0.35);
}

.footer-field-status {
  flex: 0 1 auto;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffc107;
  font-size: 0.8rem;
}

.footer-field-status.is-error {
  color: #ff8a80;
  font-weight: 600;
}

@media print {
  header,
  .lf-navbar,
  .lf-full-edit-toolbar,
  .live-footer,
  .section-filter-row {
    display: none !important;
  }

  body {
    padding-top: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  main {
    overflow: visible !important;
  }

  .lf-print-target {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }
}

/* -- Find tab (issue #36) ----------------------------------------------------------------------
   The one menu on this strip that is typed into rather than picked from. The box is built once
   and only the list below it is refilled, so the caret survives every keystroke. */
.lf-fe-tab-find-box {
    padding: 0.25rem 0.3rem 0.35rem;
}

.lf-fe-tab-find-box input {
    font-size: 0.85rem;
}

/* Thirty tabs is the case this command exists for, so the list is bounded and scrolls. */
.lf-fe-tab-find-results {
    max-height: 15rem;
    overflow-y: auto;
}

.lf-fe-tab-find-empty {
    padding: 0.4rem 0.6rem;
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.85rem;
}

/* Wider than the 168px a menu of short words needs: these are tab names. */
.lf-fe-tab-find-menu {
    min-width: 15rem;
}
