/* ═══════════════════════════════════════════════════════════════════
   C4-AI Widget Chat - Mobile-First Responsive Design
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --bg-1: #ffffff;
  --bg-2: #f8fafc;
  --bg-3: #f1f5f9;
  --text-1: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --border: #e2e8f0;
  --success: #10b981;
  --error: #ef4444;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-1: #0f172a;
    --bg-2: #1e293b;
    --bg-3: #334155;
    --text-1: #f1f5f9;
    --text-2: #94a3b8;
    --text-3: #64748b;
    --border: #334155;
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'IRANSans', 'Vazir', sans-serif;
  background: var(--bg-2);
  color: var(--text-1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

#widget-app {
  width: 100%;
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════
   Loading & Error States
   ═══════════════════════════════════════════════════════════════════ */

.widget-loading,
.widget-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-2);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.widget-error .error-icon {
  font-size: 48px;
}

.widget-error button {
  margin-top: 8px;
  padding: 10px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 14px;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════════════
   Chat Container
   ═══════════════════════════════════════════════════════════════════ */

.widget-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  max-width: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════
   Header
   ═══════════════════════════════════════════════════════════════════ */

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--primary);
  color: white;
  position: relative;
  z-index: 10;
}

.header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  overflow: hidden;
}

.header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-info {
  flex: 1;
}

.header-name {
  font-weight: 600;
  font-size: 16px;
}

.header-status {
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #34d399;
  border-radius: 50%;
}

.header-menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.header-menu-btn:hover {
  background: rgba(255,255,255,0.25);
}

/* ═══════════════════════════════════════════════════════════════════
   Menu Panel
   ═══════════════════════════════════════════════════════════════════ */

.menu-panel {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.menu-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}

.menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-1);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

.menu-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.menu-btn-emoji {
  font-size: 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   Messages Area
   ═══════════════════════════════════════════════════════════════════ */

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  width: 100%;
}

/* Load More Button */
.load-more-container {
  text-align: center;
  padding: 16px 0;
}

.load-more-btn {
  padding: 10px 24px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
}

.load-more-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Message Bubble */
.message {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeIn 0.3s ease;
}

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

.message.bot {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
}

.message-bubble,
.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.message.bot .message-bubble,
.message.bot .msg-bubble {
  background: var(--bg-3);
  color: var(--text-1);
  border-bottom-right-radius: var(--radius);
  border-bottom-left-radius: 4px;
}

.message.user .message-bubble,
.message.user .msg-bubble {
  background: var(--primary);
  color: white;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: 4px;
}

.message-time,
.msg-time {
  font-size: 11px;
  color: var(--text-3);
  padding: 0 4px;
}

.message.user .message-time,
.message.user .msg-time {
  text-align: left;
}

.message.bot .message-time,
.message.bot .msg-time {
  text-align: right;
}

/* Inline Buttons */
.message-buttons,
.msg-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.inline-btn {
  display: inline-block;
  padding: 8px 16px;
  background: var(--bg-1);
  border: 1px solid var(--primary);
  border-radius: var(--radius-xs);
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  text-align: center;
}

.inline-btn:hover {
  background: var(--primary);
  color: white;
}

/* URL buttons (anchor links) - stand out more */
a.inline-btn.url-btn {
  background: var(--primary);
  color: white;
  font-weight: 500;
}

