/* ============================================
   AI Chat Widget Styles
   Modern, responsive chat dialog for BPC
   ============================================ */

/* ── CSS VARIABLES ── */
.bpc-chat-root {
  --bpc-primary: rgb(8, 92, 177);
  --bpc-primary-dk: rgb(5, 68, 133);
  --bpc-primary-lt: rgb(232, 241, 254);
  --bpc-accent: #f0a500;
  --bpc-white: #ffffff;
  --bpc-offwhite: #f6f7f5;
  --bpc-border: #ccd8ee;
  --bpc-text: #0d1a2e;
  --bpc-muted: #4a5d7a;
  --bpc-shadow: 0 4px 24px rgba(0,0,0,.12);
  --bpc-radius: 6px;
}

/* ── FAB BUTTON ── */
.bpc-fab {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 56px; height: 56px;
  background: var(--bpc-primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 16px rgba(8,92,177,.45);
  border: none;
  z-index: 9999;
  transition: background .18s, transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .18s;
}
.bpc-fab:hover { background: var(--bpc-primary-dk); transform: scale(1.07); box-shadow: 0 6px 22px rgba(5,68,133,.5); }
.bpc-fab.open .fab-icon-open { opacity: 0; transform: rotate(90deg) scale(.55); }
.bpc-fab.open .fab-icon-close { opacity: 1; transform: rotate(0) scale(1); }
.fab-icon-open, .fab-icon-close {
  position: absolute; font-size: 22px; color: #fff;
  transition: all .26s cubic-bezier(.34,1.56,.64,1);
}
.fab-icon-close { opacity: 0; transform: rotate(-90deg) scale(.55); font-size: 17px; }
.bpc-fab::after {
  content: ''; position: absolute; width: 100%; height: 100%;
  border-radius: 50%; border: 2px solid rgba(8,92,177,.3);
  animation: fab-ring 2.5s infinite;
}
@keyframes fab-ring { 0%{transform:scale(1);opacity:1} 70%{transform:scale(1.7);opacity:0} 100%{transform:scale(1.7);opacity:0} }

/* ── CHAT WINDOW ── */
.bpc-chat-window {
  position: fixed;
  bottom: 92px; right: 24px;
  width: 380px; height: 520px;
  min-height: 480px;
  background: var(--bpc-white);
  border: 1px solid var(--bpc-border);
  border-radius: var(--bpc-radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.16);
  display: flex; flex-direction: column;
  z-index: 9998; overflow: hidden;
  transform-origin: bottom right;
  transform: scale(.92);
  opacity: 0; pointer-events: none;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
}
.bpc-chat-window.open {
  transform: scale(1);
  opacity: 1; pointer-events: all;
}

/* Header */
.bpc-chat-header { background: var(--bpc-primary); flex-shrink: 0; }
.bpc-chat-header-top {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
}
.bpc-ch-avatar {
  width: 38px; height: 38px;
  /* background: rgba(255,255,255,.15); */
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  border: 2px solid rgba(255,255,255,.25);
  flex-shrink: 0;
}
.bpc-ch-info { flex: 1; }
.bpc-ch-info h3 { color: #fff; font-size: .88rem; font-weight: 700; line-height: 1.2; margin: 0; }
.bpc-ch-info .bpc-ch-sub {
  display: flex; align-items: center; gap: 5px;
  font-size: .67rem; color: rgba(255,255,255,.72); margin-top: 2px;
}
.bpc-dot-online {
  width: 6px; height: 6px; background: #7ddf96;
  border-radius: 50%; animation: blink 2s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.35} }
.bpc-ch-close {
  background: rgba(255,255,255,.15); border: none;
  color: rgba(255,255,255,.85); width: 28px; height: 28px;
  border-radius: 50%; cursor: pointer; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background .17s;
}
.bpc-ch-close:hover { background: rgba(255,255,255,.28); color: #fff; }

.bpc-ch-branding {
  background: var(--bpc-primary-dk);
  padding: 4px 14px;
  font-size: .62rem; color: rgba(255,255,255,.6);
  letter-spacing: .05em; text-transform: uppercase; font-weight: 600;
}

/* Messages */
.bpc-messages {
  flex: 1; overflow-y: auto;
  padding: 12px 11px;
  display: flex; flex-direction: column; gap: 10px;
  background: #f0f4fb;
  scroll-behavior: smooth;
}
.bpc-messages::-webkit-scrollbar { width: 3px; }
.bpc-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,.1); border-radius: 2px; }

.bpc-msg-row { display: flex; gap: 7px; align-items: flex-end; }
.bpc-msg-row.user { flex-direction: row-reverse; }

