/* =============================================================
   RGB SKYLINE — ERP SUPPORT CHATBOT WIDGET
   ============================================================= */

.rgb-chat{
  --chat-w: 384px;
  --chat-h: 560px;
  --chat-launcher: 58px;
  /* Gap, bottom and size must match .rgb-whatsapp-btn */
  --chat-gap: 24px;
  --chat-bottom: 24px;
  --chat-whatsapp: 58px;
  --chat-pair-gap: 14px;
  --chat-panel-bottom: calc(var(--chat-bottom) + var(--chat-launcher) + 12px);
}

/* ================= LAUNCHER ================= */
.rgb-chat-launcher{
  position: fixed;
  z-index: 1045;
  bottom: var(--chat-bottom);
  inset-inline-start: calc(var(--chat-gap) + var(--chat-whatsapp) + var(--chat-pair-gap));
  width: var(--chat-launcher);
  height: var(--chat-launcher);
  border: none;
  border-radius: 50%;
  background: var(--grad-primary);
  color: #fff;
  font-size: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 34px -10px rgba(25, 118, 210, .75);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), opacity .2s var(--ease);
}
.rgb-chat-launcher:hover{ transform: scale(1.07); box-shadow: 0 18px 40px -10px rgba(25, 118, 210, .85); }
.rgb-chat-launcher:active{ transform: scale(.98); }

/* Attention ring until first open */
.rgb-chat-launcher::after{
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--b-400);
  opacity: 0;
  animation: rgb-chat-ring 2.8s var(--ease) infinite;
}
.rgb-chat.is-used .rgb-chat-launcher::after{ animation: none; content: none; }

