/* Ezra AI Advisor Chat Widget */

.ezra-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0f172a;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.35);
  z-index: 9999;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ezra-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(15, 23, 42, 0.45);
}
.ezra-chat-btn .ezra-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: sans-serif;
}

.ezra-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 380px;
  height: 560px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  transform: translateY(20px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s ease;
}
.ezra-chat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

.ezra-chat-header {
  background: #0f172a;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ezra-chat-header-avatar {
  width: 36px;
  height: 36px;
  background: #1e3a5f;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.ezra-chat-header-info {
  flex: 1;
}
.ezra-chat-header-title {
  font-weight: 700;
  font-size: 14px;
  font-family: sans-serif;
}
.ezra-chat-header-status {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: sans-serif;
}
.ezra-chat-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}
.ezra-chat-close {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s;
}
.ezra-chat-close:hover { color: #fff; }

.ezra-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.ezra-chat-messages::-webkit-scrollbar { width: 4px; }
.ezra-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ezra-chat-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 2px; }

.ezra-chat-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}
.ezra-chat-prompts-label {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: sans-serif;
  margin-bottom: 4px;
}
.ezra-chat-prompt-chip {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  font-family: sans-serif;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.ezra-chat-prompt-chip:hover {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}

.ezra-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  font-family: sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
}
.ezra-msg.user { align-self: flex-end; align-items: flex-end; }
.ezra-msg.ai { align-self: flex-start; align-items: flex-start; }

.ezra-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.ezra-msg.user .ezra-msg-bubble {
  background: #0f172a;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ezra-msg.ai .ezra-msg-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}
.ezra-msg-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 3px;
  padding: 0 4px;
}

.ezra-typing {
  align-self: flex-start;
  background: #f1f5f9;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.ezra-typing span {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: ezra-bounce 1.2s infinite;
}
.ezra-typing span:nth-child(2) { animation-delay: 0.2s; }
.ezra-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ezra-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

.ezra-chat-footer {
  padding: 12px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
}
.ezra-chat-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: sans-serif;
  color: #1e293b;
  outline: none;
  resize: none;
  line-height: 1.4;
  max-height: 96px;
  transition: border-color 0.15s;
}
.ezra-chat-input:focus { border-color: #0f172a; }
.ezra-chat-input::placeholder { color: #94a3b8; }
.ezra-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  align-self: flex-end;
  transition: background 0.15s, transform 0.1s;
}
.ezra-chat-send:hover { background: #1e3a5f; }
.ezra-chat-send:active { transform: scale(0.95); }
.ezra-chat-send:disabled { background: #cbd5e1; cursor: not-allowed; }

/* Markdown rendered content inside AI bubbles */
.ezra-msg-bubble.ezra-md { padding: 12px 14px; }
.ezra-msg-bubble.ezra-md h1,
.ezra-msg-bubble.ezra-md h2,
.ezra-msg-bubble.ezra-md h3 {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  margin: 10px 0 4px 0;
  line-height: 1.3;
}
.ezra-msg-bubble.ezra-md h1 { font-size: 14px; }
.ezra-msg-bubble.ezra-md p { margin: 4px 0; }
.ezra-msg-bubble.ezra-md ul,
.ezra-msg-bubble.ezra-md ol {
  margin: 4px 0 4px 16px;
  padding: 0;
}
.ezra-msg-bubble.ezra-md li { margin: 2px 0; }
.ezra-msg-bubble.ezra-md strong { font-weight: 700; color: #0f172a; }
.ezra-msg-bubble.ezra-md em { font-style: italic; }
.ezra-msg-bubble.ezra-md hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 8px 0;
}
.ezra-msg-bubble.ezra-md blockquote {
  border-left: 3px solid #f59e0b;
  margin: 6px 0;
  padding: 4px 10px;
  background: #fffbeb;
  border-radius: 0 6px 6px 0;
  font-style: italic;
  color: #78350f;
}
.ezra-msg-bubble.ezra-md table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 12px;
}
.ezra-msg-bubble.ezra-md th,
.ezra-msg-bubble.ezra-md td {
  border: 1px solid #e2e8f0;
  padding: 5px 8px;
  text-align: left;
}
.ezra-msg-bubble.ezra-md th {
  background: #f1f5f9;
  font-weight: 700;
}
.ezra-msg-bubble.ezra-md code {
  background: #f1f5f9;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
  font-family: monospace;
}
.ezra-msg-bubble.ezra-md > *:first-child { margin-top: 0; }
.ezra-msg-bubble.ezra-md > *:last-child { margin-bottom: 0; }

.ezra-chat-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: sans-serif;
  align-self: flex-start;
  max-width: 86%;
}

@media (max-width: 480px) {
  .ezra-chat-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 80px;
  }
  .ezra-chat-btn { right: 16px; bottom: 16px; }
}
