/* ==========================================
   Iris CRM web: so o que a extensao nao precisava (pagina propria em vez do WhatsApp Web).
   O visual vem do iris.css (copia do CSS da extensao); o menu lateral, do PromosApp.
   ========================================== */

html,
body {
  margin: 0;
  height: 100%;
}

body.iris-app {
  background: var(--iris-bg-secondary);
  color: var(--iris-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ==========================================
   MENU LATERAL
   Estrutura copiada do PromosApp (promosappbr/webapp/public/css/style.css): fixo a partir de
   992px; abaixo disso vira gaveta, aberta pelo botao do topo (main.js). No desktop com mouse fica
   recolhido nos icones e abre por cima do conteudo ao passar o mouse (bloco no fim da secao).
   Cor: o degrade do cabecalho das telas (.iris-funil-modal-header, pedido do Siqueira), com o texto em
   branco cheio (contraste de 3,1 a 3,8, o do titulo das telas); hover e item ativo escurecem o
   verde em vez de clarear, o que sobe o contraste (4,6 no item ativo).
   ========================================== */

:root {
  --menu-from: #1fa855;
  --menu-to: #128C7E;
  --sidebar-width: 290px;
  --spacing-unit: 8px;
  /* Faixa recolhida: largura que deixa o icone (20px) no centro, com a margem e o recuo dos itens */
  --sidebar-rail: calc(var(--spacing-unit) * 5.5 + 20px);
  /* Onde comeca a area das telas: largura do menu aberto ou da faixa recolhida */
  --sidebar-offset: var(--sidebar-width);
  --iris-mobile-header-height: 56px;
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--menu-from) 0%, var(--menu-to) 100%);
  color: #ffffff;
  z-index: 9500;
  overflow-x: hidden;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 200ms ease-out;
  will-change: transform;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.45) transparent;
}

.sidebar.show {
  transform: translateX(0);
}

/* No PromosApp o reset do Bootstrap deixa tudo em border-box (item com 44px de altura total) */
.sidebar,
.sidebar *,
.sidebar *::before,
.sidebar *::after {
  box-sizing: border-box;
}

/* Fundo escuro atras da gaveta no celular */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9499;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease-out, visibility 200ms ease-out;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.45);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.65);
}

/* Marca no topo do menu */
.sidebar-brand {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 12px;
  /* Sem linha embaixo: a do titulo "Pagina inicial" ja separa a marca dos itens (duas linhas juntas
     ficavam estranhas, Siqueira); entre os dois, 8 px a mais (16 ficou demais, Siqueira) */
  padding: calc(var(--spacing-unit) * 2.5) calc(var(--spacing-unit) * 2.5) var(--spacing-unit);
  margin-bottom: var(--spacing-unit);
  text-decoration: none;
}

/* O logo e um circulo verde: o anel branco o separa do fundo verde */
.sidebar-brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #ffffff;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-brand-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #ffffff;
}

/* Nome do cliente (PAINEL_NOME): uma linha so, nome longo termina em reticencias e aparece
   inteiro no title do link */
.sidebar-brand-name {
  overflow: hidden;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.15;
  color: #ffffff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar .nav {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
  margin: 0;
  padding: 0 0 var(--spacing-unit);
  list-style: none;
}

/* Rotulo de secao entre grupos de itens, com a linha embaixo (pedido do Siqueira) */
.sidebar .nav-section-label {
  padding: calc(var(--spacing-unit) * 2.25) calc(var(--spacing-unit) * 2.75) var(--spacing-unit);
  margin-bottom: calc(var(--spacing-unit) * 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 1px calc(var(--spacing-unit) * 1.25);
  padding: calc(var(--spacing-unit) * 1.25) calc(var(--spacing-unit) * 1.5);
  border-radius: 8px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}

.sidebar .nav-link:hover,
.sidebar .nav-link:focus {
  color: #ffffff;
  background-color: rgba(0, 0, 0, 0.1);
  outline: none;
}

.sidebar .nav-link:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: -2px;
}

.sidebar .nav-link i {
  width: 20px;
  margin-right: calc(var(--spacing-unit) * 1.25);
  text-align: center;
  flex-shrink: 0;
}

.sidebar .nav-link span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .nav-link.active {
  background-color: rgba(0, 0, 0, 0.2);
  color: #ffffff;
  box-shadow: inset 3px 0 0 #ffffff;
  font-weight: 600;
}

