/* Floating Assistant Widget — bottom-right, always-on after auth.
   Quiet by default, expands into a side panel on click. */

.asw-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brand, #0e5259);
  color: #fff;
  border: none;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .22);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9990;
  transition: transform .18s ease, box-shadow .18s ease;
}
.asw-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, .28); }
.asw-fab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; }
.asw-fab .asw-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid var(--brand, #0e5259);
  display: none;
}
.asw-fab.has-nudges .asw-dot { display: block; }

.asw-panel {
  position: fixed;
  right: 18px;
  bottom: 84px;
  width: 380px;
  max-width: calc(100vw - 36px);
  height: min(620px, calc(100vh - 110px));
  background: var(--bg, #fff);
  color: var(--fg, #0f172a);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .22);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9991;
}
.asw-panel.open { display: flex; }

.asw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--brand, #0e5259);
  color: #fff;
}
.asw-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: .2px; }
.asw-head .asw-sub { font-size: 11px; opacity: .8; margin-top: 1px; }
.asw-head-actions { display: flex; gap: 6px; }
.asw-icon-btn {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: none;
  border-radius: 6px;
  width: 28px; height: 28px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.asw-icon-btn:hover { background: rgba(255,255,255,.22); }
.asw-icon-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

.asw-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.asw-nudge {
  background: var(--card-bg, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-left: 3px solid var(--brand, #0e5259);
  border-radius: 10px;
  padding: 10px 12px;
}
.asw-nudge.urg-critica { border-left-color: #dc2626; }
.asw-nudge.urg-alta { border-left-color: #b45309; }
.asw-nudge.urg-normal { border-left-color: #0e5259; }
.asw-nudge-title { font-size: 13px; font-weight: 600; margin: 0 0 3px; }
.asw-nudge-reason { font-size: 12px; color: var(--muted, #64748b); margin: 0 0 8px; line-height: 1.45; }
.asw-nudge-actions { display: flex; gap: 6px; }
.asw-nudge-actions button {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border, #e2e8f0);
  background: #fff;
  color: var(--fg, #0f172a);
  cursor: pointer;
}
.asw-nudge-actions button.primary {
  background: var(--brand, #0e5259);
  color: #fff;
  border-color: var(--brand, #0e5259);
}
.asw-nudge-actions button:hover { filter: brightness(1.05); }

.asw-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 92%;
}
.asw-msg.user { align-self: flex-end; align-items: flex-end; }
.asw-msg.assistant { align-self: flex-start; align-items: flex-start; }
.asw-msg-bubble {
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.asw-msg.user .asw-msg-bubble {
  background: var(--brand, #0e5259);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.asw-msg.assistant .asw-msg-bubble {
  background: var(--card-bg, #f1f5f9);
  color: var(--fg, #0f172a);
  border-bottom-left-radius: 4px;
}
.asw-msg-bubble strong { font-weight: 700; }

.asw-typing {
  align-self: flex-start;
  font-size: 12px;
  color: var(--muted, #64748b);
  padding: 4px 11px;
}
.asw-typing::after {
  content: '...';
  display: inline-block;
  animation: asw-dots 1.4s steps(4, end) infinite;
}
@keyframes asw-dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

.asw-foot {
  border-top: 1px solid var(--border, #e2e8f0);
  padding: 10px 12px;
  background: var(--bg, #fff);
}
.asw-input {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.asw-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  background: var(--bg, #fff);
  color: var(--fg, #0f172a);
  min-height: 36px;
  max-height: 120px;
  line-height: 1.4;
}
.asw-input textarea:focus { outline: 2px solid var(--brand, #0e5259); outline-offset: -1px; border-color: transparent; }
.asw-send {
  background: var(--brand, #0e5259);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  height: 36px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.asw-send:disabled { opacity: .5; cursor: not-allowed; }

.asw-empty {
  text-align: center;
  color: var(--muted, #64748b);
  font-size: 12px;
  padding: 24px 12px;
  line-height: 1.5;
}
.asw-empty strong { color: var(--fg, #0f172a); }

[data-theme="dark"] .asw-panel { background: #0b1220; color: #e2e8f0; border-color: #1e293b; }
[data-theme="dark"] .asw-nudge { background: #111827; border-color: #1e293b; }
[data-theme="dark"] .asw-nudge-actions button { background: #0b1220; color: #e2e8f0; border-color: #1e293b; }
[data-theme="dark"] .asw-msg.assistant .asw-msg-bubble { background: #111827; color: #e2e8f0; }
[data-theme="dark"] .asw-input textarea { background: #0b1220; color: #e2e8f0; border-color: #1e293b; }
[data-theme="dark"] .asw-foot { background: #0b1220; border-color: #1e293b; }

@media (max-width: 640px) {
  .asw-panel {
    right: 8px; left: 8px; bottom: 76px;
    width: auto; max-width: none;
    height: min(72vh, calc(100vh - 90px));
  }
  .asw-fab { right: 14px; bottom: 14px; }
}
