/**
 * AI Chat Widget CSS
 * Floating bubble + slide-up window design.
 * Colors driven by --chat-color (set from Customizer).
 *
 * @package AshishSaha
 */

/* ── Root ────────────────────────────────────────────────────────────── */
.ashish-chat {
  position:   fixed;
  bottom:     1.5rem;
  z-index:    99999;
  font-family: var(--font-body, 'DM Sans', sans-serif);
  font-size:  15px;
}
.ashish-chat--right { right: 1.5rem; }
.ashish-chat--left  { left:  1.5rem; }

/* ── Trigger Bubble ──────────────────────────────────────────────────── */
.ashish-chat__trigger {
  position:        relative;
  width:           3.5rem;
  height:          3.5rem;
  border-radius:   50%;
  background:      var(--chat-color, var(--primary, #4A90E2));
  color:           #fff;
  border:          none;
  cursor:          pointer;
  display:         flex;
  align-items:     center;
  justify-content: center;
  box-shadow:      0 4px 20px rgba(var(--chat-color-rgb, 74,144,226), .45);
  transition:      transform .25s, box-shadow .25s;
}
.ashish-chat__trigger:hover {
  transform:  scale(1.08);
  box-shadow: 0 6px 28px rgba(var(--chat-color-rgb, 74,144,226), .55);
}
.ashish-chat__trigger svg { width: 1.5rem; height: 1.5rem; }

/* Pulse ring animation */
.ashish-chat__trigger::before {
  content:       '';
  position:      absolute;
  inset:         -6px;
  border-radius: 50%;
  border:        2px solid var(--chat-color, var(--primary));
  opacity:       0;
  animation:     chat-pulse 2.4s ease-out infinite;
}
@keyframes chat-pulse {
  0%   { transform: scale(.9); opacity: .6; }
  70%  { transform: scale(1.3); opacity: 0; }
  100% { opacity: 0; }
}

/* Unread badge */
.ashish-chat__badge {
  position:        absolute;
  top:             -2px;
  right:           -2px;
  width:           1.15rem;
  height:          1.15rem;
  border-radius:   50%;
  background:      #ef4444;
  color:           #fff;
  font-size:       .65rem;
  font-weight:     700;
  display:         flex;
  align-items:     center;
  justify-content: center;
  border:          2px solid #fff;
  animation:       badge-pop .3s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes badge-pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* ── Chat Window ─────────────────────────────────────────────────────── */
.ashish-chat__window {
  position:      absolute;
  bottom:        calc(100% + .75rem);
  width:         340px;
  max-height:    520px;
  display:       flex;
  flex-direction: column;
  background:    #fff;
  border-radius: 1.25rem;
  box-shadow:    0 8px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
  overflow:      hidden;
  animation:     chat-slide-in .25s cubic-bezier(.34,1.4,.64,1) both;
}
.ashish-chat--right .ashish-chat__window { right: 0; }
.ashish-chat--left  .ashish-chat__window { left:  0; }

@keyframes chat-slide-in {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

/* ── Header ──────────────────────────────────────────────────────────── */
.ashish-chat__header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         1rem 1.15rem;
  background:      var(--chat-color, var(--primary, #4A90E2));
  color:           #fff;
  flex-shrink:     0;
}
.ashish-chat__header-info {
  display:     flex;
  align-items: center;
  gap:         .7rem;
}
.ashish-chat__avatar {
  position:        relative;
  width:           2.4rem;
  height:          2.4rem;
  border-radius:   50%;
  background:      rgba(255,255,255,.25);
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-weight:     700;
  font-size:       1rem;
  flex-shrink:     0;
}
.ashish-chat__online-dot {
  position:      absolute;
  bottom:        1px;
  right:         1px;
  width:         .6rem;
  height:        .6rem;
  border-radius: 50%;
  background:    #22c55e;
  border:        2px solid #fff;
}
.ashish-chat__agent-name {
  display:     block;
  font-size:   .9rem;
  font-weight: 700;
  color:       #fff;
}
.ashish-chat__status {
  display:   block;
  font-size: .72rem;
  opacity:   .8;
}
.ashish-chat__minimize {
  background:  transparent;
  border:      none;
  color:       rgba(255,255,255,.85);
  cursor:      pointer;
  padding:     .25rem;
  border-radius: .35rem;
  transition:  background .15s;
  line-height: 0;
}
.ashish-chat__minimize:hover { background: rgba(255,255,255,.2); }
.ashish-chat__minimize svg   { width: 1.1rem; height: 1.1rem; }

/* ── Messages ────────────────────────────────────────────────────────── */
.ashish-chat__messages {
  flex:          1;
  overflow-y:    auto;
  padding:       1rem;
  display:       flex;
  flex-direction: column;
  gap:           .75rem;
  scroll-behavior: smooth;
}
.ashish-chat__messages::-webkit-scrollbar { width: 4px; }
.ashish-chat__messages::-webkit-scrollbar-track { background: transparent; }
.ashish-chat__messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.ashish-chat__msg { display: flex; flex-direction: column; max-width: 85%; gap: .2rem; }
.ashish-chat__msg--user     { align-self: flex-end; align-items: flex-end; }
.ashish-chat__msg--assistant { align-self: flex-start; }

.ashish-chat__bubble {
  padding:       .65rem .9rem;
  border-radius: 1.1rem;
  font-size:     .875rem;
  line-height:   1.55;
  word-break:    break-word;
}
.ashish-chat__msg--user .ashish-chat__bubble {
  background:    var(--chat-color, var(--primary, #4A90E2));
  color:         #fff;
  border-bottom-right-radius: .35rem;
}
.ashish-chat__msg--assistant .ashish-chat__bubble {
  background:    #f1f5f9;
  color:         #0f172a;
  border-bottom-left-radius: .35rem;
}
.ashish-chat__bubble a { color: inherit; text-decoration: underline; }
.ashish-chat__bubble code { background: rgba(0,0,0,.1); padding: .1rem .3rem; border-radius: .25rem; font-size: .8em; }

.ashish-chat__time {
  font-size: .68rem;
  color:     #94a3b8;
}

/* ── Typing Indicator ────────────────────────────────────────────────── */
.ashish-chat__typing {
  display:     flex;
  gap:         4px;
  padding:     .5rem 1rem;
  align-items: center;
  flex-shrink: 0;
}
.ashish-chat__typing span {
  width:         7px;
  height:        7px;
  background:    #94a3b8;
  border-radius: 50%;
  animation:     typing-dot 1.2s ease-in-out infinite;
}
.ashish-chat__typing span:nth-child(2) { animation-delay: .2s; }
.ashish-chat__typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0);    opacity: .4; }
  30%            { transform: translateY(-5px); opacity: 1;  }
}

/* ── Quick Replies ───────────────────────────────────────────────────── */
.ashish-chat__quick-replies {
  display:   flex;
  flex-wrap: wrap;
  gap:       .4rem;
  padding:   .5rem 1rem;
  flex-shrink: 0;
}
.ashish-chat__quick-btn {
  padding:       .35rem .85rem;
  border-radius: 1rem;
  border:        1px solid var(--chat-color, var(--primary, #4A90E2));
  color:         var(--chat-color, var(--primary, #4A90E2));
  background:    transparent;
  font-size:     .78rem;
  font-weight:   600;
  cursor:        pointer;
  transition:    background .15s, color .15s;
}
.ashish-chat__quick-btn:hover {
  background: var(--chat-color, var(--primary, #4A90E2));
  color:      #fff;
}

/* ── Input Form ──────────────────────────────────────────────────────── */
.ashish-chat__form { flex-shrink: 0; padding: .75rem; border-top: 1px solid #e2e8f0; }
.ashish-chat__input-wrap {
  display:       flex;
  align-items:   flex-end;
  gap:           .5rem;
  background:    #f8fafc;
  border:        1px solid #e2e8f0;
  border-radius: .875rem;
  padding:       .5rem .5rem .5rem .75rem;
  transition:    border-color .2s, box-shadow .2s;
}
.ashish-chat__input-wrap:focus-within {
  border-color: var(--chat-color, var(--primary, #4A90E2));
  box-shadow:   0 0 0 3px rgba(var(--chat-color-rgb, 74,144,226),.12);
}
.ashish-chat__input {
  flex:        1;
  border:      none;
  background:  transparent;
  font-family: inherit;
  font-size:   .875rem;
  line-height: 1.5;
  resize:      none;
  max-height:  120px;
  outline:     none;
  color:       #0f172a;
}
.ashish-chat__input::placeholder { color: #94a3b8; }
.ashish-chat__send {
  width:           2.1rem;
  height:          2.1rem;
  border-radius:   50%;
  border:          none;
  background:      var(--chat-color, var(--primary, #4A90E2));
  color:           #fff;
  display:         flex;
  align-items:     center;
  justify-content: center;
  cursor:          pointer;
  flex-shrink:     0;
  transition:      background .15s, transform .15s;
}
.ashish-chat__send:disabled { background: #cbd5e1; cursor: not-allowed; transform: none; }
.ashish-chat__send:not(:disabled):hover { background: var(--primary-dark, #3a7fd4); transform: scale(1.06); }
.ashish-chat__send svg { width: .95rem; height: .95rem; }

/* ── Footer brand ────────────────────────────────────────────────────── */
.ashish-chat__footer-brand {
  text-align:  center;
  font-size:   .68rem;
  color:       #94a3b8;
  padding:     .35rem;
  flex-shrink: 0;
}
.ashish-chat__footer-brand a { color: inherit; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 400px) {
  .ashish-chat__window { width: calc(100vw - 2rem); }
  .ashish-chat--right  { right: 1rem; }
  .ashish-chat--left   { left:  1rem; }
}
