/*
  ============================================================
  chatbot.css — RanStack Solutions Chat Widget
  Add <link rel="stylesheet" href="chatbot.css"> in <head>
  ============================================================
*/

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --rs-c-ink:        #0a0a0a;
  --rs-c-ink-lt:     #333333;
  --rs-c-surface:    #ffffff;
  --rs-c-mist:       #f5f5f5;
  --rs-c-border:     #e4e4e4;
  --rs-c-subtext:    #999999;
  --rs-c-green:      #22c55e;
  --rs-c-red:        #ef4444;

  --rs-bot-bubble:   #f1f1f1;
  --rs-usr-bubble:   #0a0a0a;

  --rs-radius-win:   22px;
  --rs-radius-bub:   18px;

  --rs-font:         'Poppins', sans-serif;

  --rs-shadow-win:
    0 32px 80px rgba(0,0,0,0.14),
    0 8px  24px rgba(0,0,0,0.08),
    0 2px  6px  rgba(0,0,0,0.04);
}

/* ── FAB ─────────────────────────────────────────────────── */
#rs-chat-fab {
  position:         fixed;
  bottom:           28px;
  right:            28px;
  z-index:          9999;
  width:            100px;
  height:           100px;
  border-radius:    50%;
  background:       transparent;
  border:           none;
  cursor:           pointer;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  box-shadow:       none;
  color:            #fff;
  animation:        rs-fab-in 0.55s cubic-bezier(.34,1.56,.64,1) both;
  transition:       transform 0.2s cubic-bezier(.34,1.4,.64,1),
                    opacity 0.2s, visibility 0.2s;
}
#rs-chat-fab.open {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
#rs-chat-fab:hover  { transform: scale(1.1); }
#rs-chat-fab:active { transform: scale(0.94); }

/* icon swap */
.rs-fab-icon        { position: absolute; transition: opacity 0.2s, transform 0.22s; pointer-events: none; }
.rs-fab-chat        { opacity: 1; transform: scale(1) rotate(0deg); width: 100%; height: 100%; object-fit: contain; }
.rs-fab-close       { display: none; }
#rs-chat-fab.open .rs-fab-chat  { opacity: 0; }

/* notification dot */
#rs-chat-notif {
  position:     absolute;
  top:          3px;
  right:        3px;
  width:        12px;
  height:       12px;
  background:   var(--rs-c-red);
  border-radius:50%;
  border:       2.5px solid #fff;
  display:      none;
  animation:    rs-pulse 2s infinite;
}

@keyframes rs-fab-in {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);   opacity: 1; }
}
@keyframes rs-pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.3); }
}

/* mobile */
@media (max-width: 480px) {
  #rs-chat-fab { bottom: 18px; right: 18px; }
}

/* ── Window ──────────────────────────────────────────────── */
#rs-chat-window {
  position:       fixed;
  bottom:         30px;
  right:          28px;
  z-index:        9998;
  width:          385px;
  max-width:      calc(100vw - 36px);
  height:         570px;
  max-height:     calc(100vh - 130px);
  background:     var(--rs-c-surface);
  border-radius:  var(--rs-radius-win);
  border:         1px solid var(--rs-c-border);
  box-shadow:     var(--rs-shadow-win);
  display:        flex;
  flex-direction: column;
  overflow:       hidden;
  font-family:    var(--rs-font);

  /* hidden state */
  opacity:        0;
  transform:      translateY(18px) scale(0.96);
  pointer-events: none;
  transition:     opacity 0.24s ease,
                  transform 0.26s cubic-bezier(.34,1.2,.64,1);
}
#rs-chat-window.rs-open {
  opacity:        1;
  transform:      translateY(0) scale(1);
  pointer-events: all;
}

@media (max-width: 480px) {
  #rs-chat-window {
    bottom:        0; right: 0; left: 0;
    width:         100%; max-width: 100%;
    border-radius: var(--rs-radius-win) var(--rs-radius-win) 0 0;
    height:        88vh; max-height: 88vh;
  }
}

/* ── Header ──────────────────────────────────────────────── */
.rs-chat-header {
  flex-shrink: 0;
  background:  var(--rs-c-ink);
  padding:     14px 16px;
  display:     flex;
  align-items: center;
  gap:         11px;
}

.rs-chat-avatar {
  flex-shrink:      0;
  width:            40px;
  height:           40px;
  border-radius:    50%;
  background:       transparent;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  position:         relative;
}
/* online dot */
.rs-chat-avatar::after {
  content:       '';
  position:      absolute;
  bottom:        1px; right: 1px;
  width:         10px; height: 10px;
  background:    var(--rs-c-green);
  border-radius: 50%;
  border:        2px solid var(--rs-c-ink);
}

