/* Complemento leve para telas exclusivas da Ana (Atendimentos e Informações),
   reutilizando 100% dos tokens de app.css e theme-navy.css da Lia. */

.out-form { margin: 0; }
button.out {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
}
button.out:hover {
  border: 0;
  box-shadow: none;
  transform: none;
}
body.app-body[data-theme="navy"] button.out {
  border: 0;
  background: transparent;
  color: #aeb6d1;
  box-shadow: none;
}
body.app-body[data-theme="navy"] button.out:hover {
  border: 0;
  background: rgba(255, 255, 255, .08);
  color: #ffffff;
  box-shadow: none;
}

select, textarea {
  width: 100%;
  min-height: 44px;
  margin-bottom: 16px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fbfcfa;
  color: var(--ink);
  font: inherit;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
body.app-body[data-theme="navy"] select,
body.app-body[data-theme="navy"] textarea {
  border-color: var(--line-strong);
  background: #fbfcff;
  color: var(--ink);
}
select:focus, textarea:focus {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(49, 173, 161, .13);
  outline: none;
}

.flash.error {
  border-color: #efc5cc;
  background: var(--danger-soft);
  color: var(--danger);
}
.flash.info {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink-soft);
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0 0 12px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: .9rem;
  font-weight: 600;
}

/* Dashboard period alignment (padrão Lia 15/11) */
#dashboard-period-filter .custom-period {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
#dashboard-period-filter .period-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#dashboard-period-filter .period-field label {
  margin: 0;
  font-size: .74rem;
  font-weight: 700;
  color: var(--muted);
}
#dashboard-period-filter .period-field input {
  width: 152px;
  min-height: 44px;
  margin: 0;
  padding: 9px 11px;
  font-size: .84rem;
}
#dashboard-period-filter .custom-period button {
  min-height: 44px;
  padding: 10px 16px;
}
#dashboard-period-filter .period-links {
  min-height: 44px;
  align-items: center;
}
#dashboard-period-filter .period-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
}

/* ── Atendimentos: Chat compacto estilo WhatsApp Web ── */
.wa-page-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.wa-page-bar h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -.03em;
  line-height: 1.15;
}
.wa-page-bar-sub {
  margin: 0;
  font-size: .8rem;
  color: var(--muted);
}

.wa-shell {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  height: calc(100vh - 138px);
  min-height: 520px;
  max-height: 820px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.wa-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.wa-search-box {
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.wa-search-form {
  display: flex;
  gap: 6px;
  align-items: center;
}
.wa-search-form input[type="text"] {
  flex: 1;
  min-height: 34px;
  height: 34px;
  margin: 0;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
}
.wa-search-form button {
  min-height: 34px;
  height: 34px;
  padding: 0 11px;
  font-size: 12px;
  border-radius: 8px;
  box-shadow: none;
}
.wa-filter-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.wa-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: var(--canvas);
  border: 1px solid transparent;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.wa-tab:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}
.wa-tab.on {
  background: var(--green-soft);
  color: var(--green-deep);
  border-color: rgba(49, 173, 161, .35);
}

.wa-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.wa-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  transition: background .12s ease;
}
.wa-row:hover { background: var(--canvas); }
.wa-row.selected {
  background: var(--green-soft);
  box-shadow: inset 3px 0 0 var(--green);
}
.wa-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  background: var(--green-soft);
  color: var(--green-deep);
  text-transform: uppercase;
}
.wa-avatar.warn { background: var(--gold-soft); color: #8a641a; }
.wa-avatar.danger { background: var(--danger-soft); color: var(--danger); }

.wa-row-body { min-width: 0; flex: 1; }
.wa-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.wa-row-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wa-row-time {
  font-size: 10.5px;
  color: var(--soft-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.wa-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
}
.wa-row-preview {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wa-mini-pill {
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
}
.wa-mini-pill.ok { background: var(--green-soft); color: var(--green-deep); }
.wa-mini-pill.warn { background: var(--gold-soft); color: #8a641a; }
.wa-mini-pill.danger { background: var(--danger-soft); color: var(--danger); }

.wa-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--canvas);
}
.wa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}
.wa-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.wa-back-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--canvas);
  color: var(--ink);
}
.wa-back-btn:hover { background: var(--green-soft); color: var(--green-deep); }
.wa-header-info { min-width: 0; flex: 1; }
.wa-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 750;
  color: var(--ink);
  line-height: 1.2;
  min-width: 0;
}
.wa-header-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wa-header-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wa-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.wa-header-actions form { margin: 0; }
.wa-header-actions button {
  min-height: 32px;
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 8px;
  box-shadow: none;
}