a.inline-btn.url-btn:hover {
  background: var(--primary-dark, #0056b3);
  filter: brightness(1.1);
}

/* Inline text links (from AI responses) */
a.inline-link {
  color: var(--primary);
  text-decoration: underline;
  word-break: break-all;
}

a.inline-link:hover {
  color: var(--primary-dark, #0056b3);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-3);
  border-radius: var(--radius);
  width: fit-content;
  align-self: flex-start;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-3);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════
   Input Area
   ═══════════════════════════════════════════════════════════════════ */

.chat-input {
  padding: 12px 16px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 4px;
}

.input-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: var(--text-2);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.input-btn:hover {
  background: var(--bg-3);
  color: var(--primary);
}

.send-btn {
  background: var(--primary);
  color: white;
}

.send-btn:hover {
  background: var(--primary-dark);
  color: white;
}

.voice-btn.recording {
  background: var(--error);
  color: white;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

#message-input {
  flex: 1;
  border: none;
  background: none;
  font-size: 15px;
  padding: 8px;
  color: var(--text-1);
  outline: none;
}

#message-input::placeholder {
  color: var(--text-3);
}

/* ═══════════════════════════════════════════════════════════════════
   Product Cards (for /products command)
   ═══════════════════════════════════════════════════════════════════ */

.products-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.products-carousel::-webkit-scrollbar {
  display: none;
}

.product-card {
  min-width: 200px;
  max-width: 200px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.product-card-img {
  width: 100%;
  height: 120px;
  background: var(--bg-3);
  object-fit: cover;
}

.product-card-body {
  padding: 12px;
}

.product-card-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-card-price {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
}

.product-card-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  background: var(--primary);
  color: white;
}

/* ═══════════════════════════════════════════════════════════════════
   Media in Messages
   ═══════════════════════════════════════════════════════════════════ */

.msg-media {
  margin: 6px 0;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
}

.msg-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 12px;
  cursor: pointer;
  object-fit: contain;
  transition: transform 0.2s;
}

.msg-image:hover {
  transform: scale(1.02);
}

.voice-wrapper {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8ecf8 100%);
  border-radius: 16px;
  padding: 10px 14px;
}

.voice-label {
  font-size: 12px;
  color: #6366f1;
  font-weight: 600;
  margin-bottom: 6px;
}

.msg-audio {
  width: 100%;
  min-width: 260px;
  height: 54px;
  border-radius: 27px;
}

.msg-video {
  max-width: 100%;
  max-height: 280px;
  border-radius: 12px;
}

.msg-caption {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
  padding: 2px 4px;
}

.msg-file {
  margin: 8px 0;
}

.file-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  color: var(--text-1);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.file-link:hover {
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border-color: #c7d2fe;
  box-shadow: 0 2px 6px rgba(99,102,241,0.15);
}

.file-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.file-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
}

.file-action {
  font-size: 11px;
  color: #6366f1;
  font-weight: 500;
  margin-top: 2px;
}

.file-download-icon {
  font-size: 18px;
  flex-shrink: 0;
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════════════
   Reply / Quote
   ═══════════════════════════════════════════════════════════════════ */

.reply-quote {
  background: rgba(99, 102, 241, 0.08);
  border-right: 3px solid var(--primary);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.reply-quote:hover {
  background: rgba(99, 102, 241, 0.14);
}

.reply-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
}

.reply-text {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.msg-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
}

.reply-btn {
  background: none;
  border: none;
  padding: 2px 6px;
  font-size: 14px;
  color: var(--text-3);
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.15s, color 0.15s;
  border-radius: 4px;
}

.message:hover .reply-btn {
  opacity: 1;
}

.reply-btn:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

.reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border-right: 3px solid var(--primary);
  border-radius: 8px 0 0 8px;
  padding: 8px 12px;
  margin: 0 12px;
  animation: slideUp 0.2s ease-out;
}

.reply-preview.hidden {
  display: none;
}

.reply-preview-content {
  flex: 1;
  min-width: 0;
}

.reply-preview-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
}

.reply-preview-text {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-preview-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.reply-preview-close:hover {
  background: rgba(0,0,0,0.08);
  color: var(--error);
}

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

.msg-highlight {
  animation: highlightPulse 1.5s ease-out;
}

@keyframes highlightPulse {
  0%, 100% { background: transparent; }
  30% { background: rgba(99, 102, 241, 0.15); }
}

/* ═══════════════════════════════════════════════════════════════════
   File Upload Preview
   ═══════════════════════════════════════════════════════════════════ */

.file-preview {
  position: relative;
  max-width: 200px;
  margin-bottom: 8px;
}

.file-preview img {
  width: 100%;
  border-radius: var(--radius-xs);
}

.file-preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════════════
   Welcome Screen
   ═══════════════════════════════════════════════════════════════════ */

.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  gap: 16px;
}

