/* ── Kaissa Support Chat Widget ─────────────────────────────────────────── */

#chat-widget-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  transition: transform 0.2s, box-shadow 0.2s;
}
#chat-widget-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(99,102,241,0.55);
}
#chat-widget-fab img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

/* ── Panel ─────────────────────────────────────────────────────────────── */
#chat-widget-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 360px;
  max-height: 520px;
  background: #1a1a2e;
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  z-index: 9001;
  clip-path: inset(0 round 16px);
  transition: opacity 0.2s, transform 0.2s;
}
#chat-widget-panel.cw-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

/* ── Header ──────────────────────────────────────────────────────────────*/
#chat-widget-header {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#chat-widget-header .cw-title {
  font-weight: 600;
  color: #fff;
  font-size: 15px;
}
#chat-widget-header .cw-subtitle {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
}
#chat-widget-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.8);
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
#chat-widget-close:hover { color: #fff; }
#chat-widget-close svg { width: 18px; height: 18px; }

/* ── Turnstile gate ──────────────────────────────────────────────────────*/
#chat-widget-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 20px;
  flex: 1;
}
#chat-widget-gate p {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  text-align: center;
  margin: 0;
}
#chat-turnstile-container { min-height: 65px; }

/* ── Messages area ───────────────────────────────────────────────────────*/
#chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#chat-widget-messages::-webkit-scrollbar { width: 4px; }
#chat-widget-messages::-webkit-scrollbar-track { background: transparent; }
#chat-widget-messages::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.4); border-radius: 2px; }

.cw-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.cw-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cw-msg.assistant {
  align-self: flex-start;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
  border-bottom-left-radius: 4px;
}
.cw-msg.typing {
  align-self: flex-start;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.5);
  font-style: italic;
}

/* ── Input row ───────────────────────────────────────────────────────────*/
#chat-widget-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
#chat-widget-input {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 20px;
  padding: 9px 14px;
  color: #fff;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
}
#chat-widget-input::placeholder { color: rgba(255,255,255,0.35); }
#chat-widget-input:focus { border-color: rgba(99,102,241,0.6); }
#chat-widget-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
#chat-widget-send:hover { opacity: 0.85; }
#chat-widget-send:disabled { opacity: 0.4; cursor: default; }
#chat-widget-send svg { width: 18px; height: 18px; fill: #fff; }

/* ── Mobile ──────────────────────────────────────────────────────────────*/
@media (max-width: 420px) {
  #chat-widget-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 80px;
  }
  #chat-widget-fab { right: 12px; }
}