.wa-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wa-bubble {
  max-width: min(74%, 640px);
  min-width: 0;
  padding: 7px 11px 5px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.42;
  box-shadow: 0 1px 2px rgba(13, 15, 54, .05);
}
.wa-bubble-cliente {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid var(--line);
  border-top-left-radius: 3px;
  color: var(--ink);
}
.wa-bubble-ana {
  align-self: flex-end;
  background: #e3f5f2;
  border: 1px solid #bce4dd;
  border-top-right-radius: 3px;
  color: var(--ink);
}
body.app-body[data-theme="standard"] .wa-bubble-ana {
  background: #e6f3ea;
  border-color: #c2decb;
}
.wa-bubble-equipe {
  align-self: flex-end;
  background: var(--green-deep);
  border: 1px solid var(--green-deep);
  border-top-right-radius: 3px;
  color: #ffffff;
}
.wa-bubble-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.wa-bubble-meta {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 3px;
  font-size: 10.5px;
  line-height: 1;
  opacity: .68;
}

.wa-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}
.wa-composer textarea {
  flex: 1;
  min-height: 38px;
  height: 38px;
  max-height: 110px;
  margin: 0;
  padding: 8px 11px;
  font-size: 13.5px;
  line-height: 1.35;
  border-radius: 9px;
  resize: none;
}
.wa-composer button {
  min-height: 38px;
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
  border-radius: 9px;
  flex-shrink: 0;
  box-shadow: none;
}
.wa-empty {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* Informações da Clínica items */
.ana-item-list { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.ana-item-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ana-item-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.ana-item-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; color: var(--ink); }
.ana-item-desc { margin-top: 6px; font-size: .85rem; color: var(--muted); white-space: pre-wrap; }
.ana-pill {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: .72rem; font-weight: 750;
}
.ana-pill.ok { background: var(--green-soft); color: var(--green-deep); }
.ana-pill.warn { background: var(--gold-soft); color: #8a641a; }
.ana-pill.danger { background: var(--danger-soft); color: var(--danger); }
.ana-pill.muted { background: var(--canvas); color: var(--muted); border: 1px solid var(--line); }

.ana-subpanel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--canvas);
}
.ana-json-preview {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .78rem;
  overflow-x: auto;
  max-height: 360px;
}

dialog.ana-modal {
  width: min(92vw, 460px);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-md);
}
dialog.ana-modal::backdrop { background: rgba(13, 15, 54, .5); }

