/* AdmComIA — utilitários compostos */

/* Reset essencial — Tailwind preflight está desligado, inputs/textarea com width:100% + padding
   ficam maiores que container sem box-sizing border-box. Causa overflow visível dos modais. */
*, *::before, *::after { box-sizing: border-box; }

.input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid rgb(203 213 225);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  background: white;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: rgb(43 86 212);
  box-shadow: 0 0 0 3px rgba(59, 108, 242, 0.15);
}
.input:disabled {
  background: rgb(241 245 249);
  color: rgb(100 116 139);
  cursor: not-allowed;
}

.btn-primary {
  padding: 0.625rem 1rem;
  background: rgb(43 86 212);
  color: white;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: rgb(31 67 173); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* Botão em estado "ocupado" (durante ação async) */
.btn-ocupado {
  cursor: wait !important;
  opacity: 0.85;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ============================================================
 * Chat estilo WhatsApp — usado no Meu Espaço → Skill Central
 * ============================================================ */
.wa-chat {
  background-color: #efeae2;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40'><path d='M20 0 L40 20 L20 40 L0 20 Z' fill='%23e9e1d2' fill-opacity='0.4'/></svg>");
  background-size: 80px 80px;
  border-radius: 12px;
  padding: 14px 12px;
  min-height: 240px;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wa-row { display: flex; }
.wa-row.out { justify-content: flex-end; }
.wa-row.in  { justify-content: flex-start; }

.wa-bubble {
  max-width: 78%;
  padding: 6px 8px 18px 9px;
  border-radius: 8px;
  position: relative;
  font-size: 15px;
  line-height: 1.35;
  color: #111b21;
  box-shadow: 0 1px 0.5px rgba(11,20,26,.13);
  word-wrap: break-word;
  white-space: pre-wrap;
}
.wa-row.out .wa-bubble { background: #d9fdd3; border-top-right-radius: 0; }
.wa-row.in  .wa-bubble { background: #ffffff;  border-top-left-radius: 0; }

.wa-author {
  font-size: 13px;
  font-weight: 600;
  color: #06cf9c;
  margin-bottom: 2px;
}
.wa-row.out .wa-author { color: #1f7a8c; }

.wa-time {
  position: absolute;
  bottom: 3px;
  right: 7px;
  font-size: 11px;
  color: #667781;
  white-space: nowrap;
}
.wa-time-extra { color: #8696a0; font-size: 10px; }

/* "Tail" — pequeno triângulo identificador WhatsApp */
.wa-row.out .wa-bubble::after {
  content: "";
  position: absolute;
  top: 0; right: -8px;
  border: 8px solid transparent;
  border-top-color: #d9fdd3;
  border-right: 0;
}
.wa-row.in .wa-bubble::after {
  content: "";
  position: absolute;
  top: 0; left: -8px;
  border: 8px solid transparent;
  border-top-color: #ffffff;
  border-left: 0;
}

.wa-link {
  color: #027eb5;
  text-decoration: underline;
  word-break: break-all;
}
.wa-link:hover { color: #015d85; }

.wa-tools-tag {
  display: inline-block;
  font-size: 10px;
  background: #e7f3ff;
  color: #1f43ad;
  border-radius: 999px;
  padding: 1px 6px;
  margin-top: 4px;
}

.wa-loading {
  align-self: flex-start;
  background: #ffffff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #667781;
  font-style: italic;
  box-shadow: 0 1px 0.5px rgba(11,20,26,.13);
}
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
.btn-ocupado-txt { font-size: inherit; line-height: 1; }

.btn-secondary {
  padding: 0.5rem 0.875rem;
  background: white;
  color: rgb(51 65 85);
  border: 1px solid rgb(203 213 225);
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: rgb(248 250 252); }

.btn-danger {
  padding: 0.5rem 0.875rem;
  background: rgb(220 38 38);
  color: white;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
}
.btn-danger:hover { background: rgb(185 28 28); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  background: transparent;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: rgb(71 85 105);
  transition: background 0.15s;
}
.btn-icon:hover { background: rgb(241 245 249); }

.tab-btn { transition: all 0.15s; cursor: pointer; border: none; }
.tab-vend { transition: all 0.15s; cursor: pointer; border: none; background: transparent; }
.tab-btn.tw-bg-white { color: rgb(15 23 42); }

.nav-btn {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: rgb(51 65 85);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  display: block;
}
.nav-btn:hover:not(:disabled) { background: rgb(241 245 249); }
.nav-btn.active {
  background: rgb(238 245 255);
  color: rgb(31 67 173);
  font-weight: 600;
}

.card {
  background: white;
  border: 1px solid rgb(226 232 240);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid rgb(226 232 240);
  font-weight: 600;
  color: rgb(71 85 105);
  background: rgb(248 250 252);
}
.table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid rgb(241 245 249);
}
.table tr:hover td { background: rgb(248 250 252); }

.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-success { background: rgb(220 252 231); color: rgb(22 101 52); }
.badge-warn    { background: rgb(254 249 195); color: rgb(133 77 14); }
.badge-danger  { background: rgb(254 226 226); color: rgb(153 27 27); }
.badge-neutral { background: rgb(241 245 249); color: rgb(51 65 85); }

.msg-success { background: rgb(220 252 231); color: rgb(22 101 52); }
.msg-error   { background: rgb(254 226 226); color: rgb(153 27 27); }
.msg-info    { background: rgb(219 234 254); color: rgb(30 64 175); }

/* ============================================================
   DRAWER MOBILE — sidebar off-canvas em <768px
   ============================================================ */
@media (max-width: 767.98px) {
  #aside-menu {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.1);
  }
  #aside-menu.aberto { transform: translateX(0); }
}
@media (min-width: 768px) {
  #aside-menu { transform: none; transition: transform 0.25s ease, width 0.25s ease, margin 0.25s ease; }
  #aside-backdrop { display: none !important; }
  /* Recolhido em desktop: sidebar oculta, main ocupa largura cheia */
  #aside-menu.recolhido {
    transform: translateX(-100%);
    margin-left: -14rem;        /* ≈ 224px (md:tw-w-56) */
    overflow: hidden;
  }
}

/* ============================================================
   MODAL CANÔNICO DataMarcada (regra universal aplicada via ns.modal.abrir)
   - Header fixo com botão X no topo direito
   - Body com 1 único scroll vertical (sem horizontal)
   - Footer fixo com botões
   ============================================================ */
#modal-card {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  width: 100%;
  max-width: 32rem;
  background: white;
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  overflow: hidden;
}
.modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid rgb(226 232 240);
  background: white;
}
.modal-title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: rgb(15 23 42);
  line-height: 1.3;
  word-break: break-word;
}
.modal-close {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  font-size: 1.5rem;
  line-height: 1;
  color: rgb(100 116 139);
  cursor: pointer;
  padding: 0;
}
.modal-close:hover { background: rgb(241 245 249); color: rgb(15 23 42); }
.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 1.25rem;
  min-width: 0;
  word-break: break-word;
}
/* Tabelas dentro do modal nunca empurram a largura: scrollam por dentro */
.modal-body table { max-width: 100%; }
.modal-body .modal-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; }
/* Inputs/selects/textareas respeitam a largura do body do modal */
.modal-body input,
.modal-body select,
.modal-body textarea { max-width: 100%; }
/* Validação inline canônica DataMarcada — usada por _validacaoInline */
.campo-invalido {
  border-color: rgb(239 68 68) !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,.15) !important;
  background: rgb(254 242 242) !important;
}
.erro-inline { animation: erro-inline-pulso 0.4s ease-out; }
@keyframes erro-inline-pulso {
  0% { opacity: 0; transform: translateY(-2px); }
  100% { opacity: 1; transform: translateY(0); }
}
.modal-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgb(226 232 240);
  background: white;
  flex-wrap: wrap;
}
.modal-footer:empty { padding: 0; border-top: none; }

