/* ── Bithart Advisors — Dual Twin Widget ─────────────────────────────────── */
/* Brand: #0D0C0B ink · #B8963E gold · #F5EDD8 pale · #1E1C18 ink-2          */

:root {
  --bh-ink:    #0D0C0B;
  --bh-ink2:   #1E1C18;
  --bh-gold:   #B8963E;
  --bh-pale:   #F5EDD8;
  --bh-muted:  rgba(212,175,106,0.45);
  --bh-border: rgba(184,150,62,0.18);
  --bh-radius: 14px;
  --bh-shadow: 0 8px 48px rgba(0,0,0,0.6), 0 2px 12px rgba(0,0,0,0.4);
}

/* ── Trigger button ──────────────────────────────────────────────────────── */
.bh-trigger {
  position: fixed;
  right: 24px;
  width: 88px;
  height: 88px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 9997;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bh-breathe 3.5s ease-in-out infinite;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}

.bh-trigger:hover {
  transform: scale(1.08);
  animation-play-state: paused;
}

.bh-trigger:hover .bh-ring-svg {
  filter: drop-shadow(0 0 10px rgba(184,150,62,0.5));
}

@keyframes bh-breathe {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.04); }
}

/* ── Ring ────────────────────────────────────────────────────────────────── */
.bh-ring-svg {
  position: absolute;
  inset: 0;
  width: 88px;
  height: 88px;
  transition: filter 0.3s ease;
  will-change: transform;
}

/* ── Portrait (trigger) ─────────────────────────────────────────────────── */
.bh-portrait {
  position: relative;
  z-index: 1;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bh-ink2);
  border: 1.5px solid rgba(184,150,62,0.55);
  box-shadow: 0 0 0 4px rgba(184,150,62,0.07);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bh-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  border-radius: 50%;
  display: block;
}

/* ── Panel ───────────────────────────────────────────────────────────────── */
.bh-panel {
  position: fixed;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 580px;
  background: var(--bh-ink2);
  border: 1px solid var(--bh-border);
  border-radius: var(--bh-radius);
  box-shadow: var(--bh-shadow);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.22s ease;
}

.bh-panel.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.bh-header {
  background: var(--bh-ink);
  padding: 20px 20px 18px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-shrink: 0;
  position: relative;
}

.bh-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 20px; right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(184,150,62,0.25) 30%, rgba(184,150,62,0.25) 70%, transparent);
}

/* Portrait in header */
.bh-header-portrait {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bh-ink2);
  border: 1.5px solid rgba(184,150,62,0.45);
  box-shadow: 0 0 0 4px rgba(184,150,62,0.06);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.bh-header-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  border-radius: 50%;
  display: block;
}

.bh-header-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bh-header-since {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 9px;
  font-weight: 500;
  color: rgba(184,150,62,0.4);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.bh-header-name {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--bh-pale);
  margin: 0;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.bh-header-title {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 10px;
  font-weight: 500;
  color: var(--bh-gold);
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.bh-header-sub {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 10px;
  color: rgba(212,175,106,0.3);
  margin: 4px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.bh-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  animation: bh-pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes bh-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

.bh-close {
  background: rgba(184,150,62,0.08);
  border: 1px solid var(--bh-border);
  color: var(--bh-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
  margin-top: 2px;
}

.bh-close:hover {
  background: rgba(184,150,62,0.2);
  color: var(--bh-pale);
}

/* ── Messages ────────────────────────────────────────────────────────────── */
.bh-messages {
  flex: 1;
  overflow-y: scroll;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background: var(--bh-ink2);
}

.bh-messages::-webkit-scrollbar { width: 3px; }
.bh-messages::-webkit-scrollbar-track { background: transparent; }
.bh-messages::-webkit-scrollbar-thumb { background: var(--bh-border); border-radius: 4px; }

.bh-msg { display: flex; align-items: flex-end; gap: 8px; }
.bh-msg--agent { flex-direction: row; }
.bh-msg--user  { flex-direction: row-reverse; }

.bh-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bh-ink);
  border: 1px solid var(--bh-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bh-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  border-radius: 50%;
  display: block;
}

.bh-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
}

.bh-msg--agent .bh-bubble {
  background: rgba(184,150,62,0.07);
  color: var(--bh-pale);
  border: 1px solid var(--bh-border);
  border-radius: 12px 12px 12px 4px;
}

.bh-msg--user .bh-bubble {
  background: var(--bh-gold);
  color: var(--bh-ink);
  border-radius: 12px 12px 4px 12px;
  font-weight: 500;
}

/* ── Typing indicator ────────────────────────────────────────────────────── */
.bh-typing { display: flex; gap: 4px; padding: 4px 0; }

.bh-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bh-gold);
  opacity: 0.4;
  animation: bh-dot 1.3s ease-in-out infinite;
}

