* { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- Theme via CSS custom properties ---- */
.chat-widget {
  --cw-primary: #6c5ce7;
  --cw-primary-hover: #5a4bd1;
  --cw-primary-light: #ede9fe;
  --cw-primary-shadow: rgba(108, 92, 231, 0.4);
  --cw-text-on-primary: #ffffff;
}

/* Floating trigger button */
.chat-trigger {
  position: fixed; bottom: 28px; right: 28px; z-index: 1000;
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: var(--cw-primary); color: var(--cw-text-on-primary); cursor: pointer;
  box-shadow: 0 4px 16px var(--cw-primary-shadow);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chat-trigger:hover { transform: scale(1.08); }
.chat-trigger svg { width: 28px; height: 28px; }

/* Chat popup */
.chat-popup {
  position: fixed; bottom: 100px; right: 28px; z-index: 1001;
  width: 400px; height: 560px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  display: none; flex-direction: column; overflow: hidden;
}
.chat-popup.open { display: flex; }

/* Header */
.chat-header {
  background: var(--cw-primary); color: var(--cw-text-on-primary); padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header-left { display: flex; align-items: center; gap: 10px; }
.chat-header-left .avatar {
  width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.chat-header-left .info h3 { font-size: 15px; font-weight: 600; }
.chat-header-left .info span { font-size: 11px; opacity: 0.85; }
.chat-close {
  background: none; border: none; color: var(--cw-text-on-primary); cursor: pointer;
  font-size: 22px; line-height: 1; opacity: 0.8; padding: 4px;
}
.chat-close:hover { opacity: 1; }

/* Messages area */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: #f8f9fa;
}

.msg { max-width: 85%; padding: 10px 14px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.msg.user {
  align-self: flex-end; background: var(--cw-primary); color: var(--cw-text-on-primary);
  border-radius: 14px 14px 4px 14px;
}
.msg.assistant {
  align-self: flex-start; background: #fff; color: #2d3436;
  border-radius: 14px 14px 14px 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.status-pill {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px; font-size: 11px; color: var(--cw-primary);
  background: var(--cw-primary-light);
}
.status-pill .spinner {
  width: 10px; height: 10px; border: 2px solid var(--cw-primary-light);
  border-top-color: var(--cw-primary); border-radius: 50%;
  animation: cw-spin 0.6s linear infinite;
}
@keyframes cw-spin { to { transform: rotate(360deg); } }

.msg.error-msg { background: #fee; color: #c0392b; align-self: flex-start; border-radius: 14px 14px 14px 4px; }

/* Input area */
.chat-input-bar {
  padding: 12px 16px; border-top: 1px solid #eee; background: #fff;
  display: flex; gap: 8px; align-items: center;
}
.chat-input-bar input {
  flex: 1; padding: 10px 14px; border: 1px solid #e0e0e0; border-radius: 24px;
  font-size: 13px; outline: none; background: #f8f9fa;
}
.chat-input-bar input:focus { border-color: var(--cw-primary); background: #fff; }
.chat-input-bar button {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: var(--cw-primary); color: var(--cw-text-on-primary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.chat-input-bar button:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-input-bar button:hover:not(:disabled) { background: var(--cw-primary-hover); }
.chat-input-bar button svg { width: 18px; height: 18px; }

/* Welcome message */
.welcome { text-align: center; padding: 30px 20px; color: #888; font-size: 13px; line-height: 1.6; }
.welcome .icon { font-size: 36px; margin-bottom: 8px; display: block; }