.bpc-msg-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; flex-shrink: 0;
}
.bpc-msg-avatar.ai { background: var(--bpc-primary); }
.bpc-msg-avatar.user-av { background: var(--bpc-muted); }
.bpc-msg-avatar.system { background: var(--bpc-accent); }

.bpc-bubble {
  max-width: 80%; padding: 9px 12px;
  font-size: .82rem; line-height: 1.58;
  animation: pop-in .2s cubic-bezier(.34,1.56,.64,1);
  font-family: 'Noto Sans', sans-serif;
}
.bpc-bubble.system {
  background: #fff8e1; color: #5d4200;
  border-radius: 8px;
  border: 1px solid #ffe082;
  font-size: .75rem;
}
@keyframes pop-in { from{transform:scale(.7) translateY(8px);opacity:0} to{transform:scale(1) translateY(0);opacity:1} }

.bpc-bubble.ai {
  background: var(--bpc-white); color: var(--bpc-text);
  border-radius: 0 8px 8px 8px;
  border: 1px solid var(--bpc-border);
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.bpc-bubble.user {
  background: var(--bpc-primary); color: #fff;
  border-radius: 8px 0 8px 8px;
}

.bpc-quick-replies { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.bpc-qr {
  background: var(--bpc-primary-lt);
  border: 1px solid rgba(8,92,177,.2);
  border-radius: 3px; padding: 4px 10px;
  font-size: .71rem; font-weight: 600; color: var(--bpc-primary);
  cursor: pointer; transition: all .15s;
  font-family: 'Noto Sans', sans-serif;
}
.bpc-qr:hover { background: var(--bpc-primary); color: #fff; border-color: var(--bpc-primary); }

/* Typing */
.bpc-typing-row { display: flex; align-items: flex-end; gap: 7px; }
.bpc-typing-bubble {
  background: var(--bpc-white); border: 1px solid var(--bpc-border);
  border-radius: 0 8px 8px 8px;
  padding: 10px 13px; display: flex; gap: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.bpc-dot { width: 6px; height: 6px; background: #bbb; border-radius: 50%; animation: bounce .72s infinite; }
.bpc-dot:nth-child(2){animation-delay:.13s} .bpc-dot:nth-child(3){animation-delay:.26s}
@keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }
.bpc-typing-cursor { display: inline-block; color: var(--bpc-primary); animation: cursor-blink .52s steps(1) infinite; font-weight: 300; margin-left: 1px; }
@keyframes cursor-blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* Input */
.bpc-chat-input-area {
  padding: 9px 10px; background: var(--bpc-white);
  border-top: 1px solid var(--bpc-border);
  display: flex; gap: 7px; align-items: flex-end; flex-shrink: 0;
}
.bpc-chat-input {
  flex: 1; border: 1px solid var(--bpc-border); border-radius: var(--bpc-radius);
  padding: 8px 11px; font-size: .81rem;
  font-family: 'Noto Sans', sans-serif;
  resize: none; outline: none; max-height: 86px; min-height: 38px;
  background: var(--bpc-offwhite); color: var(--bpc-text);
  transition: border-color .17s; line-height: 1.45;
}
.bpc-chat-input:focus { border-color: var(--bpc-primary); background: #fff; }
.bpc-chat-input::placeholder { color: #aaa; }

.bpc-send-btn {
  width: 38px; height: 38px; background: var(--bpc-primary);
  border: none; border-radius: var(--bpc-radius); color: #fff;
  font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .17s, transform .12s; flex-shrink: 0;
}
.bpc-send-btn:hover { background: var(--bpc-primary-dk); transform: scale(1.04); }
.bpc-send-btn:disabled { background: #ccc; cursor: not-allowed; transform: none; }

/* Human Chat Button */
.bpc-human-chat-btn {
  width: 38px; height: 38px; background: var(--bpc-accent);
  border: none; border-radius: var(--bpc-radius); color: #fff;
  font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .17s, transform .12s; flex-shrink: 0;
}
.bpc-human-chat-btn:hover { background: #d49400; transform: scale(1.04); }

.bpc-chat-footer {
  background: var(--bpc-offwhite); border-top: 1px solid var(--bpc-border);
  text-align: center; font-size: .63rem; color: var(--bpc-muted);
  padding: 5px 8px; flex-shrink: 0; line-height: 1.5;
}
.bpc-chat-footer a { color: var(--bpc-primary); text-decoration: none; }

@media (max-width: 420px) {
  .bpc-chat-window { right: 8px; bottom: 82px; width: calc(100vw - 16px); }
  .bpc-fab { right: 14px; bottom: 14px; }
}
