/* Widget da Cora — balão flutuante + painel de chat. Prefixo .cora- para isolar. */
:root { --cora-primary: var(--primary-color, #667eea); }

#cora-widget {
  position: fixed; right: 20px; bottom: 20px; z-index: 1080;
  display: flex; flex-direction: column; align-items: flex-end;
  max-width: min(420px, calc(100vw - 24px));
}
#cora-widget.cora-panel-left { align-items: flex-start; }
#cora-widget.cora-dragging { cursor: grabbing; user-select: none; }

.cora-fab {
  min-width: 58px; min-height: 58px; border-radius: 999px; border: none;
  background: var(--cora-primary); color: #fff; font-size: 1.4rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.25); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 0 18px 0 14px;
  transition: transform .15s ease, box-shadow .15s ease;
  white-space: nowrap;
  touch-action: none;
  flex-direction: row-reverse;
}
.cora-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 10px 24px rgba(0,0,0,.3); }
.cora-fab.cora-aberto { transform: scale(.9); opacity: .85; }
.cora-fab-icon {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  position: relative;
}
.cora-fab-base { font-size: 1rem; }
.cora-fab-badge {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(255,255,255,.95);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--cora-primary);
}
.cora-fab-badge i { font-size: .62rem; }
.cora-fab-label { font-size: .95rem; font-weight: 600; letter-spacing: .01em; }

.cora-panel {
  position: absolute; right: 0; bottom: calc(100% + 10px);
  width: 370px; max-width: min(370px, calc(100vw - 32px));
  height: 560px; max-height: min(560px, calc(100vh - 120px));
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,.28); display: flex; flex-direction: column;
  animation: cora-in .18s ease;
}
#cora-widget.cora-panel-left .cora-panel { left: 0; right: auto; }
#cora-widget.cora-panel-top .cora-panel { top: calc(100% + 10px); bottom: auto; }
@keyframes cora-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.cora-header {
  background: var(--cora-primary); color: #fff; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.cora-header-id { display: flex; align-items: center; gap: 10px; }
.cora-header-id small { display: block; opacity: .85; font-size: .72rem; }
.cora-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
}
.cora-header-actions { display: flex; align-items: center; gap: 2px; }
.cora-icon-btn { background: transparent; border: none; color: #fff; font-size: 1rem; cursor: pointer; opacity: .9; padding: 4px 6px; border-radius: 6px; }
.cora-icon-btn:hover { opacity: 1; background: rgba(255,255,255,.12); }
.cora-icon-btn.cora-ativo { background: rgba(255,255,255,.2); }

.cora-search-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff; border-bottom: 1px solid #eef0f5; }
.cora-search-ico { color: #9aa0ac; font-size: .82rem; }
.cora-search-input { flex: 1; border: 1px solid #dfe3ea; border-radius: 10px; padding: 6px 10px; font-size: .85rem; outline: none; font-family: inherit; }
.cora-search-input:focus { border-color: var(--cora-primary); }
.cora-search-count { font-size: .72rem; color: #7a8090; white-space: nowrap; }
.cora-search-clear { color: #7a8090; }
.cora-search-clear:hover { background: rgba(0,0,0,.06); }
mark.cora-hl { background: #ffe08a; color: inherit; padding: 0 1px; border-radius: 3px; }

.cora-resultados { flex: 1; overflow-y: auto; padding: 10px 12px; background: #f7f8fb; display: flex; flex-direction: column; gap: 8px; }
.cora-resultado { text-align: left; width: 100%; background: #fff; border: 1px solid #eef0f5; border-radius: 10px; padding: 8px 10px; cursor: pointer; font-family: inherit; }
.cora-resultado:hover { border-color: var(--cora-primary); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.cora-resultado-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.cora-resultado-quem { font-size: .72rem; font-weight: 600; }
.cora-resultado-quem.bot { color: var(--cora-primary); }
.cora-resultado-quem.user { color: #555; }
.cora-resultado-data { font-size: .68rem; color: #9aa0ac; }
.cora-resultado-trecho { font-size: .84rem; color: #2b2f38; line-height: 1.4; }
.cora-vazio, .cora-buscando { text-align: center; color: #9aa0ac; font-size: .85rem; padding: 20px; }

.cora-mensagens { flex: 1; overflow-y: auto; padding: 14px; background: #f7f8fb; display: flex; flex-direction: column; gap: 10px; }
.cora-msg { display: flex; }
.cora-msg-user { justify-content: flex-end; }
.cora-bolha {
  max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: .9rem; line-height: 1.45;
  white-space: normal; word-wrap: break-word; box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.cora-msg-bot .cora-bolha { background: #fff; border: 1px solid #eef0f5; border-top-left-radius: 4px; color: #2b2f38; }
.cora-msg-user .cora-bolha { background: var(--cora-primary); color: #fff; border-top-right-radius: 4px; }
.cora-bolha p { margin: 0 0 .5em; }
.cora-bolha p:last-child { margin-bottom: 0; }
.cora-bolha ul { margin: .3em 0; padding-left: 1.2em; }
.cora-bolha code { background: rgba(0,0,0,.06); padding: 0 4px; border-radius: 4px; font-size: .85em; }
.cora-bolha .cora-sugestao { color: var(--cora-primary); text-decoration: none; cursor: pointer; }
.cora-bolha .cora-sugestao:hover { text-decoration: underline; }

.cora-status { font-size: .78rem; color: #7a8090; font-style: italic; padding-left: 4px; }
.cora-typing::after { content: '▋'; animation: cora-blink 1s steps(2) infinite; }
@keyframes cora-blink { 50% { opacity: 0; } }

.cora-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid #eef0f5; background: #fff; }
.cora-input {
  flex: 1; resize: none; border: 1px solid #dfe3ea; border-radius: 12px; padding: 9px 11px;
  font-size: .9rem; max-height: 120px; outline: none; font-family: inherit;
}
.cora-input:focus { border-color: var(--cora-primary); }
.cora-enviar {
  width: 40px; height: 40px; flex: none; border: none; border-radius: 50%;
  background: var(--cora-primary); color: #fff; cursor: pointer; font-size: .95rem;
}
.cora-enviar:disabled { opacity: .5; cursor: not-allowed; }
.cora-rodape { margin: 0; padding: 4px 12px 8px; font-size: .68rem; color: #9aa0ac; text-align: center; background: #fff; }

@media (max-width: 480px) {
  #cora-widget {
    right: 14px; bottom: 14px; left: auto !important; top: auto !important;
    max-width: calc(100vw - 28px); align-items: flex-end;
  }
  .cora-fab {
    min-height: 54px;
    padding: 0 16px 0 12px;
    gap: 8px;
  }
  .cora-fab-label { font-size: .9rem; }
  .cora-panel {
    position: fixed; right: 8px; left: 8px; bottom: 80px; top: auto;
    width: auto; max-width: none; height: calc(100vh - 100px);
  }
}
