/* ============================================================
   Radius Security – Website Chatbot Widget
   ============================================================
   Colour placeholders below (--rsc-primary / --rsc-primary-dark)
   are a dark navy guess appropriate to a security brand — pull
   the real hex values from Divi Theme Customizer > Global Colors
   before this goes live, and swap them in here.
   ============================================================ */

:root {
  --rsc-primary:       #0b2545;   /* placeholder — confirm against Divi brand colour */
  --rsc-primary-dark:  #071a33;
  --rsc-accent:        #eef2f7;
  --rsc-bot-bg:        #f1f4f8;
  --rsc-user-bg:       #0b2545;
  --rsc-user-text:     #ffffff;
  --rsc-radius:        16px;
  --rsc-shadow:        0 8px 32px rgba(0,0,0,.18);
  --rsc-font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --rsc-widget-z:      9999;
  --rsc-panel-w:       380px;
  --rsc-panel-h:       560px;
}

/* ── Widget wrapper ───────────────────────────────────────── */
#rsc-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--rsc-widget-z);
  font-family: var(--rsc-font);
  font-size: 15px;
  line-height: 1.5;
}

/* ── Toggle button ───────────────────────────────────────── */
#rsc-chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--rsc-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 16px rgba(11,37,69,.45);
  transition: background .2s, transform .2s;
  position: relative;
  z-index: 1;
}
#rsc-chat-toggle:hover  { background: var(--rsc-primary-dark); transform: scale(1.07); }
#rsc-chat-toggle:focus-visible { outline: 3px solid #ffbf47; outline-offset: 3px; }
#rsc-chat-toggle svg    { width: 26px; height: 26px; }

/* icon swap */
#rsc-chat-toggle .rsc-icon-close { display: none; }
#rsc-chat-widget.rsc-open #rsc-chat-toggle .rsc-icon-open  { display: none; }
#rsc-chat-widget.rsc-open #rsc-chat-toggle .rsc-icon-close { display: flex; }

/* unread dot (optional, toggled via JS) */
#rsc-chat-toggle::after {
  content: '';
  position: absolute;
  top: 6px; right: 6px;
  width: 10px; height: 10px;
  background: #e84118;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}
#rsc-chat-widget.rsc-has-unread #rsc-chat-toggle::after { display: block; }

/* ── Panel ───────────────────────────────────────────────── */
#rsc-chat-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: var(--rsc-panel-w);
  height: var(--rsc-panel-h);
  background: #fff;
  border-radius: var(--rsc-radius);
  box-shadow: var(--rsc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rsc-slide-up .25s ease;
}
#rsc-chat-panel[hidden] { display: none; }

@keyframes rsc-slide-up {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* ── Header ──────────────────────────────────────────────── */
#rsc-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--rsc-primary);
  color: #fff;
  flex-shrink: 0;
}
.rsc-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rsc-chat-avatar {
  width: 38px; height: 38px;
  background: rgba(255,255,255,.22);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.rsc-chat-title    { font-weight: 700; font-size: 15px; line-height: 1.2; }
.rsc-chat-subtitle { font-size: 11px; opacity: .8; margin-top: 1px; }

#rsc-chat-close {
  background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; padding: 4px 6px;
  border-radius: 6px; line-height: 1;
  transition: background .15s;
}
#rsc-chat-close:hover { background: rgba(255,255,255,.15); }
#rsc-chat-close:focus-visible { outline: 2px solid #ffbf47; }

/* ── Info bar ────────────────────────────────────────────── */
#rsc-chat-disclaimer {
  background: var(--rsc-accent);
  color: #374151;
  font-size: 11.5px;
  padding: 7px 14px;
  display: flex;
  align-items: center;
  gap: 5px;
  border-bottom: 1px solid #dde4ee;
  flex-shrink: 0;
}

/* ── Messages ────────────────────────────────────────────── */
#rsc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#rsc-chat-messages::-webkit-scrollbar { width: 5px; }
#rsc-chat-messages::-webkit-scrollbar-track { background: transparent; }
#rsc-chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 99px; }

.rsc-msg {
  display: flex;
  max-width: 88%;
}
.rsc-msg--bot  { align-self: flex-start; }
.rsc-msg--user { align-self: flex-end; flex-direction: row-reverse; }

.rsc-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.rsc-msg--bot  .rsc-bubble { background: var(--rsc-bot-bg); color: #1f2937; border-bottom-left-radius: 4px; }
.rsc-msg--user .rsc-bubble { background: var(--rsc-user-bg); color: var(--rsc-user-text); border-bottom-right-radius: 4px; }

/* Typing indicator */
.rsc-msg--typing .rsc-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}
.rsc-msg--typing .rsc-bubble span {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: rsc-bounce 1.2s infinite;
}
.rsc-msg--typing .rsc-bubble span:nth-child(2) { animation-delay: .2s; }
.rsc-msg--typing .rsc-bubble span:nth-child(3) { animation-delay: .4s; }

@keyframes rsc-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* ── Input area ──────────────────────────────────────────── */
#rsc-chat-input-area {
  border-top: 1px solid #e5e7eb;
  padding: 10px 12px 8px;
  flex-shrink: 0;
  background: #fff;
}
#rsc-chat-typing-hint {
  font-size: 11.5px;
  color: #9ca3af;
  margin-bottom: 6px;
  padding: 0 2px;
}
#rsc-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f3f4f6;
  border-radius: 24px;
  padding: 6px 6px 6px 14px;
  border: 1.5px solid transparent;
  transition: border-color .2s;
}
#rsc-chat-form:focus-within {
  border-color: var(--rsc-primary);
  background: #fff;
}
#rsc-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: var(--rsc-font);
  font-size: 14px;
  line-height: 1.5;
  color: #1f2937;
  min-height: 22px;
  max-height: 120px;
  outline: none;
  overflow-y: auto;
}
#rsc-chat-input::placeholder { color: #9ca3af; }
#rsc-chat-input:disabled { opacity: .5; cursor: not-allowed; }

#rsc-chat-send {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--rsc-primary);
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .2s, opacity .2s;
}
#rsc-chat-send svg { width: 18px; height: 18px; }
#rsc-chat-send:hover:not(:disabled) { background: var(--rsc-primary-dark); }
#rsc-chat-send:disabled { opacity: .4; cursor: not-allowed; }
#rsc-chat-send:focus-visible { outline: 2px solid #ffbf47; outline-offset: 2px; }

#rsc-chat-footer-note {
  font-size: 10.5px;
  color: #9ca3af;
  text-align: center;
  margin-top: 6px;
}
#rsc-chat-footer-note a { color: #9ca3af; }

/* Disabled / config-error state */
#rsc-chat-widget.rsc-disabled #rsc-chat-toggle { opacity: .5; cursor: not-allowed; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
  #rsc-chat-widget { bottom: 16px; right: 16px; left: 16px; }
  #rsc-chat-panel  {
    width: auto;
    left: 0; right: 0;
    bottom: 72px;
    height: calc(100dvh - 110px);
    border-radius: 16px;
  }
}
