/* v1.9.86 — regras de celular migradas para mobile.css (arquivo unico, corte 650px). */
/* v1.9.32 — auditoria visual e consistência responsiva */

/* --------------------------------------------------------------------------
   Base compartilhada: evita componentes espremidos ou quebrando no meio.
   -------------------------------------------------------------------------- */
.page,
.card,
.form-card,
.field,
.form-grid,
.filters,
.head-actions,
.form-actions,
.modal,
.modal-head,
.modal-body,
.modal-foot,
.modal-foot-row,
.queue-item,
.queue-actions,
.lawyer-card,
.settings-tile { min-width: 0; }

.field > label {
  line-height: 1.25;
  overflow-wrap: normal;
  word-break: normal;
}

.field input,
.field select,
.field textarea { min-width: 0; }

.btn {
  min-height: 42px;
  line-height: 1.2;
  text-wrap: balance;
  word-break: normal;
  overflow-wrap: normal;
}

.btn-sm {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 11.5px;
}

.head-actions,
.form-actions,
.lawyer-card-actions { align-items: center; gap: 8px; }

/* --------------------------------------------------------------------------
   Ambiente de testes: continua inequívoco, mas deixa de atravessar formulários.
   -------------------------------------------------------------------------- */
html.test-environment .test-environment-watermark {
  top: auto;
  left: auto;
  right: 18px;
  bottom: 70px;
  width: auto;
  max-width: calc(100vw - 36px);
  transform: none;
  padding: 7px 11px;
  border: 1px solid rgba(168, 86, 99, .30);
  border-radius: 999px;
  background: rgba(118, 40, 54, .09);
  color: rgba(139, 53, 68, .72);
  font-size: 11px;
  line-height: 1;
  letter-spacing: .08em;
  box-shadow: 0 5px 18px rgba(40, 18, 22, .08);
  backdrop-filter: blur(8px);
}

html[data-theme="dark"].test-environment .test-environment-watermark {
  background: rgba(146, 55, 73, .15);
  border-color: rgba(235, 125, 145, .24);
  color: rgba(255, 202, 212, .78);
}

/* --------------------------------------------------------------------------
   Novo atendimento.
   -------------------------------------------------------------------------- */
#appointmentForm .form-grid { gap: 15px 14px; }

/* Quando o select do responsável ainda não existe visualmente, o preview ocupa
   a área livre em vez de deixar 1/3 da linha vazio. */
#appointmentProviderField.hidden + .field { grid-column: span 8; }

#appointmentForm .appointment-provider-choice,
#appointmentForm .selected-lawyer-preview { min-height: 54px; }

#appointmentForm .selected-lawyer-preview {
  padding: 9px 12px;
  border-radius: 12px;
}

#appointmentForm .appointment-operational-row {
  grid-template-columns:
    minmax(210px, 1.25fr)
    minmax(145px, .75fr)
    minmax(165px, .85fr)
    minmax(170px, .90fr)
    minmax(205px, 1.15fr);
  gap: 14px;
  align-items: start;
}

#appointmentForm .appointment-operational-row .field { min-width: 0; }
#appointmentForm .appointment-operational-row input,
#appointmentForm .appointment-operational-row select { min-height: 46px; }
#appointmentForm textarea { min-height: 92px; }
#appointmentForm .form-actions { flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Detalhes do atendimento.
   -------------------------------------------------------------------------- */
.modal.modal-appointment-details {
  width: min(780px, calc(100vw - 28px));
  max-width: 780px;
}

.modal.modal-appointment-details .modal-head h3 {
  font-size: 18px;
  line-height: 1.25;
}

.modal.modal-appointment-details .modal-body { padding: 18px; }

.modal.modal-appointment-details .appointment-detail-timing {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 18px;
}

.modal.modal-appointment-details .appointment-detail-timing .field {
  grid-column: auto !important;
  align-content: start;
}

.modal.modal-appointment-details .appointment-detail-timing .field > label {
  min-height: 31px;
  display: flex;
  align-items: flex-end;
  font-size: 11px;
}

.modal.modal-appointment-details .appointment-detail-timing .field > strong {
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.3;
  word-break: normal;
  overflow-wrap: normal;
}

.modal.modal-appointment-details .appointment-detail-notes { gap: 10px; }
.modal.modal-appointment-details .appointment-detail-note { min-width: 0; }

/* Painel único de ações: fundo e separador para as duas linhas nunca
   parecerem botões soltos flutuando sobre um vazio. */
.modal.modal-appointment-details.modal-details-two-rows .modal-foot {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 20px 20px;
}

/* Primeira linha: atalhos por ícone. Segunda: ações operacionais com largura
   mínima suficiente para nunca quebrar palavras no meio. */