.bh-typing span:nth-child(2) { animation-delay: 0.15s; }
.bh-typing span:nth-child(3) { animation-delay: 0.30s; }

@keyframes bh-dot {
  0%, 80%, 100% { transform: translateY(0);   opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1;   }
}

/* ── Quick action chips ──────────────────────────────────────────────────── */
.bh-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  background: var(--bh-ink2);
}

.bh-chips[hidden] { display: none; }

.bh-chip {
  background: transparent;
  border: 1px solid var(--bh-border);
  color: var(--bh-muted);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 100px;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  white-space: nowrap;
}

.bh-chip:hover {
  border-color: var(--bh-gold);
  background: rgba(184,150,62,0.1);
  color: var(--bh-pale);
}

/* ── Input area ──────────────────────────────────────────────────────────── */
.bh-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--bh-border);
  background: var(--bh-ink);
  flex-shrink: 0;
}

.bh-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--bh-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 13px;
  color: var(--bh-pale);
  background: var(--bh-ink2);
  outline: none;
  min-height: 40px;
  max-height: 96px;
  line-height: 1.4;
  transition: border-color 0.2s;
}

.bh-input:focus { border-color: rgba(184,150,62,0.45); }
.bh-input::placeholder { color: rgba(212,175,106,0.22); }

.bh-send {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--bh-gold);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.bh-send:hover  { background: #D4AF6A; }
.bh-send:active { transform: scale(0.93); }
.bh-send:disabled { opacity: 0.35; cursor: not-allowed; }
.bh-send svg { width: 16px; height: 16px; fill: var(--bh-ink); }

/* ── Branding ────────────────────────────────────────────────────────────── */
.bh-branding {
  text-align: center;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 10px;
  color: rgba(184,150,62,0.22);
  padding: 6px 16px 10px;
  flex-shrink: 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--bh-ink);
}

.bh-branding a { color: var(--bh-gold); text-decoration: none; }

/* ── Cursor (typewriter) ─────────────────────────────────────────────────── */
.bh-cursor::after {
  content: '|';
  animation: bh-blink 0.8s step-end infinite;
  color: var(--bh-gold);
  margin-left: 1px;
}

@keyframes bh-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .bh-panel {
    bottom: auto !important;
    top: max(56px, env(safe-area-inset-top, 0px) + 56px);
    right: 12px;
    width: calc(100vw - 24px);
    max-height: calc(100svh - max(56px, env(safe-area-inset-top, 0px) + 56px) - 8px);
  }
  .bh-trigger { right: 16px; }
}

/* ── Landscape (short viewport) ─────────────────────────────────────────── */
@media (max-height: 500px) {
  .bh-panel {
    top: 8px !important;
    max-height: calc(100svh - 16px);
  }
  .bh-trigger { width: 72px; height: 72px; }
  .bh-ring-svg { width: 72px; height: 72px; }
  .bh-portrait { width: 58px; height: 58px; }
}