/* Submenu (padrao do PromosApp, promosappbr/webapp/public/css/style.css): o pai e um botao com a
   seta e os filhos ficam recuados, sem o trilho do PromosApp (pedido do Siqueira); aberto pelo
   aria-expanded do pai (main.js) */
.sidebar button.nav-link {
  width: calc(100% - var(--spacing-unit) * 2.5);
  border: 0;
  background: none;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.sidebar .nav-link .submenu-arrow {
  width: auto;
  margin: 0 0 0 auto;
  padding-left: var(--spacing-unit);
  font-size: 11px;
  transition: transform 200ms ease-out;
}

.sidebar .submenu-toggle[aria-expanded="true"] .submenu-arrow {
  transform: rotate(180deg);
}

/* Pai da tela aberta: em negrito (recolhido no desktop, leva a marca do item ativo) */
.sidebar .submenu-toggle.has-active {
  font-weight: 600;
}

.sidebar .submenu {
  display: none;
  flex-direction: column;
  margin: calc(var(--spacing-unit) * 0.5) 0 calc(var(--spacing-unit) * 0.5) calc(var(--spacing-unit) * 3.5);
  padding: 0;
  list-style: none;
}

.sidebar .submenu-toggle[aria-expanded="true"] + .submenu {
  display: flex;
}

/* O submenu aberto rola para a vista sem ficar atras do pe do menu (usuario e Sair) */
.sidebar {
  scroll-padding-bottom: calc(var(--spacing-unit) * 8);
}

.sidebar .submenu .nav-link {
  margin: 1px var(--spacing-unit) 1px calc(var(--spacing-unit) * 0.75);
  padding: var(--spacing-unit) calc(var(--spacing-unit) * 1.5);
  color: #ffffff;
  font-size: 13px;
}

.sidebar .submenu .nav-link:hover,
.sidebar .submenu .nav-link:focus {
  color: #ffffff;
  background-color: rgba(0, 0, 0, 0.1);
}

.sidebar .submenu .nav-link.active {
  background-color: rgba(0, 0, 0, 0.2);
  box-shadow: inset 3px 0 0 #ffffff;
  color: #ffffff;
  font-weight: 600;
}

.sidebar .submenu .nav-link i {
  width: 16px;
  margin-right: var(--spacing-unit);
  font-size: 0.9em;
}

/* Pe do menu: usuario logado e Sair, presos embaixo mesmo com a lista rolando */
.sidebar-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: var(--spacing-unit);
  padding: var(--spacing-unit) calc(var(--spacing-unit) * 1.25) var(--spacing-unit) calc(var(--spacing-unit) * 2.75);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  /* Preso embaixo, cobre a lista que rola: a cor do fim do degrade */
  background-color: var(--menu-to);
}

.sidebar-user {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
}

.sidebar-user i {
  width: 20px;
  margin-right: calc(var(--spacing-unit) * 1.25);
  text-align: center;
  flex-shrink: 0;
}

.sidebar-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout-form {
  margin: 0 0 0 auto;
}

/* Sair: o vermelho do text-danger do PromosApp nao se le sobre o verde, entao fica branco e o
   vermelho aparece no hover; e botao porque o logout e POST com CSRF */
.sidebar-logout {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-unit);
  min-height: 44px;
  padding: 0 calc(var(--spacing-unit) * 1.5);
  border: 0;
  border-radius: 8px;
  background: none;
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease-out;
}

.sidebar-logout:hover,
.sidebar-logout:focus {
  background-color: #dc3545;
  outline: none;
}

.sidebar-logout:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: -2px;
}

/* Topo do celular (o .header do PromosApp): marca e botao do menu */
.iris-mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--iris-mobile-header-height);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px 0 16px;
  background: linear-gradient(135deg, var(--menu-from) 0%, var(--menu-to) 100%);
  z-index: 8000;
}

.iris-mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: #ffffff;
  font-size: 19px;
  font-weight: 700;
  text-decoration: none;
}

.iris-mobile-brand span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.iris-mobile-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #ffffff;
  flex-shrink: 0;
}

/* Botao do menu: o do PromosApp com as cores invertidas, porque fica sobre o verde do topo */
.toggle-sidebar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin-left: auto;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 8px;
  background-color: transparent;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}

.toggle-sidebar:hover,
.toggle-sidebar:focus-visible {
  background-color: #ffffff;
  color: var(--menu-to);
}