.modal-details-two-rows .modal-foot-row[data-modal-row="1"] {
  grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)) !important;
}

.modal-details-two-rows .modal-foot-row[data-modal-row="2"] {
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)) !important;
}

.modal-details-two-rows .modal-foot-row .btn {
  min-width: 0;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
}

.modal-details-two-rows .modal-foot-row[data-modal-row="2"] .btn {
  min-height: 48px;
  padding: 9px 11px;
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Agenda e fila: hierarquia e quebra previsível.
   -------------------------------------------------------------------------- */
#page-queue .queue-item { row-gap: 9px; }
#page-queue .queue-created-by,
#page-queue .queue-lawyer,
#page-queue .queue-time,
#page-queue .queue-status,
#page-queue .queue-actions { min-width: 0; }

#page-queue .queue-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: stretch;
  gap: 6px;
}

#page-queue .queue-actions .btn-sm {
  flex: 0 1 auto;
  min-width: 86px;
  max-width: 100%;
  white-space: normal;
}

#page-queue .queue-created-by { margin-top: 7px; }
#page-queue .queue-lawyer-mobile { margin-top: 7px; }

/* --------------------------------------------------------------------------
   Tabelas e cards administrativos.
   -------------------------------------------------------------------------- */
.table-wrap { max-width: 100%; }
.table-wrap td,
.table-wrap th { overflow-wrap: anywhere; }
.table-wrap td .btn { max-width: 100%; }

.lawyer-grid,
.settings-grid { align-items: stretch; }

.lawyer-card,
.settings-tile { overflow: hidden; }

.lawyer-card-actions {
  display: flex;
  flex-wrap: wrap;
}

.lawyer-card-actions .btn { flex: 1 1 120px; }

/* --------------------------------------------------------------------------
   Breakpoints intermediários — a aplicação deixa de esperar a largura mobile
   para reorganizar grids que já ficaram apertados em notebooks/tablets.
   -------------------------------------------------------------------------- */
@media (min-width: 651px) and (max-width: 1280px) {
  #appointmentForm .appointment-operational-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #appointmentForm .appointment-operational-row .field:first-child { grid-column: span 2; }

  #page-queue .queue-actions .btn-sm {
    flex: 1 1 108px;
    min-width: 0;
  }
}

@media (min-width: 651px) and (max-width: 900px) {
  #appointmentForm .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #appointmentForm .form-grid > .span-12 { grid-column: 1 / -1; }
  #appointmentForm .form-grid > .span-8,
  #appointmentForm .form-grid > .span-6,
  #appointmentForm .form-grid > .span-4,
  #appointmentForm .form-grid > .span-3,
  #appointmentForm .form-grid > .span-2 { grid-column: span 1; }
  #appointmentForm .form-grid > .span-6:first-child { grid-column: 1 / -1; }
  #appointmentProviderField.hidden + .field { grid-column: 1 / -1; }

  #appointmentForm .appointment-operational-row {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #appointmentForm .appointment-operational-row .field:first-child { grid-column: 1 / -1; }

  .modal.modal-appointment-details {
    width: min(720px, calc(100vw - 20px));
  }

  .modal.modal-appointment-details .appointment-detail-timing {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .modal.modal-appointment-details .appointment-detail-timing .field > label { min-height: 0; }

  .modal-details-two-rows .modal-foot-row[data-modal-row="1"] {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 7px;
  }

  .modal-details-two-rows .modal-foot-row[data-modal-row="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Nomes e responsáveis nunca devem invadir a coluna de ações. */
#page-queue .queue-name .appointment-link {
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

#page-queue .queue-lawyer .lawyer-badge-name {
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

/* Grupos de ações dentro de tabelas/cards: quebram por botão, não por palavra. */
#reportTableWrap td:last-child,
#protocolsTableWrap td:last-child,
#usersTableWrap td:last-child {
  min-width: 0;
}

#reportTableWrap td:last-child .btn,
#protocolsTableWrap td:last-child .btn,
#usersTableWrap td:last-child .btn {
  word-break: normal;
  overflow-wrap: normal;
}

.settings-tile .btn { max-width: 100%; white-space: normal; }

@media (min-width: 651px) and (max-width: 900px) {
  .monitor-modal-lawyer,
  .monitor-modal-process,
  .monitor-row-time { white-space: normal; overflow-wrap: anywhere; }

  .page-head { gap: 12px; }
  .head-actions { width: 100%; }
  .head-actions .btn { min-width: 0; }
}

/* Menus flutuantes permanecem dentro do viewport. */
.queue-status-filter-menu {
  max-width: min(320px, calc(100vw - 24px));
}

