/* ── Estate A.I Chat Widget ── */

/* Floating button */
.ea-btn {
  position: fixed;
  bottom: var(--ea-bottom, 24px);
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #161b22;
  border: 2px solid #d4a843;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  box-shadow: 0 4px 20px rgba(212, 168, 67, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
  overflow: visible;
}

.ea-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(212, 168, 67, 0.38);
}

.ea-btn img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  z-index: 1;
}

/* Pulse ring */
@keyframes ea-pulse-ring {
  0%   { transform: scale(1); opacity: 0.55; }
  100% { transform: scale(1.7); opacity: 0; }
}

.ea-pulse-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid #d4a843;
  animation: ea-pulse-ring 2.2s ease-out infinite;
  pointer-events: none;
}

/* Unread badge */
.ea-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 10px;
  background: #d4a843;
  color: #0d1117;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  border: 2px solid #0d1117;
  z-index: 2;
}

/* Slide-up animation */
@keyframes ea-slide-up {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Chat window */
.ea-window {
  position: fixed;
  bottom: calc(var(--ea-bottom, 24px) + 70px);
  right: 24px;
  width: 360px;
  height: 500px;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 16px;
  z-index: 9001;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(212, 168, 67, 0.07);
  animation: ea-slide-up 0.22s ease;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
}

.ea-window.ea-hidden {
  display: none;
}

/* ── Header ── */
.ea-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #21262d;
  flex-shrink: 0;
  background: #161b22;
}

.ea-header-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #d4a843;
  flex-shrink: 0;
}

.ea-header-info { flex: 1; overflow: hidden; }

.ea-header-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.ea-header-status {
  font-size: 11px;
  color: #3fb950;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

.ea-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3fb950;
  flex-shrink: 0;
}

.ea-header-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.ea-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.4);
  transition: background 0.15s ease, color 0.15s ease;
  padding: 0;
}

.ea-icon-btn:hover {
  background: #21262d;
  color: rgba(255, 255, 255, 0.87);
}

/* ── Messages ── */
.ea-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.ea-messages::-webkit-scrollbar { width: 4px; }
.ea-messages::-webkit-scrollbar-track { background: transparent; }
.ea-messages::-webkit-scrollbar-thumb { background: #21262d; border-radius: 2px; }
.ea-messages::-webkit-scrollbar-thumb:hover { background: #30363d; }

/* ── Message row ── */
.ea-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: ea-slide-up 0.18s ease;
}

.ea-msg-ai   { align-self: flex-start; }
.ea-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.ea-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #d4a843;
  flex-shrink: 0;
  margin-top: 2px;
}

.ea-bubble {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.52;
  word-break: break-word;
}

.ea-msg-ai .ea-bubble {
  background: #161b22;
  border: 1px solid #21262d;
  color: rgba(255, 255, 255, 0.85);
  border-radius: 4px 12px 12px 12px;
}

.ea-msg-user .ea-bubble {
  background: linear-gradient(135deg, #d4a843, #c09338);
  color: #0d1117;
  font-weight: 500;
  border-radius: 12px 4px 12px 12px;
}

/* ── Suggestion chips ── */
.ea-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.ea-chip {
  padding: 5px 11px;
  background: transparent;
  border: 1px solid #30363d;
  border-radius: 20px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.ea-chip:hover {
  border-color: #d4a843;
  color: #d4a843;
  background: rgba(212, 168, 67, 0.07);
}

/* ── Loading dots ── */
@keyframes ea-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

.ea-thinking {
  align-self: flex-start;
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 4px 12px 12px 12px;
  padding: 11px 14px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.ea-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d4a843;
  animation: ea-dot-bounce 1.2s ease-in-out infinite;
}

.ea-dot:nth-child(2) { animation-delay: 0.16s; }
.ea-dot:nth-child(3) { animation-delay: 0.32s; }

/* ── Input area ── */
.ea-input-area {
  padding: 10px 12px;
  border-top: 1px solid #21262d;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #0d1117;
}

.ea-input {
  flex: 1;
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.87);
  font-family: 'Inter', sans-serif;
  outline: none;
  resize: none;
  max-height: 80px;
  min-height: 36px;
  line-height: 1.45;
  transition: border-color 0.15s;
  overflow-y: auto;
}

.ea-input:focus { border-color: rgba(212, 168, 67, 0.55); }

.ea-input::placeholder { color: rgba(255, 255, 255, 0.22); }

.ea-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #d4a843;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0d1117;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.ea-send-btn:hover   { background: #e0b84e; transform: scale(1.06); }
.ea-send-btn:active  { transform: scale(0.96); }

.ea-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* ── Error state ── */
.ea-error {
  font-size: 12px;
  color: rgba(248, 113, 113, 0.9);
  background: rgba(220, 38, 38, 0.07);
  border: 1px solid rgba(220, 38, 38, 0.18);
  border-radius: 8px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: stretch;
}

.ea-retry-btn {
  background: transparent;
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: 4px;
  color: rgba(248, 113, 113, 0.9);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

.ea-retry-btn:hover { background: rgba(220, 38, 38, 0.1); }

/* ── Mobile responsive ── */
@media (max-width: 480px) {
  .ea-btn   { right: 16px; }

  .ea-window {
    right: 16px;
    left: 16px;
    width: auto;
    height: 480px;
    bottom: calc(var(--ea-bottom, 24px) + 70px);
  }
}
