/* =============================================
   Concord Chat Widget - Premium UI
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --cc-primary: #1a56db;
  --cc-primary-hover: #1648b8;
  --cc-primary-light: #e8effc;
  --cc-bg: #ffffff;
  --cc-bg-secondary: #f8f9fc;
  --cc-text: #1f2937;
  --cc-text-secondary: #6b7280;
  --cc-border: #e5e7eb;
  --cc-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  --cc-radius: 16px;
  --cc-bot-bubble: #f0f4ff;
  --cc-user-bubble: #1a56db;
  --cc-user-text: #ffffff;
  --cc-cs-bubble: #ecfdf5;
  --cc-cs-accent: #059669;
  --cc-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --cc-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Toggle Button ────────────────────────── */
.cc-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #1a56db 0%, #3b82f6 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(26, 86, 219, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--cc-transition);
  animation: cc-pulse 2s ease-in-out infinite;
}

.cc-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(26, 86, 219, 0.5);
}

.cc-toggle.active {
  animation: none;
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  box-shadow: 0 8px 32px rgba(220, 38, 38, 0.4);
}

.cc-toggle svg {
  width: 28px;
  height: 28px;
  transition: var(--cc-transition);
}

.cc-toggle.active .cc-icon-chat { display: none; }
.cc-toggle:not(.active) .cc-icon-close { display: none; }

@keyframes cc-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(26, 86, 219, 0.4); }
  50% { box-shadow: 0 8px 32px rgba(26, 86, 219, 0.2), 0 0 0 12px rgba(26, 86, 219, 0.08); }
}

/* ── Badge Unread ─────────────────────────── */
.cc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: cc-badge-pop 0.3s ease;
}

.cc-badge.show {
  display: flex;
}

@keyframes cc-badge-pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ── Chat Window ──────────────────────────── */
.cc-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 99998;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--cc-bg);
  border-radius: var(--cc-radius);
  box-shadow: var(--cc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: var(--cc-transition);
  font-family: var(--cc-font);
}

.cc-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ───────────────────────────────── */
.cc-header {
  background: linear-gradient(135deg, #1a56db 0%, #2563eb 50%, #3b82f6 100%);
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.cc-header::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
}

.cc-header-avatar {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.cc-header-info {
  flex: 1;
  min-width: 0;
}

.cc-header-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.cc-header-subtitle {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}

.cc-header-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  margin-top: 4px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

.cc-header-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  animation: cc-dot-blink 1.5s ease-in-out infinite;
}

.cc-header-status.live .dot {
  background: #fbbf24;
}

@keyframes cc-dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Messages Area ────────────────────────── */
.cc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cc-bg-secondary);
  scroll-behavior: smooth;
}

.cc-messages::-webkit-scrollbar {
  width: 5px;
}

.cc-messages::-webkit-scrollbar-track {
  background: transparent;
}

.cc-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

/* ── Welcome Screen ──────────────────────── */
.cc-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 24px;
  text-align: center;
  background: var(--cc-bg-secondary);
}

.cc-welcome-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #e8effc 0%, #dbeafe 100%);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: 20px;
}

.cc-welcome h3 {
  font-family: var(--cc-font);
  font-size: 20px;
  font-weight: 700;
  color: var(--cc-text);
  margin: 0 0 8px 0;
}

.cc-welcome p {
  font-family: var(--cc-font);
  font-size: 14px;
  color: var(--cc-text-secondary);
  margin: 0 0 28px 0;
  line-height: 1.5;
}

.cc-welcome-btn {
  font-family: var(--cc-font);
  background: linear-gradient(135deg, #1a56db 0%, #3b82f6 100%);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--cc-transition);
  box-shadow: 0 4px 16px rgba(26, 86, 219, 0.3);
}

.cc-welcome-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(26, 86, 219, 0.4);
}

/* ── Message Bubbles ─────────────────────── */
.cc-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: cc-msg-in 0.3s ease;
  position: relative;
}

@keyframes cc-msg-in {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.cc-msg-time {
  font-size: 10px;
  opacity: 0.5;
  margin-top: 4px;
  display: block;
}

/* Bot message */
.cc-msg.bot {
  align-self: flex-start;
  background: var(--cc-bot-bubble);
  color: var(--cc-text);
  border-bottom-left-radius: 4px;
}

/* User message */
.cc-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #1a56db 0%, #2563eb 100%);
  color: var(--cc-user-text);
  border-bottom-right-radius: 4px;
}

/* CS (live agent) message */
.cc-msg.cs {
  align-self: flex-start;
  background: var(--cc-cs-bubble);
  color: var(--cc-text);
  border-bottom-left-radius: 4px;
  border-left: 3px solid var(--cc-cs-accent);
}

.cc-msg.cs::before {
  content: '👤 CS';
  font-size: 10px;
  font-weight: 700;
  color: var(--cc-cs-accent);
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* System message */
.cc-msg.system {
  align-self: center;
  max-width: 90%;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  padding: 8px 16px;
}

/* ── Typing Indicator ────────────────────── */
.cc-typing {
  align-self: flex-start;
  background: var(--cc-bot-bubble);
  padding: 12px 18px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: none;
  gap: 5px;
  align-items: center;
}

.cc-typing.show {
  display: flex;
}

.cc-typing span {
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: cc-typing-dot 1.4s ease-in-out infinite;
}

.cc-typing span:nth-child(2) { animation-delay: 0.2s; }
.cc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cc-typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Input Area ──────────────────────────── */
.cc-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--cc-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--cc-bg);
  flex-shrink: 0;
}

.cc-input {
  flex: 1;
  border: 1.5px solid var(--cc-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--cc-font);
  color: var(--cc-text);
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 40px;
  line-height: 1.4;
  background: var(--cc-bg-secondary);
  transition: var(--cc-transition);
}

.cc-input:focus {
  border-color: var(--cc-primary);
  background: var(--cc-bg);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.cc-input::placeholder {
  color: #9ca3af;
}

.cc-send-btn {
  width: 42px;
  height: 42px;
  border: none;
  background: linear-gradient(135deg, #1a56db 0%, #3b82f6 100%);
  color: #fff;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--cc-transition);
  flex-shrink: 0;
}

.cc-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(26, 86, 219, 0.3);
}

.cc-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.cc-send-btn svg {
  width: 20px;
  height: 20px;
}

/* ── Powered By ──────────────────────────── */
.cc-powered {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: #b0b0b0;
  background: var(--cc-bg);
  flex-shrink: 0;
}

/* ── Live Agent Banner ───────────────────── */
.cc-live-banner {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-bottom: 1px solid #a7f3d0;
  font-size: 12px;
  font-weight: 600;
  color: #065f46;
  flex-shrink: 0;
}

.cc-live-banner.show {
  display: flex;
}

.cc-live-banner .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  animation: cc-dot-blink 1.5s ease-in-out infinite;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 480px) {
  .cc-window {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  .cc-toggle {
    bottom: 16px;
    right: 16px;
  }
}