.welcome-avatar {
  width: 80px;
  height: 80px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: white;
}

.welcome-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-1);
}

.welcome-message {
  font-size: 14px;
  color: var(--text-2);
  max-width: 280px;
}

.welcome-start-btn {
  margin-top: 8px;
  padding: 14px 32px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

.welcome-start-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.02);
}

.welcome-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.welcome-btn {
  padding: 10px 20px;
  background: var(--bg-1);
  border: 1px solid var(--primary);
  border-radius: 20px;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.welcome-btn:hover {
  background: var(--primary);
  color: white;
}

/* ═══════════════════════════════════════════════════════════════════
   PWA Install Banner
   ═══════════════════════════════════════════════════════════════════ */

.pwa-banner {
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
}

.pwa-banner-icon {
  width: 48px;
  height: 48px;
  background: var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.pwa-banner-text {
  flex: 1;
}

.pwa-banner-title {
  font-weight: 600;
  font-size: 14px;
}

.pwa-banner-desc {
  font-size: 12px;
  color: var(--text-2);
}

.pwa-banner-btns {
  display: flex;
  gap: 8px;
}

.pwa-banner-btn {
  padding: 8px 16px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  cursor: pointer;
  border: none;
}

.pwa-banner-btn.primary {
  background: var(--primary);
  color: white;
}

.pwa-banner-btn.ghost {
  background: none;
  color: var(--text-2);
}

/* ═══════════════════════════════════════════════════════════════════
   Support Mode
   ═══════════════════════════════════════════════════════════════════ */

.message.support {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border-radius: var(--radius);
  padding: 4px;
  margin: 8px;
}

.support-sender {
  font-size: 12px;
  font-weight: 600;
  color: #0e7490;
  margin-bottom: 4px;
  padding: 0 8px;
}

.support-active {
  color: #fff !important;
  font-weight: 600;
  animation: supportPulse 2s ease-in-out infinite;
}

@keyframes supportPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.message.support {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-radius: var(--radius);
  padding: 4px;
  margin: 8px;
}

.message.support .msg-bubble {
  background: #fff;
  border: 1px solid #bae6fd;
}

/* Support Exit Bar */
.support-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  border-bottom: none;
  box-shadow: 0 2px 8px rgba(14, 116, 144, 0.25);
}

.support-bar-text {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #fff;
  font-weight: 500;
}

.support-bar-icon {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.support-exit-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}

.support-exit-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: #fff;
}

.support-exit-btn svg {
  width: 14px;
  height: 14px;
}

/* ═══════════════════════════════════════════════════════════════════
   Responsive - Already mobile-first, add tablet/desktop if needed
   ═══════════════════════════════════════════════════════════════════ */

@media (min-width: 768px) {
  #widget-app {
    max-width: 420px;
    margin: 0 auto;
    height: 100vh;
    box-shadow: var(--shadow);
  }
}