.toggle-sidebar i {
  pointer-events: none;
}

/* ==========================================
   AREA DAS TELAS (ao lado do menu; abaixo do topo no celular)
   ========================================== */

.iris-main {
  position: fixed;
  top: var(--iris-mobile-header-height);
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
}

@media (min-width: 992px) {
  :root {
    --sidebar-width: clamp(250px, 165px + 12.8vh, 290px);
    --spacing-unit: clamp(6px, 1.7px + 0.64vh, 8px);
  }

  .sidebar {
    transform: translateX(0);
  }

  .iris-main {
    top: 0;
    left: var(--sidebar-offset);
  }

  .iris-mobile-header,
  .sidebar-overlay {
    display: none !important;
  }
}

/* Desktop com mouse (pedido do Siqueira): so os icones; ao passar o mouse o menu abre completo por
   cima do conteudo, sem empurrar a tela. Em tela de toque nao ha mouse e o menu fica aberto. */
@media (min-width: 992px) and (hover: hover) {
  :root {
    --sidebar-offset: var(--sidebar-rail);
  }

  .sidebar {
    width: var(--sidebar-rail);
    transition: width 200ms ease-out, box-shadow 200ms ease-out;
  }

  /* Pequeno atraso para nao abrir quando o mouse so atravessa a borda; pelo teclado (Tab) abre
     tambem, mas o foco deixado por um clique nao o prende aberto */
  .sidebar:hover,
  .sidebar:has(:focus-visible) {
    width: var(--sidebar-width);
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.35);
    transition-delay: 120ms;
  }

  /* Logo no centro da faixa e parado no mesmo lugar quando o menu abre */
  .sidebar-brand {
    justify-content: flex-start;
    padding-left: calc((var(--sidebar-rail) - 42px) / 2);
    padding-right: 0;
  }

  .sidebar-brand-text,
  .sidebar .nav-link span,
  .sidebar .nav-link .submenu-arrow,
  .sidebar-user span,
  .sidebar-logout-form {
    opacity: 0;
    transition: opacity 150ms ease-out;
  }

  .sidebar:hover :is(.sidebar-brand-text, .nav-link span, .submenu-arrow, .sidebar-user span, .sidebar-logout-form),
  .sidebar:has(:focus-visible) :is(.sidebar-brand-text, .nav-link span, .submenu-arrow, .sidebar-user span, .sidebar-logout-form) {
    opacity: 1;
    transition-delay: 120ms;
  }

  /* Recolhido, o rotulo de secao some e fica a linha dele, que separa os grupos de icones */
  .sidebar .nav-section-label {
    color: transparent;
    transition: color 150ms ease-out;
  }

  .sidebar:hover .nav-section-label,
  .sidebar:has(:focus-visible) .nav-section-label {
    color: #ffffff;
    transition-delay: 120ms;
  }

  /* Recolhido, o submenu fica escondido (os filhos nao cabem na faixa) e o pai leva a marca da tela
     aberta; ao abrir o menu, volta como estava. E o ultimo item do menu, entao nada pula */
  .sidebar:not(:hover):not(:has(:focus-visible)) .submenu {
    display: none;
  }

  .sidebar:not(:hover):not(:has(:focus-visible)) .submenu-toggle.has-active {
    background-color: rgba(0, 0, 0, 0.2);
    box-shadow: inset 3px 0 0 #ffffff;
  }
}

/* ==========================================
   LOGIN (pagina inteira, mesmo modal da extensao)
   ========================================== */

body.iris-login-page {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #0b141a;
}

body.iris-login-page #iris-login-overlay {
  background: linear-gradient(180deg, #111b21 0%, #0b141a 100%);
  backdrop-filter: none;
}

.iris-login-password {
  position: relative;
}

.iris-login-password input {
  padding-right: 42px;
}

.iris-login-password button {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  color: #9ca3af;
  cursor: pointer;
  padding: 6px;
}

.iris-login-turnstile {
  display: flex;
  justify-content: center;
  margin: 4px 0 8px;
}

.iris-login-modal .iris-login-footer a {
  color: #25D366;
}

/* ==========================================
   UTILITARIOS
   ========================================== */

.hidden {
  display: none !important;
}

.iris-toast.warning {
  background: #d97706;
}

.iris-modal-wide .iris-modal-content {
  max-width: 720px;
}

.iris-modal-content {
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}