/* Mobile/tablet: full-width quase total */
@media (max-width: 640px) {
  #modal-card {
    max-width: 96vw;
    max-height: 95vh;
    border-radius: 0.875rem;
  }
  .modal-header { padding: 0.75rem 1rem; }
  .modal-body { padding: 0.875rem 1rem; }
  .modal-footer { padding: 0.625rem 1rem; }
}

/* Modal header fixo + footer fixo — LEGADO (mantido para compat de modais que ainda usam manualmente) */
.modal-header-sticky {
  position: sticky;
  top: -1.5rem;                  /* neutraliza padding (p-6) do #modal-card para colar no topo real */
  background: white;
  z-index: 2;
  padding-top: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgb(226 232 240);
  margin-bottom: 0.75rem;
}
.modal-footer-sticky {
  position: sticky;
  bottom: -1.5rem;
  background: white;
  z-index: 2;
  padding-top: 0.75rem;
  padding-bottom: 1.5rem;
  margin-top: 0.75rem;
  border-top: 1px solid rgb(226 232 240);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Tooltip universal — uso: <span class="tip" data-tip="texto">ⓘ</span>
   Renderiza via JS num popup fixo no <body> para não ser cortado por overflow do modal. */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 9999px;
  background: rgb(226 232 240);
  color: rgb(71 85 105);
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  user-select: none;
}
.tip:hover, .tip:focus { background: rgb(203 213 225); outline: none; }

