/* Zeroth Finance Hub — Chat Widget */

.cw-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.cw-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.55);
}
.cw-fab.open { transform: rotate(45deg); }

.cw-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  background: #0f172a;
  color: #e2e8f0;
  border-left: 1px solid #1e293b;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease-out;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.cw-drawer.open { transform: translateX(0); }

.cw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #1e293b;
  background: #0f172a;
  flex-shrink: 0;
}
.cw-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f1f5f9;
}
.cw-title-sub {
  font-size: 0.65rem;
  color: #64748b;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cw-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
.cw-close:hover { color: #e2e8f0; }

.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cw-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 90%;
}
.cw-msg.user { align-self: flex-end; }
.cw-msg.assistant { align-self: flex-start; }
.cw-msg-role {
  font-size: 0.625rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.cw-msg.user .cw-msg-role { text-align: right; }
.cw-msg-bubble {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.8125rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.cw-msg.user .cw-msg-bubble {
  background: #3b82f6;
  color: white;
  border-bottom-right-radius: 2px;
}
.cw-msg.assistant .cw-msg-bubble {
  background: #1e293b;
  color: #e2e8f0;
  border-bottom-left-radius: 2px;
}
.cw-msg.error .cw-msg-bubble {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.cw-tool-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.cw-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 10px;
  font-size: 0.6875rem;
  color: #c4b5fd;
  font-family: 'SF Mono', Menlo, monospace;
}
.cw-tool-chip.err {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.cw-tool-chip.noop {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.3);
  color: #94a3b8;
}

.cw-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: 0.75rem;
  font-style: italic;
  padding: 4px 2px;
}
.cw-thinking-dots { display: inline-flex; gap: 3px; }
.cw-thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #64748b;
  animation: cw-blink 1.2s infinite;
}
.cw-thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.cw-thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cw-blink { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

.cw-input-wrap {
  padding: 12px 16px 16px;
  border-top: 1px solid #1e293b;
  flex-shrink: 0;
}
.cw-input-identity {
  font-size: 0.65rem;
  color: #64748b;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.cw-input-identity a {
  color: #64748b;
  text-decoration: underline;
  cursor: pointer;
}
.cw-input-identity a:hover { color: #94a3b8; }
.cw-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.cw-input {
  flex: 1;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  padding: 9px 12px;
  font-size: 0.8125rem;
  font-family: inherit;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  outline: none;
}
.cw-input:focus { border-color: #3b82f6; }
.cw-send {
  background: #3b82f6;
  border: none;
  color: white;
  padding: 0 14px;
  height: 38px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
}
.cw-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.cw-hint {
  margin-top: 6px;
  font-size: 0.625rem;
  color: #475569;
  text-align: center;
}

.cw-empty {
  color: #64748b;
  font-size: 0.8125rem;
  text-align: center;
  padding: 40px 20px;
  line-height: 1.5;
}
.cw-empty-examples {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  text-align: left;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}
.cw-example {
  padding: 6px 10px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  font-size: 0.7rem;
  color: #94a3b8;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.cw-example:hover { background: #334155; color: #e2e8f0; }

@media (max-width: 640px) {
  .cw-drawer { width: 100vw; }
  .cw-fab { bottom: 16px; right: 16px; }
}