.iris-modal-body {
  overflow-y: auto;
}

/* Botao pequeno e desabilitado (na extensao vinham do CSS injetado pelo assinatura.js) */
.iris-btn.small {
  padding: 6px 12px;
  font-size: 12px;
}

.iris-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Campo que a API nao deixa trocar (ex.: telefone do contato na edicao) */
.iris-input[readonly] {
  background: #f0f2f5;
  color: #667781;
  cursor: not-allowed;
}

/* ==========================================
   TELAS EM SOBREPOSICAO
   Mesmo overlay da extensao (#iris-funil-overlay e irmaos), mas so sobre a area das telas:
   o menu lateral (no celular, o topo) fica visivel para trocar de tela com um clique.
   ========================================== */

.iris-screen-overlay {
  position: fixed;
  top: var(--iris-mobile-header-height) !important;
  left: 0 !important;
  right: 0;
  bottom: 0;
  width: auto !important;
  height: auto !important;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9000 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: IrisFunilFadeIn 0.2s ease;
}

@media (min-width: 992px) {
  .iris-screen-overlay {
    top: 0 !important;
    left: var(--sidebar-offset) !important;
  }
}

/* As janelas da extensao usam 92vw; aqui a largura vem da area ao lado do menu */
.iris-screen-overlay .iris-funil-modal {
  width: calc(100% - 48px);
  max-height: calc(100% - 24px);
}

.iris-funil-modal-header {
  gap: 12px;
}

/* No celular estreito o titulo e o botao do topo apertam o X, que virava oval */
.iris-funil-modal-close {
  flex-shrink: 0;
}

.iris-screen-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.iris-screen-header-actions:empty {
  display: none;
}

.iris-screen-header-actions .iris-btn {
  width: auto;
  padding: 7px 14px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 13px;
}

.iris-screen-header-actions .iris-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.iris-screen-pad {
  padding: 20px 24px;
}

.iris-screen-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  color: var(--iris-text-secondary);
}

/* Telas novas do site (Conexao e Usuarios): o mesmo tamanho das outras (.iris-funil-modal); o
   corpo rola */
.iris-conexao-modal .iris-funil-modal-body,
.iris-usuarios-modal .iris-funil-modal-body {
  overflow-y: auto;
}

.cx-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 20px;
}

.cx-card {
  padding: 20px;
  border: 1px solid var(--iris-border);
  border-radius: 12px;
  background: var(--iris-bg);
}

.cx-card h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 15px;
}

.cx-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.cx-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
}

.cx-status-dot.ok {
  background: var(--iris-primary);
  box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.18);
}

.cx-status-dot.wait {
  background: #f59e0b;
  animation: cxPulse 1.2s infinite;
}

.cx-status-dot.down {
  background: #ef4444;
}

@keyframes cxPulse {
  50% { opacity: 0.35; }
}

.cx-status-text strong {
  display: block;
  font-size: 16px;
}

.cx-status-text span {
  color: var(--iris-text-secondary);
  font-size: 13px;
}

.cx-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0 0 16px;
  font-size: 13.5px;
}

.cx-info dt {
  color: var(--iris-text-secondary);
}

.cx-info dd {
  margin: 0;
  font-weight: 500;
}

.cx-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-radius: 12px;
  background: var(--iris-bg-secondary);
  text-align: center;
}

.cx-qr img {
  width: 264px;
  height: 264px;
  padding: 8px;
  border-radius: 8px;
  background: #ffffff;
}

.cx-qr ol {
  margin: 0;
  padding-left: 18px;
  color: var(--iris-text-secondary);
  font-size: 13px;
  text-align: left;
  line-height: 1.6;
}

.cx-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--iris-secondary);
}

.cx-alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff4e5;
  color: #8a4b00;
  font-size: 13px;
  line-height: 1.5;
}

.cx-alert.danger {
  background: #fdecec;
  color: #991b1b;
}

.cx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cx-actions .iris-btn {
  width: auto;
}

.cx-pair-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.cx-pair-form .iris-input {
  flex: 1;
}

.cx-pair-form .iris-btn {
  width: auto;
  white-space: nowrap;
}

.cx-system {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.cx-system-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: var(--iris-bg-secondary);
  font-size: 13px;
}

.cx-system-item strong {
  display: block;
  font-size: 13.5px;
}

.cx-system-item span {
  color: var(--iris-text-secondary);
}

