/* Editor dokladu jako okno a karta minimalizovaného dokladu vpravo dole (Blueprint tokeny). */
/* Okno překrývá obsah aplikace; sidebar i lišta hlášek nahoře zůstávají volné. */
.editor-window-layer:not([hidden]) { position: fixed; inset: 56px 0 0 244px; z-index: 40; display: flex; margin: 0; background: rgb(29 42 56 / 40%); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
[data-panel="quote"].editor-window-layer { overflow: hidden; overscroll-behavior: none; }
.editor-window { flex: 1; min-width: 0; margin: var(--editor-window-margin); display: flex; flex-direction: column; background: var(--color-canvas); border: 1px solid var(--color-border-strong); box-shadow: var(--shadow-panel); }
.editor-window-bar { position: relative; z-index: 3; display: flex; align-items: center; gap: .75rem; padding: .55rem .55rem .55rem 1rem; background: var(--color-surface); border-bottom: 1px solid var(--color-border); box-shadow: 0 8px 18px rgba(16, 37, 67, .14); }
.editor-window-title { flex: 1; min-width: 0; }
.editor-window-title h2 { margin: 0; font-size: var(--editor-window-title-font-size); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-window-title h2:focus { outline: none; }
.editor-window-title .conversion-source-banner { margin: .15rem 0 0; }
.window-controls { display: flex; align-self: flex-start; gap: .2rem; }
.editor-window-body { flex: 1; min-height: 0; overflow: auto; padding: var(--editor-window-padding-block) var(--editor-window-padding-inline); }
.editor-window-body > .quote-back { margin: 0 0 .75rem; }
/* Akce editoru ve fixní patičce okna mimo posouvané tělo – stejný vzor jako .detail-footer. */
.editor-window-footer { position: relative; z-index: 3; background: var(--color-surface); border-top: 1px solid var(--color-border); box-shadow: 0 -8px 18px rgba(16, 37, 67, .14); }
.editor-window-footer:not(:has(> .quote-submit:not([hidden]))) { display: none; }
.editor-window-footer > .quote-submit { margin: 0; padding: var(--window-footer-padding-block) var(--editor-window-padding-inline) !important; border: 0; border-radius: 0; background: transparent; box-shadow: none !important; }
.editor-window-footer > .quote-submit[hidden] { display: none; }
.editor-window-footer > .quote-submit h2 { display: none; }
.editor-window-footer > .quote-submit p { margin: 0; }
.editor-window-footer > .quote-submit p:empty { display: none; }
/* Při obnově minimalizovaného dokladu po načtení stránky se okno neukáže. */
.editor-restoring .editor-window-layer { visibility: hidden; }
@media (max-width: 880px) { .editor-window-layer:not([hidden]) { inset: 56px 0 0 0; } .editor-window { margin: 0; } }
.draft-dock { position: fixed; right: 24px; bottom: 20px; z-index: 20; display: flex; align-items: center; gap: .75rem; max-width: min(440px, calc(100vw - 32px)); padding: .55rem .55rem .55rem .9rem; background: var(--color-surface); border: 1px solid var(--color-border); border-left: 4px solid var(--color-warning); border-radius: var(--radius-panel); box-shadow: var(--shadow-panel); }
.draft-dock[hidden] { display: none; }
.draft-dock-text { display: grid; min-width: 0; }
.draft-dock-text small { color: var(--color-text-secondary); font-size: .78rem; }
.draft-dock-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draft-dock button { white-space: nowrap; flex: none; }
.app-content-scroll .draft-dock > .icon-button { width: var(--control-height); height: var(--control-height); min-height: var(--control-height); }
/* Karty dokladu a projektu mají stejnou šířku a stejné rozložení: tlačítka vpravo, štítek stavu pevné šířky.
   Dlouhý název se zkracuje a nesmí smáčknout křížek. */
.draft-dock { box-sizing: border-box; width: min(440px, calc(100vw - 32px)); }
.draft-dock .status { flex: none; min-width: 5.5rem; box-sizing: border-box; text-align: center; }
.draft-dock-text { flex: 1; }
@media (max-width: 880px) { .draft-dock { left: 16px; right: 16px; width: auto; max-width: none; } }
/* Minimalizace: okno se složí k pravému dolnímu rohu a karta jemně přijede a jednou zazáří. */
.editor-window-layer.is-minimizing { animation: editor-layer-out .18s ease-in both; }
.editor-window-layer.is-minimizing .editor-window { transform-origin: 100% 100%; animation: editor-window-minimize .18s ease-in both; }
.draft-dock.is-arriving { animation: draft-dock-arrive .9s ease-out both; }
@keyframes editor-layer-out { to { background-color: rgb(29 42 56 / 0%); } }
@keyframes editor-window-minimize { to { opacity: 0; transform: translate(4%, 6%) scale(.82); } }
@keyframes draft-dock-arrive {
  0% { opacity: 0; transform: translateY(14px) scale(.97); }
  22% { opacity: 1; transform: none; box-shadow: var(--shadow-panel), 0 0 0 0 rgb(148 99 23 / 34%); }
  70% { box-shadow: var(--shadow-panel), 0 0 0 8px rgb(148 99 23 / 0%); }
  100% { opacity: 1; transform: none; box-shadow: var(--shadow-panel); }
}
@media (prefers-reduced-motion: reduce) { .editor-window-layer.is-minimizing, .editor-window-layer.is-minimizing .editor-window, .draft-dock.is-arriving { animation: none; } }
/* Otevření okna: plynulé roztažení, navazuje na detail dokladu ve stejném místě. */
.editor-window-layer.motion-enter { animation: editor-layer-in .2s ease-out both; }
.editor-window-layer.motion-enter .editor-window { transform-origin: 50% 50%; animation: editor-window-open .22s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes editor-layer-in { from { background-color: rgb(29 42 56 / 0%); } }
@keyframes editor-window-open { from { opacity: .35; transform: scale(.94); } }
@media (prefers-reduced-motion: reduce) { .editor-window-layer.motion-enter, .editor-window-layer.motion-enter .editor-window { animation: none; } }

.editor-window-layer.is-closing { animation: editor-layer-out .17s ease-in both; pointer-events: none; }
.editor-window-layer.is-closing .editor-window { transform-origin: 50% 50%; animation: editor-window-close .17s ease-in both; }
@keyframes editor-window-close { to { opacity: 0; transform: scale(.94); } }
@media (prefers-reduced-motion: reduce) { .editor-window-layer.is-closing, .editor-window-layer.is-closing .editor-window { animation: none; } }

/* Navigace dokladu a soucty zustavaji mimo posouvany obsah. */
.editor-window-bar { flex: 0 0 auto; padding: 0 calc((var(--editor-window-bar-height) - var(--control-height)) / 2) 0 var(--editor-window-padding-inline); height: var(--editor-window-bar-height); box-sizing: border-box; }
/* Top and right gap of the buttons stay equal however many lines the title has. */
.editor-window-bar > .window-controls { align-self: center; margin-top: 0; }
.window-controls > .icon-button { box-sizing: border-box; width: var(--control-height); height: var(--control-height); min-height: var(--control-height); padding: 0; }
[data-panel="quote"] .editor-window-bar > .quote-back { align-self: stretch; flex: 0 0 auto; width: var(--editor-window-bar-height) !important; height: auto !important; min-height: var(--editor-window-bar-height); aspect-ratio: 1; display: flex; align-items: center; justify-content: center; margin: 0; padding: 0; border: 1px solid var(--color-border); background: var(--color-surface); }
.editor-window-navigation { flex: 0 0 auto; display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem; padding: var(--editor-window-padding-block) var(--editor-window-padding-inline) 0; }
.editor-window-navigation,
.project-editor-body > .quote-ribbon {
  position: relative;
  /* Nad přilepenými buňkami řádků (z-index 2 v editor_lines.css), jinak je jejich sloupce stín a dělicí čára pod záložkami minou. */
  z-index: 3;
  box-shadow: var(--shadow-detail-header);
}
.editor-window-navigation::after {
  content: "";
  position: absolute;
  inset: 100% 0 auto;
  height: 1px;
  background: var(--color-detail-header-shadow);
  pointer-events: none;
}
.editor-window-navigation > #quoteRibbon { margin: 0; min-width: 0; inset-block-start: 1px; }
.editor-window-navigation > #addLine { flex: 0 0 auto; }
.project-editor-body > .quote-ribbon ~ [role="tabpanel"]:is(.card, .project-diary),
.project-editor-body > .quote-ribbon ~ [role="tabpanel"] > .card:first-child { border-top-color: transparent; }
[data-panel="quote"] .editor-window-navigation:not(:has(#quoteTabLines.selected)) > #addLine { display: none; }
[data-panel="quote"] .editor-window-body { padding: 0; overflow: auto; overscroll-behavior: contain; }
[data-panel="quote"] .editor-window-body > .quote-workspace { padding: 0 var(--editor-window-padding-inline) var(--editor-window-padding-block); min-width: 0; }
/* V náhledu se posouvají jen stránky; nadpis a přiblížení zůstávají nahoře. */
[data-panel="quote"] .editor-window-body:has(> #quotePanelPreview:not([hidden])) { overflow: hidden; }
[data-panel="quote"] #quotePanelPreview { display: flex; flex-direction: column; height: 100%; min-height: 0; margin-bottom: 0; box-sizing: border-box; }
[data-panel="quote"] #quotePanelPreview > .pdf-preview-card { display: flex; flex-direction: column; flex: 1; min-height: 0; }
[data-panel="quote"] #quotePanelPreview .pdf-preview-card > .section-title { flex: 0 0 auto; }
[data-panel="quote"] #quotePanelLines > .card { width: auto; min-width: 0; box-sizing: border-box; }
[data-panel="quote"] #quotePanelLines .table-wrap { overflow: visible; }
[data-panel="quote"] .editor-window-footer .totals { margin: 0; flex-wrap: wrap; }
[data-panel="quote"] .editor-window-footer .quote-submit { flex-wrap: nowrap; justify-content: flex-end !important; gap: 8px !important; }
/* The message chip always sits right before the buttons (it does not wander when the window changes); a long text is cut. */
.editor-window-footer > .quote-submit > div:has(> :is(#detailResult, #linesResult)) { flex: 0 1 auto; min-width: min(100%, 11rem); max-width: 100%; margin-left: 0 !important; margin-right: auto; }
.editor-window-footer > .quote-submit > .quote-actions { margin-left: 0 !important; flex: 0 0 auto; }
.editor-window-footer > .quote-submit > div:first-child:has(> .totals) { flex: 1 20 auto; min-width: 0; }
.editor-window-footer > .quote-submit .totals { flex-wrap: wrap; min-width: 0; }
[data-panel="quote"] .editor-window-footer .quote-actions { margin-left: auto; }
@media (max-width: 760px) {
  .editor-window-navigation { padding: 12px 12px 0; gap: .35rem; }
  [data-panel="quote"] .editor-window-body > .quote-workspace { padding: 0 12px 12px; }
  [data-panel="quote"] .editor-window-footer .totals { flex-direction: row; }
}

[data-panel="quote"] .editor-window-body > .quote-workspace > .card:first-child { margin-top: 0 !important; }

/* Karta musi rust s minimalni sirkou tabulky, aby tabulka nepretekala pres jeji ramecek. */
[data-panel="quote"] .editor-window-body > #quotePanelLines { width: fit-content; min-width: 100%; box-sizing: border-box; }

[data-panel="quote"] .editor-window-body { container-type: inline-size; }

[data-panel="quote"] #quoteBackToDetail:is(:hover, :focus-visible):not(:disabled) {
  background: var(--color-primary-soft);
  color: var(--color-text) !important;
  -webkit-text-fill-color: var(--color-text) !important;
}

/* Keep the existing fade and timing without translating the scrollable tab. */
[data-panel="quote"] [data-quote-panel].motion-enter {
  animation-name: microerp-backdrop-in;
}
/* Window header: the title does not touch the edge when the back button is hidden, and stacked lines (eyebrow, title, source) have room. */
/* The bar has a fixed height: the title block holds two lines (partner and project above, number below) and never grows. */
.editor-window-title { display: flex; flex-direction: column; justify-content: center; align-self: stretch; overflow: hidden; padding-block: 0; }
.editor-window-title .conversion-source-banner { margin: 0; font-size: 12px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-window-title:has(> .conversion-source-banner:not([hidden])) > #editorWindowEyebrow { display: none; }
/* The back button sits flush to the left edge; without it the title keeps the window padding. */
.editor-window-bar:has(> .quote-back:not([hidden])) { padding-left: 0; }
/* The primary action of a new document sits on the right like the other footer actions. */
.editor-window-footer > .quote-submit > :is(#createQuote, #retryOpenConvertedOrder) { margin-left: auto; }

.editor-window-footer > .quote-submit > .quote-actions:not(:has(> :not([hidden]))) { display: none; }
.editor-window-title h2 .text-link{display:inline;width:auto;min-height:0;padding:0;border:0;background:transparent!important;box-shadow:none!important;color:var(--primary)!important;font:inherit;font-weight:700;text-decoration:underline;cursor:pointer}
/* Totals of the document: a block of their own above the row with the message and the buttons, always visible and never between the buttons. */
.editor-window-footer > .quote-submit:has(> .totals) { flex-wrap: wrap; row-gap: 8px !important; }
.editor-window-footer > .quote-submit > .totals { flex: 0 0 100% !important; order: -1; justify-content: flex-end; margin: 0; padding-bottom: 8px; border-bottom: 1px solid var(--color-divider); }

/* The save button is the rightmost one of the editor footer (the PDF buttons stay before it). */
.editor-window-footer .quote-actions > :is(#saveQuoteDetail, #saveQuoteLines) { order: 3; }
