/* Atendimento postarchive: presentation only; loaded after historical CSS.
   Compact desktop delta derives from A1, not its historical index.html.
   <=1160px retains the existing mobile/tablet contract.
   >1600px keeps the published expanded layout unless info is explicitly hidden. */
#tab-atendimento #atendimentoInfoToggle { display: none; }

@media (min-width: 1161px) {
  #tab-atendimento #atendimentoInfoToggle { display: inline-flex; align-items: center; justify-content: center; }
  #tab-atendimento.atendimento-info-collapsed .service-workspace {
    grid-template-columns: 340px minmax(0, 1fr);
  }
  /* Parent state survives the existing rail outerHTML replacement.
     display:none also removes rail descendants from keyboard/accessibility flow. */
  #tab-atendimento.atendimento-info-collapsed #emptyContext { display: none; }
}

@media (min-width: 1161px) and (max-width: 1600px) {
  .app:has(#tab-atendimento.active) {
    grid-template-columns: 224px minmax(0, 1fr);
    min-height: 100dvh;
  }
  .app.nav-collapsed:has(#tab-atendimento.active) {
    grid-template-columns: 76px minmax(0, 1fr);
  }
  .app:has(#tab-atendimento.active) > .sidebar {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .app:has(#tab-atendimento.active) .sidebar > .brand {
    flex: 0 0 auto;
    min-width: 0;
  }
  .app:has(#tab-atendimento.active) .sidebar > .nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    padding: 6px 0 12px;
  }
  .app.nav-collapsed:has(#tab-atendimento.active) .tab-count {
    right: 0;
    top: 0;
  }
  .app:has(#tab-atendimento.active) .sidebar .brand-text {
    min-width: 0;
    flex: 1 1 auto;
  }
  .app:has(#tab-atendimento.active) .sidebar .brand-text h1,
  .app:has(#tab-atendimento.active) .sidebar .brand-text p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .app:has(#tab-atendimento.active) .sidebar .logo,
  .app:has(#tab-atendimento.active) .sidebar .tab-btn,
  .app:has(#tab-atendimento.active) .nav-toggle { flex-shrink: 0; }
  .app.nav-collapsed:has(#tab-atendimento.active) .brand {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
  }
  .app.nav-collapsed:has(#tab-atendimento.active) .nav-toggle {
    position: static;
    margin: 0;
  }
  .app:has(#tab-atendimento.active) > .main {
    height: 100dvh;
    min-width: 0;
    min-height: 0;
  }
  .app:has(#tab-atendimento.active) .app-topbar {
    height: auto;
    min-height: 52px;
    padding-block: 6px;
    gap: 8px;
  }
  .app:has(#tab-atendimento.active) .global-search-wrap { flex-basis: 300px; }
  .app:has(#tab-atendimento.active) .topbar-actions { flex-wrap: wrap; gap: 6px; }
  #tab-atendimento .atendimento-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 6px 10px;
  }
  #tab-atendimento .atendimento-filters > * { min-width: 0; max-width: 100%; }
  #tab-atendimento .service-workspace {
    grid-template-columns: clamp(220px, 18vw, 280px) minmax(0, 1fr) clamp(240px, 18vw, 300px);
    min-width: 0;
    min-height: 0;
    height: auto;
  }
  #tab-atendimento.atendimento-info-collapsed .service-workspace {
    grid-template-columns: clamp(220px, 18vw, 280px) minmax(0, 1fr);
  }
  #tab-atendimento .detail-layout,
  #tab-atendimento .chat-shell { min-width: 0; min-height: 0; }
  #tab-atendimento .chat-header { padding: 7px 10px; gap: 6px; flex-wrap: wrap; }
  #tab-atendimento .chat-header > div { min-width: 0; }
  #tab-atendimento .chat-name { font-size: 17px; overflow-wrap: anywhere; }
  #tab-atendimento .chat-meta { font-size: 12px; overflow-wrap: anywhere; }
  #tab-atendimento .chat-actions { flex-wrap: wrap; gap: 5px; }
  #tab-atendimento .chat-actions button { padding: 6px 8px; }
  /* Remove historical message height floor; reserve the existing composer.
     No draft/scroll writes or message/composer DOM replacement. */
  #tab-atendimento .messages { min-height: 0; }
  #tab-atendimento .chat-composer { flex: 0 0 auto; padding: 8px 10px; gap: 6px; }
  #tab-atendimento .context-rail,
  #tab-atendimento .context-rail.v1-rail {
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    overflow-wrap: anywhere;
  }
}

/* IA overlap follow-up: reserve a right-hand dock only when the desktop
   context rail is collapsed. The existing 48px FAB stays visible and enabled
   at right:22px; 84px keeps ALL composer controls at least 14px to its left
   even if the composer reaches the viewport edge. No DOM/state mutation.
   Last rule wins over the compact composer padding shorthand above. */
@media (min-width: 1161px) {
  #tab-atendimento.atendimento-info-collapsed .chat-composer {
    padding-right: 84px;
  }
}