/* Popup global injetado via JS (#tip-popup) */
#tip-popup {
  position: fixed;
  z-index: 9999;
  background: rgb(15 23 42);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  max-width: 320px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}
#tip-popup.visivel { opacity: 1; }
#tip-popup::before {
  content: '';
  position: absolute;
  border: 6px solid transparent;
}
#tip-popup.acima::before  { left: 50%; bottom: -12px; transform: translateX(-50%); border-top-color: rgb(15 23 42); }
#tip-popup.abaixo::before { left: 50%; top:    -12px; transform: translateX(-50%); border-bottom-color: rgb(15 23 42); }

/* =================== PAINEL DE DOCUMENTAÇÃO =================== */
.doc-panel {
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  margin-bottom: 18px;
  position: relative;
}
.doc-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: #1e3a8a;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 11;
  border-radius: 10px 10px 0 0;
}
.doc-toggle:hover { background: rgba(59,130,246,0.08); }
.doc-toggle-left, .doc-toggle-right { display: flex; align-items: center; gap: 8px; }
.doc-toggle-titulo { font-weight: 600; }
.doc-versao { font-size: 11px; color: #64748b; }
.doc-chevron { font-size: 12px; color: #475569; }
.doc-badge-novo {
  background: #ef4444;
  color: white;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.5px;
  animation: pulse-badge 1.6s ease-in-out infinite;
}
.doc-badge-gap {
  background: #f59e0b;
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.doc-body {
  border-top: 1px solid #bfdbfe;
  background: white;
  padding: 0;
}
.doc-menu-rapido {
  position: sticky;
  top: 46px;
  z-index: 10;
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  overflow-x: auto;
}
@media (max-width: 640px) {
  .doc-menu-rapido { flex-wrap: nowrap; overflow-x: auto; }
}
.doc-chip {
  display: inline-block;
  background: #f1f5f9;
  color: #334155;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.doc-chip:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}

.doc-corpo { padding: 16px 20px; }
.doc-section { padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.doc-section:last-child { border-bottom: none; }
.doc-h2 {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 10px;
  scroll-margin-top: 60px;
}
.doc-h3 {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin: 14px 0 6px;
}
.doc-content { font-size: 15px; line-height: 1.6; color: #334155; }
.doc-content p { margin: 8px 0; }
.doc-list { margin: 8px 0 8px 22px; padding: 0; }
.doc-list li { margin: 4px 0; }
.doc-list-num { list-style: decimal; }
.doc-blockquote {
  border-left: 4px solid #3b82f6;
  background: #eff6ff;
  padding: 8px 14px;
  margin: 10px 0;
  color: #1e40af;
  font-style: italic;
  border-radius: 0 6px 6px 0;
}
.doc-content code {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #be185d;
}
.doc-img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin: 10px 0;
  cursor: zoom-in;
  display: block;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.doc-img:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.12); }
.doc-img-placeholder {
  background: #f1f5f9;
  border: 2px dashed #cbd5e1;
  color: #64748b;
  padding: 24px;
  border-radius: 8px;
  margin: 10px 0;
  text-align: center;
  font-size: 14px;
}
.doc-gap-aviso {
  margin: 16px 20px;
  padding: 12px 14px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  font-size: 13px;
  color: #78350f;
}
.doc-gap-aviso code {
  background: #fde68a;
  color: #78350f;
  padding: 1px 6px;
  border-radius: 3px;
}