@keyframes rgb-chat-ring{
  0%   { transform: scale(1);    opacity: .55; }
  70%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

.rgb-chat.is-open .rgb-chat-launcher{
  opacity: 0;
  visibility: hidden;
  transform: scale(.7);
  pointer-events: none;
}

/* ================= PANEL SHELL ================= */
.rgb-chat-panel{
  position: fixed;
  z-index: 1045;
  bottom: var(--chat-panel-bottom);
  inset-inline-start: var(--chat-gap);
  width: var(--chat-w);
  height: var(--chat-h);
  max-height: calc(100vh - var(--rgb-header-h) - var(--chat-panel-bottom) - 16px);
  max-height: calc(100dvh - var(--rgb-header-h) - var(--chat-panel-bottom) - 16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-blue);
  transform-origin: bottom var(--chat-origin-x, left);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(.96);
  transition: opacity .28s var(--ease), transform .28s var(--ease), visibility .28s;
}
html[dir="rtl"] .rgb-chat-panel{ --chat-origin-x: right; }

.rgb-chat.is-open .rgb-chat-panel{
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ================= HEADER ================= */
.rgb-chat-head{
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .85rem 1rem;
  background: var(--grad-primary);
  color: #fff;
  flex: 0 0 auto;
}

.rgb-chat-avatar{
  width: 38px; height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
}

.rgb-chat-head-text{ min-width: 0; flex: 1; }
.rgb-chat-title{
  font-family: var(--font-display);
  font-weight: 800;
  font-size: .98rem;
  line-height: 1.3;
  color: #fff;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rgb-chat-status{
  display: flex; align-items: center; gap: .35rem;
  font-size: .74rem;
  color: rgba(255,255,255,.85);
  line-height: 1.4;
}
.rgb-chat-status::before{
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  flex: 0 0 auto;
}

.rgb-chat-head-actions{ display: flex; gap: .25rem; flex: 0 0 auto; }
.rgb-chat-icon-btn{
  width: 32px; height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: .95rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .2s var(--ease);
}
.rgb-chat-icon-btn:hover{ background: rgba(255,255,255,.3); }

/* ================= MESSAGE LOG ================= */
.rgb-chat-log{
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .8rem;
  background: var(--bg-soft);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.rgb-chat-log::-webkit-scrollbar{ width: 6px; }
.rgb-chat-log::-webkit-scrollbar-thumb{ background: var(--border-strong); border-radius: 999px; }
.rgb-chat-log::-webkit-scrollbar-track{ background: transparent; }

.rgb-chat-msg{
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: rgb-chat-pop .28s var(--ease) both;
}
.rgb-chat-msg.is-bot{ align-self: flex-start; }
.rgb-chat-msg.is-user{ align-self: flex-end; align-items: flex-end; }

@keyframes rgb-chat-pop{
  from{ opacity: 0; transform: translateY(8px); }
  to  { opacity: 1; transform: translateY(0); }
}

.rgb-chat-bubble{
  padding: .7rem .95rem;
  border-radius: var(--radius-md);
  font-size: .9rem;
  line-height: 1.75;
  white-space: pre-line;
}
.rgb-chat-msg.is-bot .rgb-chat-bubble{
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-start-start-radius: 4px;
}
.rgb-chat-msg.is-user .rgb-chat-bubble{
  background: var(--grad-primary);
  color: #fff;
  border-start-end-radius: 4px;
  box-shadow: 0 10px 24px -12px rgba(25,118,210,.6);
}

.rgb-chat-meta{
  font-size: .68rem;
  color: var(--text-3);
  margin-top: .25rem;
  padding-inline: .35rem;
}

/* Question the answer was matched to, shown above a bot answer */
.rgb-chat-matched{
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .82rem;
  color: var(--b-300);
  margin-bottom: .3rem;
}

/* Action link under an answer (contact / WhatsApp) */
.rgb-chat-action{
  display: inline-flex; align-items: center; gap: .4rem;
  margin-top: .6rem;
  padding: .4rem .85rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(66,165,245,.08);
  color: var(--b-300);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .8rem;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.rgb-chat-action:hover{ background: rgba(66,165,245,.16); border-color: var(--b-400); color: var(--b-300); }

/* ================= CHIPS (suggested questions / topics) ================= */
.rgb-chat-chips{
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .55rem;
}
.rgb-chat-chip{
  display: inline-flex; align-items: center; gap: .35rem;
  max-width: 100%;
  padding: .38rem .8rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: .8rem;
  line-height: 1.5;
  text-align: start;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}
.rgb-chat-chip:hover{
  background: rgba(66,165,245,.1);
  border-color: var(--b-400);
  color: var(--text-1);
  transform: translateY(-1px);
}
.rgb-chat-chip i{ color: var(--b-400); font-size: .9rem; flex: 0 0 auto; }

/* ================= TYPING INDICATOR ================= */
.rgb-chat-typing{
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .75rem .95rem;
}
.rgb-chat-typing span{
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--b-300);
  opacity: .5;
  animation: rgb-chat-dot 1.1s var(--ease) infinite;
}
.rgb-chat-typing span:nth-child(2){ animation-delay: .16s; }
.rgb-chat-typing span:nth-child(3){ animation-delay: .32s; }

@keyframes rgb-chat-dot{
  0%, 60%, 100%{ transform: translateY(0);     opacity: .45; }
  30%          { transform: translateY(-4px);  opacity: 1; }
}

/* ================= QUICK QUESTIONS STRIP ================= */
.rgb-chat-quick{
  flex: 0 0 auto;
  padding: .6rem .9rem 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  max-height: 6.5rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.rgb-chat-quick::-webkit-scrollbar{ width: 6px; }
.rgb-chat-quick::-webkit-scrollbar-thumb{ background: var(--border-strong); border-radius: 999px; }
.rgb-chat-quick:empty{ display: none; }
.rgb-chat-quick-label{
  display: block;
  font-size: .7rem;
  color: var(--text-3);
  margin-bottom: .35rem;
}
.rgb-chat-quick .rgb-chat-chips{ margin-top: 0; padding-bottom: .6rem; }

/* ================= COMPOSER ================= */
.rgb-chat-form{
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem .9rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.rgb-chat-input{
  flex: 1 1 auto;
  min-width: 0;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .6rem 1rem;
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: .9rem;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.rgb-chat-input::placeholder{ color: var(--text-3); }
.rgb-chat-input:focus{ outline: none; border-color: var(--b-400); background: var(--surface-2); }
.rgb-chat-input:focus-visible{ outline: 2px solid var(--b-400); outline-offset: 2px; }

.rgb-chat-send{
  width: 42px; height: 42px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  background: var(--grad-primary);
  color: #fff;
  font-size: 1.05rem;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px -12px rgba(25,118,210,.7);
  transition: transform .2s var(--ease), filter .2s var(--ease), opacity .2s var(--ease);
}
.rgb-chat-send:hover:not(:disabled){ transform: scale(1.06); filter: brightness(1.06); }
.rgb-chat-send:disabled{ opacity: .45; cursor: not-allowed; box-shadow: none; }
/* The paper-plane glyph points right; mirror it for RTL */
html[dir="rtl"] .rgb-chat-send i{ transform: scaleX(-1); }

.rgb-chat-foot{
  flex: 0 0 auto;
  padding: 0 .9rem .6rem;
  background: var(--surface);
  font-size: .66rem;
  color: var(--text-3);
  text-align: center;
}

/* ================= RESPONSIVE ================= */
/* Tablets and phones — the site shrinks its floating buttons here */
@media (max-width: 767.98px){
  /* Mirrors the 52px WhatsApp button at 18px inset from css/responsive.css */
  .rgb-chat{
    --chat-launcher: 52px;
    --chat-gap: 18px;
    --chat-bottom: 18px;
    --chat-whatsapp: 52px;
    --chat-pair-gap: 12px;
  }
  .rgb-chat-launcher{ font-size: 1.35rem; }

  .rgb-chat-panel{
    width: auto;
    inset-inline: 12px;
    height: auto;
    top: calc(var(--rgb-header-h) + 10px);
    max-height: none;
  }
}

/* Small phones — full-height sheet, tighter paddings */
@media (max-width: 575.98px){
  .rgb-chat-panel{
    inset-inline: 8px;
    bottom: 12px;
    top: calc(var(--rgb-header-h) + 8px);
    border-radius: var(--radius-md);
  }
  .rgb-chat-log{ padding: .85rem; gap: .7rem; }
  .rgb-chat-msg{ max-width: 92%; }
  .rgb-chat-bubble{ font-size: .88rem; }
  .rgb-chat-head{ padding: .75rem .85rem; }
}

/* Short viewports (landscape phones) — keep the composer reachable */
@media (max-height: 520px){
  .rgb-chat-panel{ top: calc(var(--rgb-header-h) + 6px); bottom: 10px; height: auto; max-height: none; }
  .rgb-chat-quick{ max-height: 4.2rem; }
}
