/* =============================================================================
   DealFlow AI — Widget Styles
   Scoped under .dealflow-widget to prevent any conflicts with the host theme.
   CSS variables are injected inline by the React widget from dealflow_config.
   ============================================================================= */

/* ── Reset ─────────────────────────────────────────────────────────────────── */
.dealflow-widget *,
.dealflow-widget *::before,
.dealflow-widget *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── CSS Variables (defaults overridden inline by React) ──────────────────── */
.dealflow-widget {
  --df-primary:      #4F46E5;
  --df-primary-dark: #3730a3;
  --df-bg:           #ffffff;
  --df-bg-muted:     #f8fafc;
  --df-text:         #1e293b;
  --df-text-muted:   #64748b;
  --df-border:       #e2e8f0;
  --df-shadow:       0 8px 32px rgba(0, 0, 0, 0.14);
  --df-radius:       16px;
  --df-radius-sm:    10px;
  --df-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483647;
  font-family: var(--df-font);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Launcher Button ──────────────────────────────────────────────────────── */
.df-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--df-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.df-launcher:hover {
  background: var(--df-primary-dark);
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
}

.df-launcher:active {
  transform: scale(0.96);
}

.df-launcher--open {
  background: var(--df-primary-dark);
}

/* ── Chat Panel ───────────────────────────────────────────────────────────── */
.df-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: var(--df-bg);
  border: 1px solid var(--df-border);
  border-radius: var(--df-radius);
  box-shadow: var(--df-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: df-slide-in 0.22s ease;
}

@keyframes df-slide-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Panel Header ─────────────────────────────────────────────────────────── */
.df-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--df-primary);
  flex-shrink: 0;
}

.df-panel__header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.df-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.df-panel__bot-name {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.df-panel__status {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 11px;
}

.df-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}

.df-status-dot--admin {
  background: #f59e0b;
  animation: df-pulse 2s infinite;
}

@keyframes df-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.df-panel__close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: rgba(255, 255, 255, 0.85);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.df-panel__close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* ── Messages Scroll Area ─────────────────────────────────────────────────── */
.df-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--df-bg-muted);
  scroll-behavior: smooth;
}

.df-messages::-webkit-scrollbar {
  width: 4px;
}
.df-messages::-webkit-scrollbar-track {
  background: transparent;
}
.df-messages::-webkit-scrollbar-thumb {
  background: var(--df-border);
  border-radius: 99px;
}

/* ── Individual Message ───────────────────────────────────────────────────── */
.df-message {
  display: flex;
  max-width: 85%;
}

.df-message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.df-message--bot {
  align-self: flex-start;
}

.df-message--admin {
  align-self: flex-start;
}

.df-message__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--df-primary);
  margin-bottom: 2px;
  margin-left: 4px;
}

.df-bubble {
  padding: 10px 14px;
  border-radius: var(--df-radius-sm);
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.df-message--user .df-bubble {
  background: var(--df-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.df-message--bot .df-bubble {
  background: #fff;
  color: var(--df-text);
  border: 1px solid var(--df-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.df-message--admin .df-bubble {
  background: #16a34a;
  color: #fff;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

/* ── Typing Indicator ─────────────────────────────────────────────────────── */
.df-message--typing .df-bubble {
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.df-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--df-text-muted);
  display: inline-block;
  animation: df-bounce 1.2s ease-in-out infinite;
}

.df-dot:nth-child(2) { animation-delay: 0.2s; }
.df-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes df-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Input Area ───────────────────────────────────────────────────────────── */
.df-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: var(--df-bg);
  border-top: 1px solid var(--df-border);
  flex-shrink: 0;
}

.df-input {
  flex: 1;
  border: 1px solid var(--df-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: var(--df-font);
  font-size: 13.5px;
  color: var(--df-text);
  background: var(--df-bg-muted);
  resize: none;
  outline: none;
  line-height: 1.4;
  max-height: 96px;
  overflow-y: auto;
  transition: border-color 0.15s;
}

.df-input:focus {
  border-color: var(--df-primary);
  background: #fff;
}

.df-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.df-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--df-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.df-send-btn:hover:not(:disabled) {
  background: var(--df-primary-dark);
  transform: scale(1.05);
}

.df-send-btn:disabled {
  background: var(--df-border);
  cursor: not-allowed;
}

/* ── Panel Footer ─────────────────────────────────────────────────────────── */
.df-panel__footer {
  text-align: center;
  font-size: 10px;
  color: var(--df-text-muted);
  padding: 6px 12px;
  background: var(--df-bg);
  border-top: 1px solid var(--df-border);
  flex-shrink: 0;
}

/* ── Teaser Banner ────────────────────────────────────────────────────────── */
.df-teaser {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 260px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: df-teaser-in 0.3s ease;
}
@keyframes df-teaser-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.df-teaser__close {
  position: absolute;
  top: 6px; right: 8px;
  background: none; border: none;
  font-size: 16px; cursor: pointer; color: #94a3b8;
  line-height: 1; padding: 2px 4px;
}
.df-teaser__close:hover { color: #475569; }
.df-teaser__text {
  font-size: 13px; color: #1e293b; padding-right: 16px; line-height: 1.4;
}
.df-teaser__cta {
  background: var(--df-primary);
  color: #fff; border: none; border-radius: 8px;
  padding: 7px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; text-align: center;
}
.df-teaser__cta:hover { filter: brightness(1.1); }

/* ── Lead Capture Form ────────────────────────────────────────────────────── */
.df-lead-capture {
  background: #fff;
  border: 1px solid var(--df-border);
  border-radius: var(--df-radius-sm);
  padding: 14px;
  margin: 8px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  animation: df-slide-in 0.25s ease;
}

.df-lead-capture__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--df-text);
}

.df-lead-capture__close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--df-text-muted);
  padding: 0 4px;
  line-height: 1;
}

.df-lead-capture__close:hover {
  color: var(--df-text);
}

.df-lead-capture__fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.df-lead-capture__input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--df-border);
  border-radius: 8px;
  font-family: var(--df-font);
  font-size: 13px;
  color: var(--df-text);
  background: var(--df-bg-muted);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.df-lead-capture__input:focus {
  border-color: var(--df-primary);
  background: #fff;
}

.df-lead-capture__submit {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-family: var(--df-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.df-lead-capture__submit:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.df-lead-capture__submit:active {
  transform: translateY(0);
}

/* ── Mobile Responsiveness ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .dealflow-widget {
    bottom: 16px;
    right: 16px;
  }

  .df-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    right: -16px;
    bottom: 64px;
    border-radius: 16px 16px 0 0;
  }
}
