/* =========================================================
   SupportDesk Chat Widget — Stylesheet
   Design: Glassmorphism, dual theme (dark default / light)
   Palette:
     --bg-deep      : #0f1226  (deep indigo night backdrop)
     --accent-teal  : #2dd4bf  (signature accent — "online" teal)
     --accent-violet: #8b5cf6  (secondary accent for bot bubbles)
     --user-bubble  : #2dd4bf -> #14b8a6 gradient
     --glass        : rgba(255,255,255,0.08)
   ========================================================= */

:root {
  /* ---- Dark theme (default) ---- */
  --bg-deep: #0f1226;
  --bg-deep-2: #171b3a;
  --glass-bg: rgba(255, 255, 255, 0.07);
  --glass-border: rgba(255, 255, 255, 0.14);
  --text-main: #f1f2fb;
  --text-muted: #a3a6c2;
  --accent-teal: #2dd4bf;
  --accent-violet: #8b5cf6;
  --bot-bubble-bg: rgba(255, 255, 255, 0.09);
  --bot-bubble-text: #f1f2fb;
  --user-bubble-grad: linear-gradient(135deg, #2dd4bf, #14b8a6);
  --user-bubble-text: #04231d;
  --input-bg: rgba(255, 255, 255, 0.06);
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.35);
  --chip-bg: rgba(255, 255, 255, 0.08);
  --chip-border: rgba(255, 255, 255, 0.18);
}

/* ---- Light theme overrides ---- */
body.light-theme {
  --bg-deep: #eef1fb;
  --bg-deep-2: #dfe4fb;
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.9);
  --text-main: #1c1f36;
  --text-muted: #5c6080;
  --accent-teal: #0d9488;
  --accent-violet: #7c3aed;
  --bot-bubble-bg: rgba(255, 255, 255, 0.75);
  --bot-bubble-text: #1c1f36;
  --user-bubble-grad: linear-gradient(135deg, #2dd4bf, #0d9488);
  --user-bubble-text: #05261f;
  --input-bg: rgba(255, 255, 255, 0.7);
  --shadow-soft: 0 8px 30px rgba(80, 90, 150, 0.18);
  --chip-bg: rgba(255, 255, 255, 0.6);
  --chip-border: rgba(120, 120, 180, 0.25);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at 20% 20%, var(--bg-deep-2), var(--bg-deep) 70%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: background 0.4s ease, color 0.4s ease;
  position: relative;
}

/* ============ Ambient background blobs ============ */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  z-index: 0;
  animation: float 12s ease-in-out infinite;
}
.blob-1 {
  width: 380px;
  height: 380px;
  background: var(--accent-teal);
  top: -80px;
  left: -100px;
  animation-delay: 0s;
}
.blob-2 {
  width: 320px;
  height: 320px;
  background: var(--accent-violet);
  bottom: -60px;
  right: -80px;
  animation-delay: 2s;
}
.blob-3 {
  width: 220px;
  height: 220px;
  background: #f472b6;
  top: 40%;
  right: 10%;
  opacity: 0.18;
  animation-delay: 4s;
}

@keyframes float {
  0%, 100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-25px) translateX(15px); }
}

/* ============ Main chat app card ============ */
.chat-app {
  position: relative;
  z-index: 1;
  width: 420px;
  max-width: 94vw;
  height: 680px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 26px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  animation: appIn 0.5s ease;
}

@keyframes appIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ Header ============ */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-violet));
  flex-shrink: 0;
}

.avatar.small {
  width: 30px;
  height: 30px;
  font-size: 14px;
}

.status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--bg-deep);
}

.header-info h1 {
  margin: 0;
  font-family: "Poppins", sans-serif;
  font-size: 16px;
  font-weight: 600;
}

.status-text {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--accent-teal);
  font-weight: 500;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-main);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
}

.icon-btn:hover {
  transform: scale(1.08);
  background: rgba(255, 255, 255, 0.15);
}

/* ============ Chat window ============ */
.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-window::-webkit-scrollbar {
  width: 6px;
}
.chat-window::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 10px;
}

.date-divider {
  text-align: center;
  margin: 4px 0 10px;
}
.date-divider span {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 4px 12px;
  border-radius: 20px;
}

/* ============ Message rows ============ */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  animation: msgIn 0.35s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row.bot {
  justify-content: flex-start;
}
.msg-row.user {
  justify-content: flex-end;
}

.msg-content {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.msg-row.user .msg-content {
  align-items: flex-end;
}

.bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}

.msg-row.bot .bubble {
  background: var(--bot-bubble-bg);
  color: var(--bot-bubble-text);
  border: 1px solid var(--glass-border);
  border-radius: 16px 16px 16px 4px;
}

.msg-row.user .bubble {
  background: var(--user-bubble-grad);
  color: var(--user-bubble-text);
  border-radius: 16px 16px 4px 16px;
  font-weight: 500;
}

.msg-time {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

/* ============ Typing indicator ============ */
.typing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 10px;
  flex-shrink: 0;
}

.typing-bubble {
  background: var(--bot-bubble-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px 16px 16px 4px;
  padding: 10px 14px;
  display: flex;
  gap: 4px;
}

.typing-bubble .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite;
}
.typing-bubble .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ============ Quick reply chips ============ */
.quick-chips {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.chip {
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  color: var(--text-main);
  font-size: 12.5px;
  padding: 7px 13px;
  border-radius: 20px;
  cursor: pointer;
  font-family: "Inter", sans-serif;
  transition: transform 0.15s ease, background 0.15s ease;
}

.chip:hover {
  transform: translateY(-2px);
  background: var(--accent-teal);
  color: #04231d;
}

/* ============ Input bar ============ */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}

#chatInput {
  flex: 1;
  border: 1px solid var(--glass-border);
  background: var(--input-bg);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: 22px;
  font-size: 14px;
  font-family: "Inter", sans-serif;
  outline: none;
  transition: border 0.2s ease;
}

#chatInput:focus {
  border-color: var(--accent-teal);
}

#chatInput::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-violet));
  color: #04231d;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 18px rgba(45, 212, 191, 0.4);
}

.send-btn:active {
  transform: scale(0.94);
}

/* ============ Mobile responsiveness ============ */
@media (max-width: 480px) {
  .chat-app {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  body {
    padding: 0;
  }
}