.us-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.us-table th,
.us-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--iris-border);
  text-align: left;
  vertical-align: middle;
}

.us-table th {
  color: var(--iris-text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.us-table tr.inactive td {
  opacity: 0.55;
}

.us-role {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--iris-bg-secondary);
  font-size: 12px;
  font-weight: 600;
}

.us-role.admin {
  background: #dcfce7;
  color: #166534;
}

.us-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.us-actions button {
  padding: 6px 10px;
  border: 1px solid var(--iris-border);
  border-radius: 6px;
  background: var(--iris-bg);
  color: var(--iris-text);
  font-size: 12.5px;
  cursor: pointer;
}

.us-actions button:hover {
  background: var(--iris-bg-secondary);
}

/* Texto dos botoes so no celular (abaixo); no desktop fica o icone com o title */
.us-action-label {
  display: none;
}

.us-password {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--iris-bg-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  text-align: center;
  user-select: all;
}

/* Tela Configuracoes (assinatura, privacidade e senha) */
.cfg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.cfg-grid .cx-card .iris-btn {
  width: auto;
}

.cfg-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--iris-border);
  font-size: 14px;
}

.cfg-toggle:last-child {
  border-bottom: 0;
}

.cfg-toggle small {
  display: block;
  color: var(--iris-text-secondary);
  font-size: 12px;
}

/* ==========================================
   PAGINAS DE ERRO
   ========================================== */

.iris-error-page .iris-login-modal {
  text-align: center;
}

.iris-error-page .iris-login-modal p {
  color: #d1d5db;
  font-size: 14px;
  margin: 0 0 20px;
}

.iris-error-page .iris-login-button {
  display: inline-block;
  text-decoration: none;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .cx-grid,
  .cx-system {
    grid-template-columns: 1fr;
  }

  .iris-screen-overlay .iris-funil-modal {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .iris-screen-pad {
    padding: 16px;
  }

  /* Usuarios: a tabela nao cabe; cada usuario vira um cartao como o da tela Conexao, com o
     rotulo a esquerda e o valor ao lado, e os botoes ganham texto (no toque nao ha title) */
  .us-table,
  .us-table tr,
  .us-table td {
    display: block;
  }

  .us-table thead {
    display: none;
  }

  .us-table tbody {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
  }

  .us-table tr {
    padding: 16px;
    border: 1px solid var(--iris-border);
    border-radius: 12px;
    background: var(--iris-bg);
  }

  .us-table td {
    padding: 0;
    border-bottom: 0;
  }

  .us-table td:first-child {
    margin-bottom: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--iris-border);
    overflow-wrap: anywhere;
  }

  .us-table td[data-label] {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 3px 0;
  }

  .us-table td[data-label]::before {
    content: attr(data-label);
    color: var(--iris-text-secondary);
  }

  .us-table td[data-label] > * {
    justify-self: start;
  }

  .us-table td:last-child {
    padding-top: 14px;
  }

  .us-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
  }

  .us-actions button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .us-action-label {
    display: inline;
  }
}

/* Celular estreito: na Conexao o rotulo vai em cima do valor, senao "Ultima mensagem recebida"
   ocupa meio cartao e o telefone quebra em duas linhas */
@media (max-width: 400px) {
  .cx-info {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .cx-info dt {
    font-size: 12px;
  }

  .cx-info dd {
    margin-bottom: 8px;
  }

  .cx-info dd:last-child {
    margin-bottom: 0;
  }
}

/* ==========================================
   TELA RESPOSTAS AUTOMATICAS
   ========================================== */

/* Como a tela Contatos: o corpo rola e os cartoes ficam em grade */
.iris-respostas-modal .iris-funil-modal-body {
  overflow-y: auto;
}

.respostas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

/* Cartao da resposta, copiado do .contact-card (iris.css) */
.resposta-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s;
}

.resposta-card:hover {
  border-color: #1fa855;
  box-shadow: 0 2px 8px rgba(31, 168, 85, 0.1);
}

.resposta-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
}

.resposta-card-kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background: #e9edef;
  color: #111b21;
}

.resposta-card-actions {
  display: flex;
  gap: 2px;
}

.resposta-card-actions button {
  background: none;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: all 0.2s;
}

.resposta-card-actions .btn-resposta-edit:hover {
  background: #e3f2fd;
  color: #1565c0;
}

