/* ============================================================
   Interart — Gerador de Orçamento (embed nativo no Chatwoot)
   Prefixo .iorc- pra isolar do CSS do Chatwoot.
   ============================================================ */

/* Overlay invisível — pointer-events:none pra não bloquear scroll/click na conversa.
   Fechamento da sidebar é só pelo botão X no header. */
.iorc-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 99998;
  display: none;
  pointer-events: none;
}
.iorc-overlay.iorc-open { display: block; }

/* Sidebar fixed — left/width sincronizados via JS pra coincidir com .conversations-list-wrap */
.iorc-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 380px; /* sobrescrito por JS via syncSidebarBounds */
  height: 100vh;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  font-family: 'Inter', 'Roboto', system-ui, Arial, sans-serif;
  color: #1f2937;
  transform: translateX(-100%);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.iorc-sidebar.iorc-open { transform: translateX(0); }

/* Header gradient roxo */
.iorc-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  user-select: none;
}
.iorc-title-wrap { display: flex; align-items: center; gap: 10px; }
.iorc-title-icon { font-size: 18px; }
.iorc-title { font-weight: 700; font-size: 14px; letter-spacing: 0.3px; }
.iorc-title-sub { font-size: 11px; opacity: 0.85; margin-left: 4px; }

.iorc-header-actions { display: flex; gap: 6px; align-items: center; }
.iorc-icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 120ms;
}
.iorc-icon-btn:hover { background: rgba(255, 255, 255, 0.3); }
.iorc-icon-btn.iorc-active { background: rgba(255, 255, 255, 0.4); }