.rs-chat-header-info { flex: 1; min-width: 0; }

.rs-chat-name {
  color:       #fff;
  font-size:   14px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
}
.rs-chat-status {
  display:     flex;
  align-items: center;
  gap:         5px;
  margin-top:  2px;
}
.rs-status-dot {
  width:         7px; height: 7px;
  background:    var(--rs-c-green);
  border-radius: 50%;
  flex-shrink:   0;
  animation:     rs-pulse 2.5s infinite;
}
#rs-status-label {
  color:       rgba(255,255,255,0.55);
  font-size:   11px;
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
}

.rs-chat-close {
  flex-shrink:      0;
  width:            30px; height: 30px;
  border-radius:    50%;
  background:       rgba(255,255,255,0.1);
  border:           none;
  color:            #fff;
  cursor:           pointer;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  transition:       background 0.15s, transform 0.1s;
}
.rs-chat-close:hover  { background: rgba(255,255,255,0.2); }
.rs-chat-close:active { transform: scale(0.9); }

/* ── Messages ────────────────────────────────────────────── */
#rs-chat-messages {
  flex:            1;
  overflow-y:      auto;
  padding:         18px 14px 10px;
  display:         flex;
  flex-direction:  column;
  gap:             2px;
  scroll-behavior: smooth;
}
#rs-chat-messages::-webkit-scrollbar { width: 3px; }
#rs-chat-messages::-webkit-scrollbar-thumb {
  background:    #ddd;
  border-radius: 2px;
}

/* date divider */
.rs-date-sep {
  text-align:   center;
  font-size:    10.5px;
  color:        var(--rs-c-subtext);
  margin:       6px 0 10px;
  letter-spacing: 0.05em;
}

/* message row */
.rs-msg-row {
  display:     flex;
  align-items: flex-end;
  gap:         7px;
  animation:   rs-msg-in 0.26s cubic-bezier(.34,1.2,.64,1) both;
}
.rs-msg-row.bot  { flex-direction: row; }
.rs-msg-row.user { flex-direction: row-reverse; }

@keyframes rs-msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* mini avatar beside bot bubbles */
.rs-msg-ava {
  flex-shrink:      0;
  width:            30px; height: 30px;
  border-radius:    50%;
  background:       linear-gradient(135deg, #555, #111); 
  display:          flex;
  align-items:      center;
  justify-content:  center;
  margin-bottom:    2px;
}
.rs-msg-row.user .rs-msg-ava { display: none; }

/* bubble column */
.rs-msg-col {
  display:        flex;
  flex-direction: column;
  max-width:      80%;
}
.rs-msg-row.bot  .rs-msg-col { align-items: flex-start; }
.rs-msg-row.user .rs-msg-col { align-items: flex-end; }

/* bubble */
.rs-bubble {
  padding:     10px 13px;
  border-radius: var(--rs-radius-bub);
  font-size:   13.5px;
  line-height: 1.55;
  word-break:  break-word;
}
.rs-msg-row.bot  .rs-bubble {
  background:              var(--rs-bot-bubble);
  color:                   var(--rs-c-ink);
  border-bottom-left-radius: 5px;
}
.rs-msg-row.user .rs-bubble {
  background:               var(--rs-usr-bubble);
  color:                    #fff;
  border-bottom-right-radius: 5px;
}

/* links inside bot bubble */
.rs-msg-row.bot .rs-bubble a { color: var(--rs-c-ink); font-weight: 600; }

/* timestamp */
.rs-msg-time {
  font-size:   10px;
  color:       var(--rs-c-subtext);
  margin-top:  3px;
  padding:     0 3px;
}

/* ── Typing indicator ────────────────────────────────────── */
.rs-typing {
  display:       flex;
  align-items:   center;
  gap:           4px;
  padding:       11px 14px;
  background:    var(--rs-bot-bubble);
  border-radius: var(--rs-radius-bub);
  border-bottom-left-radius: 5px;
  width:         fit-content;
}
.rs-typing-dot {
  width:         7px; height: 7px;
  background:    #bbb;
  border-radius: 50%;
  animation:     rs-bounce 1.1s infinite ease-in-out;
}
.rs-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.rs-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes rs-bounce {
  0%,80%,100% { transform: scale(0.75); opacity: 0.45; }
  40%          { transform: scale(1.2);  opacity: 1; }
}

/* ── Quick-reply chips ───────────────────────────────────── */
#rs-chat-chips {
  flex-shrink: 0;
  padding:     4px 14px 8px;
  display:     flex;
  flex-wrap:   wrap;
  gap:         6px;
}