@media (max-width: 860px) {
  body.app-body { overflow-x: clip; }
  body.app-body:has(.wa-shell) .app-main {
    padding: 12px 10px 16px;
  }
  .wa-hide-mobile { display: none; }
  .wa-page-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin-bottom: 10px;
  }
  .wa-page-bar h1 { font-size: 1.25rem; }
  .wa-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    height: calc(100dvh - 132px);
    min-height: 440px;
    max-height: none;
  }
  .wa-shell.mobile-list .wa-sidebar {
    display: flex;
    flex: 1;
    width: 100%;
    border-right: 0;
    border-bottom: 0;
  }
  .wa-shell.mobile-list .wa-main { display: none; }
  .wa-shell.mobile-chat {
    height: calc(100dvh - 120px);
  }
  .wa-shell.mobile-chat .wa-sidebar { display: none; }
  .wa-shell.mobile-chat .wa-main {
    display: flex;
    flex: 1;
    width: 100%;
  }
  .wa-back-btn { display: inline-flex; }
  .wa-header {
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .wa-header .wa-avatar {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    font-size: 12px;
  }
  .wa-header-actions {
    gap: 6px;
  }
  .wa-header-actions button {
    min-height: 30px;
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
  }
  .wa-thread {
    padding: 10px 10px;
  }
  .wa-bubble {
    max-width: 86%;
    font-size: 13px;
  }
  .wa-composer {
    padding: 8px 10px;
    gap: 6px;
  }
  .wa-composer button {
    padding: 0 12px;
    font-size: 12.5px;
  }
}

/* ── Usuário logado na sidebar & Gestão de usuários (RBAC) ── */
.sidebar-user {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px;
  margin-bottom: 6px;
  border-radius: 10px;
  background: rgba(15, 23, 42, .05);
  color: var(--ink);
  min-width: 0;
}
.sidebar-user strong {
  font-size: .82rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user small {
  font-size: .72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.app-body[data-theme="navy"] .sidebar-user {
  background: rgba(255, 255, 255, .06);
  color: #f1f5ff;
}
body.app-body[data-theme="navy"] .sidebar-user small {
  color: #aeb6d1;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.user-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.user-card.user-inactive {
  opacity: .76;
  background: var(--canvas);
}
.user-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.user-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: .95rem;
  color: var(--ink);
}
.user-handle {
  font-size: .8rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--muted);
}
.user-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.user-perm-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: .74rem;
  font-weight: 600;
  background: var(--canvas);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.user-last-login {
  font-size: .74rem;
  color: var(--muted);
  margin-left: 4px;
}
.user-card-controls {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.user-details {
  flex: 1 1 260px;
}
.user-details > summary {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--canvas);
  color: var(--ink);
  font-size: .82rem;
  font-weight: 650;
  list-style: none;
}
.user-details > summary::-webkit-details-marker { display: none; }
.user-details[open] > summary {
  background: var(--green-soft);
  color: var(--green-deep);
  border-color: rgba(49, 173, 161, .35);
}
.user-inline-form {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--canvas);
}
.user-del-btn {
  min-height: 34px;
  height: 34px;
  padding: 0 12px;
  font-size: .82rem;
}

.perm-section {
  margin: 4px 0 8px;
}
.perm-heading {
  margin: 0 0 8px;
  font-size: .82rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.perm-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
}
.perm-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 2px 0 0;
  flex: 0 0 16px;
}
.perm-check span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.perm-check strong {
  font-size: .82rem;
  color: var(--ink);
  line-height: 1.25;
}
.perm-check small {
  font-size: .74rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.3;
}

@media (max-width: 860px) {
  .sidebar-user { display: none; }
  .perm-grid { grid-template-columns: 1fr; }
}

/* ── Editor do SOUL.md ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.soul-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
}
.soul-meta-items,
.soul-markers,
.soul-live-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.soul-meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  background: var(--canvas);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.soul-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.soul-textarea {
  width: 100%;
  min-height: 480px;
  margin: 0;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.55;
  tab-size: 2;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--canvas);
  color: var(--ink);
}
.soul-textarea:focus {
  outline: none;
  border-color: var(--green-deep);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(49, 173, 161, .16);
}
.soul-form-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.soul-note-wrap {
  flex: 1 1 280px;
  min-width: 0;
}
.soul-note-wrap input {
  margin-bottom: 0;
}
.soul-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.soul-history-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.soul-history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.soul-restore-btn {
  min-height: 34px;
  height: 34px;
  padding: 0 12px;
  font-size: .82rem;
}
@media (max-width: 860px) {
  .soul-textarea {
    min-height: 360px;
    font-size: 13px;
    padding: 12px;
  }
}