/* Search bar */
.iorc-search-wrap {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #fafafa;
}
.iorc-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 120ms;
}
.iorc-search-input:focus { border-color: #6366f1; }

/* Histórico colapsável */
.iorc-history-panel {
  flex: 0 0 auto;
  border-bottom: 1px solid #e5e7eb;
  max-height: 0;
  overflow: hidden;
  transition: max-height 220ms ease-out;
  background: #f9fafb;
}
.iorc-history-panel.iorc-open { max-height: 240px; overflow-y: auto; }
.iorc-history-empty {
  padding: 24px 16px;
  text-align: center;
  color: #6b7280;
  font-size: 12px;
}
.iorc-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
.iorc-history-table th {
  background: #f3f4f6;
  font-weight: 700;
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
}
.iorc-history-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
}
.iorc-history-table tr:hover td { background: #eef2ff; }
.iorc-history-table .iorc-h-action {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: #6b7280;
}
.iorc-history-table .iorc-h-action:hover { background: #e0e7ff; color: #4338ca; }
.iorc-history-table .iorc-h-action.iorc-danger:hover { background: #fee2e2; color: #b91c1c; }

/* Body — lista de categorias + itens extras */
.iorc-body {
  flex: 1 1 auto;
  overflow-y: auto;
  background: #fff;
}
.iorc-loading,
.iorc-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 40px 16px;
  color: #6b7280;
  font-size: 13px;
  gap: 8px;
}
.iorc-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: iorc-spin 0.8s linear infinite;
}
@keyframes iorc-spin { to { transform: rotate(360deg); } }

/* Grid de categorias 2 colunas */
.iorc-categorias-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

/* Categoria (accordion) */
.iorc-categoria {
  border-bottom: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
}
.iorc-cat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
  transition: filter 120ms;
}
.iorc-cat-header:hover { filter: brightness(0.96); }
.iorc-cat-icon { flex-shrink: 0; }
.iorc-cat-name {
  flex: 1;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iorc-cat-count {
  flex-shrink: 0;
  height: 18px;
  min-width: 18px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.iorc-cat-arrow {
  flex-shrink: 0;
  transition: transform 180ms;
}
.iorc-categoria.iorc-expanded .iorc-cat-arrow { transform: rotate(180deg); }
.iorc-cat-items {
  max-height: 0;
  overflow: hidden;
  background: #fff;
  transition: max-height 280ms cubic-bezier(0.4, 0, 0.2, 1);
}
.iorc-categoria.iorc-expanded .iorc-cat-items { max-height: 2000px; }

/* Produto */
.iorc-produto {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  border-left: 3px solid transparent;
  transition: background-color 120ms;
}
.iorc-produto:hover { background: #f9fafb; }
.iorc-produto.iorc-selected { padding-left: 5px; }
.iorc-produto.iorc-selected:hover { filter: brightness(0.97); }
.iorc-produto-checkbox {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid #d1d5db;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}
.iorc-produto.iorc-selected .iorc-produto-checkbox::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.iorc-produto-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.iorc-produto-nome {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iorc-produto.iorc-selected .iorc-produto-nome { font-weight: 700; }
.iorc-produto-preco-range {
  font-size: 10px;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iorc-produto-soma-tag {
  display: inline-block;
  padding: 0 4px;
  border: 1px solid #a78bfa;
  border-radius: 3px;
  font-size: 9px;
  color: #7c3aed;
  margin-top: 2px;
  align-self: flex-start;
}
.iorc-produto-qtd,
.iorc-produto-preco {
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 3px 5px;
  font-size: 11.5px;
  outline: none;
  text-align: center;
  -moz-appearance: textfield;
}
.iorc-produto-qtd { width: 48px; }
.iorc-produto-preco { width: 64px; text-align: right; }
.iorc-produto-qtd::-webkit-outer-spin-button,
.iorc-produto-qtd::-webkit-inner-spin-button,
.iorc-produto-preco::-webkit-outer-spin-button,
.iorc-produto-preco::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.iorc-produto-qtd:focus,
.iorc-produto-preco:focus { border-color: #6366f1; }

/* Itens extras */
.iorc-extras-section {
  border-top: 2px solid #f59e0b;
  background: #fffbeb;
}
.iorc-extras-title {
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 700;
  color: #b45309;
}
.iorc-extra-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid #fef3c7;
  background: #fffbeb;
}
.iorc-extra-desc { flex: 1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iorc-extra-qty { font-size: 11.5px; color: #6b7280; }
.iorc-extra-preco { font-size: 12px; font-weight: 700; }
.iorc-extra-remove {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: #b91c1c;
}
.iorc-extra-remove:hover { background: #fee2e2; }

/* Footer com desconto + total + botões */
.iorc-footer {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 10px 12px;
}
.iorc-footer-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.iorc-desconto-input {
  width: 110px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}
.iorc-desconto-input:focus { border-color: #6366f1; }
.iorc-desconto-info {
  flex: 1;
  font-size: 10.5px;
  color: #6b7280;
  line-height: 1.3;
}
.iorc-total-wrap {
  text-align: right;
  min-width: 110px;
}
.iorc-total-value {
  font-size: 17px;
  font-weight: 700;
  color: #4f46e5;
  line-height: 1.1;
}
.iorc-total-label {
  font-size: 10px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.iorc-footer-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.iorc-extra-btn-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.iorc-btn {
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter 120ms, background-color 120ms;
}
.iorc-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.iorc-btn:not(:disabled):hover { filter: brightness(1.08); }
.iorc-btn-outline {
  background: #fff;
  border: 1px solid #d1d5db;
  color: #4b5563;
}
.iorc-btn-outline:not(:disabled):hover { background: #f9fafb; }
.iorc-btn-extra {
  background: #fff;
  border: 1px solid #f59e0b;
  color: #b45309;
  flex: 1;
}
.iorc-btn-extra:not(:disabled):hover { background: #fffbeb; }
.iorc-btn-whatsapp { background: #25d366; color: #fff; }
.iorc-btn-pdf { background: #10b981; color: #fff; }
.iorc-btn-save { background: #6366f1; color: #fff; }

/* Header injection — botão na conversa */
.iorc-open-btn {
  padding: 6px 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 6px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}
.iorc-open-btn:hover { filter: brightness(1.06); }

/* Toast */
.iorc-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 999999;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: iorc-toast-in 180ms ease-out;
}
.iorc-toast.iorc-toast-success { background: #047857; }
.iorc-toast.iorc-toast-error { background: #b91c1c; }
@keyframes iorc-toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Dialogs */
.iorc-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: iorc-fade-in 150ms ease-out;
}
@keyframes iorc-fade-in { from { opacity: 0; } to { opacity: 1; } }
.iorc-dialog {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 460px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', 'Roboto', system-ui, Arial, sans-serif;
}
.iorc-dialog-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.iorc-dialog-title { font-size: 16px; font-weight: 700; color: #1f2937; }
.iorc-dialog-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: #9ca3af;
  padding: 0 4px;
}
.iorc-dialog-close:hover { color: #4b5563; }
.iorc-dialog-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}
.iorc-dialog-footer {
  padding: 12px 18px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.iorc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.iorc-field-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.iorc-field-input {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 120ms;
}
.iorc-field-input:focus { border-color: #6366f1; }
.iorc-field-row { display: flex; gap: 10px; }
.iorc-field-row > .iorc-field { flex: 1; }