.rs-chip {
  display:       inline-flex;
  align-items:   center;
  padding:       6px 13px;
  border-radius: 20px;
  border:        1.5px solid var(--rs-c-border);
  background:    var(--rs-c-mist);
  color:         var(--rs-c-ink);
  font-size:     12px;
  font-weight:   500;
  font-family:   var(--rs-font);
  cursor:        pointer;
  white-space:   nowrap;
  animation:     rs-chip-in 0.22s cubic-bezier(.34,1.2,.64,1) both;
  transition:    background 0.14s, color 0.14s, border-color 0.14s, transform 0.1s;
}
.rs-chip:hover {
  background:   var(--rs-c-ink);
  color:        #fff;
  border-color: var(--rs-c-ink);
  transform:    translateY(-1px);
}
.rs-chip:active { transform: scale(0.95); }

@keyframes rs-chip-in {
  from { opacity: 0; transform: translateY(7px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ── Time-slot buttons ───────────────────────────────────── */
.rs-slot-grid {
  display:        flex;
  flex-wrap:      wrap;
  gap:            8px;
  padding:        8px 14px 4px 48px; /* indent to align under bot bubble */
  animation:      rs-msg-in 0.24s cubic-bezier(.34,1.2,.64,1) both;
}

.rs-slot-btn {
  display:       inline-flex;
  align-items:   center;
  gap:           5px;
  padding:       8px 16px;
  border-radius: 22px;
  border:        2px solid var(--rs-c-ink);
  background:    #fff;
  color:         var(--rs-c-ink);
  font-size:     13px;
  font-weight:   600;
  font-family:   var(--rs-font);
  cursor:        pointer;
  white-space:   nowrap;
  letter-spacing: 0.01em;
  animation:     rs-slot-in 0.28s cubic-bezier(.34,1.4,.64,1) both;
  transition:    background 0.15s, color 0.15s, transform 0.12s, box-shadow 0.15s;
  box-shadow:    0 1px 4px rgba(0,0,0,0.06);
}
.rs-slot-btn::before {
  content: '🕐';
  font-size: 13px;
  line-height: 1;
}
.rs-slot-btn:hover {
  background:  var(--rs-c-ink);
  color:       #fff;
  transform:   translateY(-2px);
  box-shadow:  0 4px 12px rgba(0,0,0,0.18);
}
.rs-slot-btn:active { transform: scale(0.95); }

@keyframes rs-slot-in {
  from { opacity: 0; transform: translateY(10px) scale(0.88); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── Input row ───────────────────────────────────────────── */
.rs-chat-input-row {
  flex-shrink: 0;
  padding:     10px 12px 14px;
  border-top:  1px solid var(--rs-c-border);
  display:     flex;
  align-items: flex-end;
  gap:         8px;
  background:  var(--rs-c-surface);
}

#rs-chat-input {
  flex:        1;
  padding:     9px 14px;
  border:      1.5px solid var(--rs-c-border);
  border-radius: 20px;
  font-size:   13.5px;
  font-family: var(--rs-font);
  color:       var(--rs-c-ink);
  background:  var(--rs-c-mist);
  outline:     none;
  resize:      none;
  max-height:  96px;
  line-height: 1.5;
  overflow-y:  auto;
  transition:  border-color 0.15s, background 0.15s;
}
#rs-chat-input:focus        { border-color: #888; background: #fff; }
#rs-chat-input::placeholder { color: #bbb; }

#rs-chat-send {
  flex-shrink:      0;
  width:            40px; height: 40px;
  border-radius:    50%;
  background:       var(--rs-c-ink);
  border:           none;
  color:            #fff;
  cursor:           pointer;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  transition:       background 0.14s, transform 0.1s;
}
#rs-chat-send:hover  { background: #333; transform: scale(1.07); }
#rs-chat-send:active { transform: scale(0.92); }
#rs-chat-send:disabled { background: #ccc; cursor: not-allowed; transform: none; }

/* ── Footer caption ──────────────────────────────────────── */
.rs-chat-foot {
  text-align:     center;
  font-size:      10px;
  color:          #ccc;
  padding:        0 0 9px;
  margin:         0;
  font-family:    var(--rs-font);
  letter-spacing: 0.03em;
}
