/* ATOMIS FILE - fixes of the Codex audit of 2026-11-28 (B01-B19), hand-written, loaded after the theme.
   Colours come from the theme variables where one exists, so both themes follow. */

/* B03: a picked re-upload file waits for the send button - show that it is ready to go */
.compact-reupload.has-file button {
  box-shadow: 0 0 0 2px var(--accent, #2f7cf6), 0 0 14px rgba(47, 124, 246, .45);
}
.compact-reupload.has-file .file-picker span {
  font-weight: 600;
}

/* B16: the hint under "Set charged total" says it moves tokens - make it readable, not a footnote */
.inline-credit-hint { display: block; line-height: 1.35; }

/* B04: on wide screens the top bar may wrap to two rows - the sticky filter and the detail window start under its
   REAL height (portal-fixes.js measures it into --atf-topbar; the old fixed values stay as the fallback) */
@media (min-width: 1101px) {
  .admin-lab-filter,
  .client-lab-filter {
    top: var(--atf-topbar, 78px);
  }
  .admin-lab-detail,
  .client-lab-detail {
    top: calc(var(--atf-topbar, 72px) + 6px);
    max-height: calc(100vh / .9 - var(--atf-topbar, 72px) - 24px);
  }
}

/* B05: slim bar with the menu once the page is scrolled (one column only) */
.atf-minibar,
.atf-minimenu,
.atf-sheet-bar { display: none; }
@media (max-width: 1100px) {
  .atf-minibar:not([hidden]) {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 880;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 6px 12px;
    background: var(--panel, #121826);
    border-bottom: 1px solid var(--line, rgba(255, 255, 255, .12));
    box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
  }
  .atf-minibar-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
  }
  .atf-minibar .btn { flex: 0 0 auto; white-space: nowrap; }
  .atf-minimenu:not([hidden]) {
    position: fixed;
    top: 52px;
    left: 8px;
    right: 8px;
    z-index: 881;
    display: grid;
    gap: 4px;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px;
    border: 1px solid var(--line, rgba(255, 255, 255, .12));
    border-radius: 10px;
    background: var(--panel, #121826);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
  }
  .atf-minimenu-link {
    display: block;
    padding: 11px 12px;
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
    font-weight: 600;
  }
  .atf-minimenu-link:hover,
  .atf-minimenu-link:focus-visible { background: var(--panel-soft, rgba(255, 255, 255, .06)); }
  .atf-minimenu-link.active { background: var(--accent-soft, rgba(47, 124, 246, .18)); }

  /* B06: the open order as a sheet over the list */
  body.atf-sheet-open .atf-minibar,
  body.atf-sheet-open .atf-minimenu { display: none !important; }
  body.atf-sheet-open .atf-sheet-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 902;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 8px 12px;
    background: var(--panel, #121826);
    border-bottom: 1px solid var(--line, rgba(255, 255, 255, .12));
  }
  .atf-sheet-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.atf-sheet-open .admin-lab-detail.atf-sheet,
  body.atf-sheet-open .client-lab-detail.atf-sheet {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 901;
    width: auto;
    height: auto;
    max-height: none !important;
    margin: 0;
    padding: 70px 14px 28px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 0;
    border-radius: 0;
    background: var(--bg, #0c1018);
    box-shadow: none;
    scroll-padding-top: 70px;          /* an anchor (#admin-lab-response-form...) is not hidden under the sheet bar */
  }
  /* the live chat is opened from inside the order: it must lie above the sheet */
  body.atf-sheet-open .live-chat-backdrop { z-index: 910; }
  body.atf-sheet-open .live-chat-window { z-index: 911; }

  /* Audit 2026-12-03: body is no longer a scroll container (app.css: overflow-x clip), so the sticky parts work on one
     column too. The slim bar above stays the sticky header here - the full top bar scrolls away as before (B05 shows
     the slim bar only once the top bar has left the screen) - and what sticks lines up under the slim bar (52 px). */
  .topbar { position: relative; }
  .admin-lab-filter,
  .client-lab-filter { top: 52px; }
  .admin-files-table thead th { top: 52px; }
}
@media (max-width: 820px) {
  /* phones: the "Ticket list / Files and details" switch sticks under the slim bar; the filter (four rows here) stays in
     the page so that the bar and the switch are all that cover the list */
  .mobile-lab-switch { top: 52px; }
  .admin-lab-filter,
  .client-lab-filter { position: relative; top: auto; }
}

/* Audit 2026-12-03 (HIGH): the live chat window always lies above the slim bar and its menu (880 / 881), not only
   while an order sheet is open - on a phone the bar covered the chat title and the close button */
.live-chat-backdrop { z-index: 910; }
.live-chat-window { z-index: 911; }

/* Audit 2026-12-03: an anchor of the client card (a save returns to #client-...), the Flex access list and the helper
   box landed under the sticky top bar; keep them below the bar's real height (B04 measures it), below the slim bar on
   one column */
#new-client,
#client-account, #client-company, #client-credits, #client-discounts, #client-security, #client-note, #client-devices,
#client-history, #client-settlements, #client-flex, #flex-access, #flex-helper {
  scroll-margin-top: calc(var(--atf-topbar, 78px) + 14px);
}
@media (max-width: 1100px) {
  #new-client,
  #client-account, #client-company, #client-credits, #client-discounts, #client-security, #client-note, #client-devices,
  #client-history, #client-settlements, #client-flex, #flex-access, #flex-helper {
    scroll-margin-top: 66px;
  }
}