.resposta-card-actions .btn-resposta-delete:hover {
  background: #fbe9e7;
  color: #c62828;
}

.resposta-card-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.resposta-card-avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1fa855, #128C7E);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 18px;
}

.resposta-card-info {
  flex: 1;
  min-width: 0;
}

.resposta-card-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #1a2e35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resposta-card-when {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.resposta-card-msg {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modal da resposta: dias da semana e os pares de campos (molde .ia-form-row) */
.resposta-days {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.resposta-day {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #1a2e35;
  cursor: pointer;
}

.resposta-day input {
  accent-color: #00a884;
}

#resposta-form .ia-form-row,
form[data-cfg="sla"] .ia-form-row {
  margin-bottom: 0;
}

/* ==========================================
   TELA WEBHOOK
   ========================================== */

/* Como a tela Respostas Automaticas: o corpo rola e os cartoes ficam em grade */
.iris-webhook-modal .iris-funil-modal-body {
  overflow-y: auto;
}

.webhooks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

/* Cartao da entrada, copiado do .resposta-card (que veio do .contact-card do iris.css) */
.webhook-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s;
}

.webhook-card:hover {
  border-color: #1fa855;
  box-shadow: 0 2px 8px rgba(31, 168, 85, 0.1);
}

.webhook-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
}

.webhook-card-kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background: #e9edef;
  color: #111b21;
}

.webhook-card-kind.on {
  background: #dcfce7;
  color: #166534;
}

.webhook-card-kind.test {
  background: #fef3c7;
  color: #92400e;
}

.webhook-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.webhook-card-actions .ia-toggle {
  margin-right: 6px;
}

.webhook-card-actions button {
  background: none;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: all 0.2s;
}

.webhook-card-actions .btn-webhook-edit:hover {
  background: #e3f2fd;
  color: #1565c0;
}

.webhook-card-actions .btn-webhook-delete:hover {
  background: #fbe9e7;
  color: #c62828;
}

.webhook-card-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.webhook-card-avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1fa855, #128C7E);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 18px;
}

.webhook-card-info {
  flex: 1;
  min-width: 0;
}

.webhook-card-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #1a2e35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.webhook-card-when {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.webhook-card-msg {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Botoes do pe do cartao: o visual dos botoes da tabela de Usuarios (.us-actions) */
.webhook-card-footer {
  display: flex;
  gap: 8px;
}

.webhook-card-footer button {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--iris-border);
  border-radius: 6px;
  background: var(--iris-bg);
  color: var(--iris-text);
  font-size: 12.5px;
  cursor: pointer;
}

.webhook-card-footer button:hover {
  background: var(--iris-bg-secondary);
}

/* URL no modal da entrada: selecionavel inteira, como a senha gerada em Usuarios (.us-password) */
.webhook-url {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--iris-bg-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  overflow-wrap: anywhere;
  user-select: all;
}

.webhook-url-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.webhook-url-actions .iris-btn {
  width: auto;
}

#webhook-form .ia-form-row {
  margin-bottom: 0;
}

.webhook-limit-group {
  max-width: 140px;
}

/* Historico: a tabela da tela Usuarios com o resultado de cada evento */
.webhook-history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.webhook-history-top .iris-btn {
  width: auto;
  flex-shrink: 0;
}

.webhook-result {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--iris-bg-secondary);
  font-size: 12px;
  font-weight: 600;
}

.webhook-result.sent {
  background: #dcfce7;
  color: #166534;
}

.webhook-result.pending {
  background: #fef3c7;
  color: #92400e;
}

.webhook-result.failed {
  background: #fee2e2;
  color: #991b1b;
}

.webhook-result-detail {
  display: block;
  margin-top: 4px;
  color: var(--iris-text-secondary);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.webhook-event-box {
  padding: 4px 0 8px;
  font-size: 13px;
}

.webhook-event-label {
  margin: 8px 0 4px;
  color: var(--iris-text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.webhook-event-msg {
  padding: 10px 12px;
  border-radius: 8px;
  background: #d9fdd3;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.webhook-event-json {
  max-height: 320px;
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  border-radius: 8px;
  background: var(--iris-bg-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre;
}

@media (max-width: 900px) {
  /* No celular a linha do evento aberto vira o proprio cartao, sem a borda do primeiro campo */
  .us-table tr.webhook-event-row td:first-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
  }

  .webhook-history-top {
    flex-direction: column;
    align-items: flex-start;
  }
}