/* Safe area for iPhone notch */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .chat-input {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* ═══════════════════════════════════════════════════════════════════
   TEMPLATE: Bubble - Rounded, soft, friendly
   ═══════════════════════════════════════════════════════════════════ */

body.template-bubble {
  --radius: 24px;
  --radius-sm: 20px;
  --radius-xs: 16px;
  --shadow: 0 8px 32px rgba(99, 102, 241, 0.15);
}

body.template-bubble .chat-header {
  border-radius: 24px 24px 0 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

body.template-bubble .header-avatar {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255,255,255,0.3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

body.template-bubble .message-bubble,
body.template-bubble .msg-bubble {
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

body.template-bubble .message.bot .message-bubble,
body.template-bubble .message.bot .msg-bubble {
  border-bottom-left-radius: 6px;
}

body.template-bubble .message.user .message-bubble,
body.template-bubble .message.user .msg-bubble {
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

body.template-bubble .input-row {
  border-radius: 30px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  border: none;
  background: var(--bg-1);
}

body.template-bubble .send-btn {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

body.template-bubble .welcome-avatar {
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

body.template-bubble .welcome-start-btn {
  border-radius: 30px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

@media (min-width: 768px) {
  body.template-bubble #widget-app {
    border-radius: 24px;
    margin: 20px auto;
    height: calc(100vh - 40px);
    box-shadow: 0 12px 48px rgba(99, 102, 241, 0.2);
  }
}

/* ═══════════════════════════════════════════════════════════════════
   TEMPLATE: Card - Sharp, corporate, prominent shadows
   ═══════════════════════════════════════════════════════════════════ */

body.template-card {
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --shadow: 0 10px 40px rgba(0,0,0,0.12);
  background: #e5e7eb;
}

body.template-card .chat-header {
  background: var(--primary);
  padding: 20px 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

body.template-card .header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: rgba(255,255,255,0.15);
}

body.template-card .header-menu-btn {
  border-radius: 8px;
}

body.template-card .message-bubble,
body.template-card .msg-bubble {
  border-radius: 8px;
  border: 1px solid var(--border);
}

body.template-card .message.bot .message-bubble,
body.template-card .message.bot .msg-bubble {
  border-radius: 8px;
  border-bottom-left-radius: 2px;
  background: #fff;
}

body.template-card .message.user .message-bubble,
body.template-card .message.user .msg-bubble {
  border-radius: 8px;
  border-bottom-right-radius: 2px;
  border: none;
}

body.template-card .input-row {
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

body.template-card .input-btn {
  border-radius: 6px;
}

body.template-card .send-btn {
  border-radius: 6px;
}

body.template-card .inline-btn {
  border-radius: 6px;
}

body.template-card .welcome-avatar {
  width: 72px;
  height: 72px;
  border-radius: 12px;
}

body.template-card .welcome-start-btn {
  border-radius: 8px;
}

body.template-card .welcome-btn {
  border-radius: 6px;
}

@media (min-width: 768px) {
  body.template-card #widget-app {
    border-radius: 12px;
    margin: 24px auto;
    height: calc(100vh - 48px);
    box-shadow: 0 16px 64px rgba(0,0,0,0.15);
    border: 1px solid var(--border);
  }
}

/* ═══════════════════════════════════════════════════════════════════
   TEMPLATE: Fullscreen - Modern, clean (default)
   ═══════════════════════════════════════════════════════════════════ */

body.template-fullscreen {
  /* Uses default CSS variables */
}

body.template-fullscreen .chat-header {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
}

@media (min-width: 768px) {
  body.template-fullscreen #widget-app {
    max-width: 100%;
    border-radius: 0;
    margin: 0;
    height: 100vh;
    box-shadow: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   TEMPLATE: Minimal - Flat, simple, no frills
   ═══════════════════════════════════════════════════════════════════ */

body.template-minimal {
  --radius: 4px;
  --radius-sm: 3px;
  --radius-xs: 2px;
  --shadow: none;
  --primary-light: var(--primary);
}

body.template-minimal .chat-header {
  background: var(--bg-1);
  color: var(--text-1);
  border-bottom: 2px solid var(--primary);
  padding: 12px 16px;
}

body.template-minimal .header-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 4px;
}

body.template-minimal .header-status::before {
  background: var(--primary);
}

body.template-minimal .header-menu-btn {
  background: transparent;
  color: var(--text-1);
  border-radius: 4px;
}

body.template-minimal .header-menu-btn:hover {
  background: var(--bg-3);
}

body.template-minimal .message-bubble,
body.template-minimal .msg-bubble {
  border-radius: 4px;
  box-shadow: none;
}

body.template-minimal .message.bot .message-bubble,
body.template-minimal .message.bot .msg-bubble {
  background: var(--bg-2);
  border-radius: 4px;
}

body.template-minimal .message.user .message-bubble,
body.template-minimal .message.user .msg-bubble {
  border-radius: 4px;
}

body.template-minimal .input-row {
  border-radius: 4px;
  border: 2px solid var(--border);
  background: var(--bg-1);
}

body.template-minimal .input-btn {
  border-radius: 4px;
}

body.template-minimal .send-btn {
  border-radius: 4px;
}

body.template-minimal .inline-btn {
  border-radius: 4px;
  border-width: 2px;
}

body.template-minimal .welcome-avatar {
  width: 64px;
  height: 64px;
  border-radius: 8px;
}

body.template-minimal .welcome-start-btn {
  border-radius: 4px;
  font-weight: 500;
}

body.template-minimal .welcome-btn {
  border-radius: 4px;
  border-width: 2px;
}

body.template-minimal .menu-btn {
  border-radius: 4px;
}

@media (min-width: 768px) {
  body.template-minimal #widget-app {
    max-width: 400px;
    margin: 0 auto;
    height: 100vh;
    box-shadow: none;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* ═══════════════════════════════════════════════════════════════════
   THEME: Site — Dark glass theme matching c4-ai.com main site
   Only applied via ?theme=site query parameter
   ═══════════════════════════════════════════════════════════════════ */

body.theme-site {
  --bg-1: #0a0a0a;
  --bg-2: #111;
  --bg-3: #1a1a1a;
  --text-1: #fff;
  --text-2: rgba(255,255,255,0.6);
  --text-3: rgba(255,255,255,0.35);
  --border: rgba(255,255,255,0.08);
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  background: #0a0a0a;
  font-family: 'Vazirmatn', system-ui, sans-serif;
}

body.theme-site .chat-header {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

body.theme-site .chat-messages {
  background: #0a0a0a;
}

body.theme-site .message.bot .message-bubble,
body.theme-site .message.bot .msg-bubble {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.14);
  color: #f0f0f0;
  font-size: 14.5px;
  line-height: 1.85;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body.theme-site .message.user .message-bubble,
body.theme-site .message.user .msg-bubble {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}

/* Scrollbar for site theme */
body.theme-site .chat-messages::-webkit-scrollbar {
  width: 6px;
}
body.theme-site .chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
body.theme-site .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(99,102,241,0.35);
  border-radius: 3px;
}
body.theme-site .chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(99,102,241,0.55);
}
body.theme-site .chat-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(99,102,241,0.35) transparent;
}

body.theme-site .chat-input {
  background: #111;
  border-top: 1px solid rgba(255,255,255,0.08);
}

body.theme-site .input-row {
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.1);
}

body.theme-site #message-input {
  background: transparent;
  color: #fff;
}

body.theme-site #message-input::placeholder {
  color: rgba(255,255,255,0.35);
}

body.theme-site .input-btn {
  color: rgba(255,255,255,0.5);
}

body.theme-site .input-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.07);
}

body.theme-site .send-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}

body.theme-site .header-name {
  color: #fff;
}

body.theme-site .header-status {
  color: rgba(255,255,255,0.7);
}

body.theme-site .header-menu-btn {
  color: rgba(255,255,255,0.7);
}

body.theme-site .menu-panel {
  background: #111;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

body.theme-site .menu-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #fff;
}

body.theme-site .menu-btn:hover {
  background: rgba(255,255,255,0.07);
}

body.theme-site .inline-btn {
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.3);
  color: #818cf8;
}

body.theme-site .inline-btn:hover {
  background: rgba(99,102,241,0.25);
}

body.theme-site .widget-loading,
body.theme-site .widget-error {
  background: #0a0a0a;
  color: rgba(255,255,255,0.6);
}

body.theme-site .welcome-screen {
  background: #0a0a0a;
}

body.theme-site .welcome-title {
  color: #fff;
}

body.theme-site .welcome-subtitle {
  color: rgba(255,255,255,0.6);
}

body.theme-site .welcome-start-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}

body.theme-site .typing-indicator span {
  background: rgba(255,255,255,0.3);
}

body.theme-site .msg-time {
  color: rgba(255,255,255,0.3);
}

body.theme-site .reply-preview {
  background: #1a1a1a;
  border-right-color: #6366f1;
  color: rgba(255,255,255,0.6);
}

body.theme-site .support-bar {
  background: rgba(99,102,241,0.1);
  border-bottom: 1px solid rgba(99,102,241,0.2);
}
