/**
 * Serimi Live Chat Widget — CSS Styles
 * Mobile-first, clean design. No framework dependencies.
 */

/* ============================================================
   CSS Variables
   ============================================================ */
:root {
  --sl-primary: #2563eb;
  --sl-primary-dark: #1d4ed8;
  --sl-bg: #ffffff;
  --sl-bg-secondary: #f8fafc;
  --sl-text: #1e293b;
  --sl-text-light: #64748b;
  --sl-border: #e2e8f0;
  --sl-shadow: 0 4px 24px rgba(0,0,0,0.12);
  --sl-radius: 12px;
  --sl-radius-sm: 8px;
  --sl-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ============================================================
   Widget Container
   ============================================================ */
#serimi-livechat-widget {
  position: fixed;
  z-index: 999999;
  font-family: var(--sl-font);
  font-size: 14px;
  line-height: 1.5;
}

.sl-widget-bottom-right {
  bottom: 20px;
  right: 20px;
}

.sl-widget-bottom-left {
  bottom: 20px;
  left: 20px;
}

/* ============================================================
   Chat Bubble Button
   ============================================================ */
.sl-chat-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sl-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: sl-pulse 2s infinite;
}

.sl-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  background: var(--sl-primary-dark);
}

@keyframes sl-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(37,99,235,0.3); }
  50% { box-shadow: 0 4px 24px rgba(37,99,235,0.5); }
}

/* ============================================================
   Chat Panel
   ============================================================ */
.sl-chat-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 360px;
  max-height: 560px;
  background: var(--sl-bg);
  border-radius: var(--sl-radius);
  box-shadow: var(--sl-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--sl-border);
}

.sl-widget-bottom-left .sl-chat-panel {
  right: auto;
  left: 0;
}

@media (max-width: 420px) {
  .sl-chat-panel {
    width: calc(100vw - 40px);
    max-height: calc(100vh - 120px);
    bottom: 70px;
    right: 0;
  }
}

/* ============================================================
   Chat Header
   ============================================================ */
.sl-chat-header {
  background: var(--sl-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sl-chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
}

.sl-chat-icon {
  font-size: 20px;
}

.sl-chat-actions {
  display: flex;
  gap: 4px;
}

.sl-btn-icon {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.sl-btn-icon:hover {
  opacity: 1;
  background: rgba(255,255,255,0.15);
}

.sl-btn-end-session {
  font-size: 14px;
  opacity: 0.7;
}

.sl-btn-end-session:hover {
  opacity: 1;
  background: rgba(255,80,80,0.3);
}

/* ============================================================
   Messages Area
   ============================================================ */
.sl-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  background: var(--sl-bg-secondary);
}

.sl-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--sl-radius-sm);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: sl-fadeIn 0.3s ease;
}

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

.sl-message-user {
  align-self: flex-end;
  background: var(--sl-primary);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.sl-message-bot {
  align-self: flex-start;
  background: #fff;
  color: var(--sl-text);
  border: 1px solid var(--sl-border);
  border-bottom-left-radius: 2px;
}

.sl-message-bot a {
  color: var(--sl-primary);
  text-decoration: underline;
  font-weight: 500;
}

.sl-message-bot a:hover {
  color: var(--sl-primary-dark);
}

.sl-message-user a {
  color: #fff;
  text-decoration: underline;
}

/* Typing indicator */
.sl-typing-dots {
  display: inline-flex;
  gap: 3px;
  padding: 4px 0;
}

.sl-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sl-text-light);
  animation: sl-bounce 1.4s infinite ease-in-out;
}

.sl-typing-dots span:nth-child(1) { animation-delay: 0s; }
.sl-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.sl-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sl-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* ============================================================
   Input Area
   ============================================================ */
.sl-chat-input-area {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--sl-border);
  background: #fff;
}

.sl-chat-input {
  flex: 1;
  border: 1px solid var(--sl-border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  font-family: var(--sl-font);
  transition: border-color 0.15s;
}

.sl-chat-input:focus {
  border-color: var(--sl-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.sl-send-btn {
  background: var(--sl-primary);
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 8px;
  flex-shrink: 0;
  transition: background 0.15s;
}

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

/* ============================================================
   Footer
   ============================================================ */
.sl-chat-footer {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--sl-text-light);
  border-top: 1px solid var(--sl-border);
  text-align: center;
}

.sl-chat-footer a {
  color: var(--sl-primary);
  text-decoration: none;
  font-weight: 500;
}

.sl-chat-footer a:hover {
  text-decoration: underline;
}

/* ============================================================
   Badge (unread counter)
   ============================================================ */
.sl-bubble-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 2px 6px rgba(239,68,68,0.4);
}

/* ============================================================
   Lead Capture Form
   ============================================================ */
.sl-lead-form {
  padding: 12px;
  border-top: 1px solid var(--sl-border);
  background: #f0f9ff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sl-lead-form-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--sl-text);
  margin-bottom: 2px;
}

.sl-lead-input {
  border: 1px solid var(--sl-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  font-family: var(--sl-font);
  transition: border-color 0.15s;
}

.sl-lead-input:focus {
  border-color: var(--sl-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.sl-lead-submit {
  background: var(--sl-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  align-self: flex-end;
}

.sl-lead-submit:hover {
  background: var(--sl-primary-dark);
}

/* ============================================================
   Actions Row (Live Chat button)
   ============================================================ */
.sl-actions-row {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--sl-border);
  background: #fff;
}

.sl-action-btn {
  flex: 1;
  background: #fff;
  border: 1px solid var(--sl-primary);
  color: var(--sl-primary);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.sl-action-btn:hover {
  background: var(--sl-primary);
  color: #fff;
}

/* ============================================================
   Branding
   ============================================================ */
.sl-branding {
  padding: 6px 12px;
  font-size: 10px;
  color: var(--sl-text-light);
  text-align: center;
  border-top: 1px solid var(--sl-border);
}

.sl-branding a {
  color: var(--sl-primary);
  text-decoration: none;
  font-weight: 600;
}

/* ============================================================
   Markdown rendering in messages
   ============================================================ */
.sl-message-bot a {
  color: var(--sl-primary);
  text-decoration: underline;
}

.sl-message-bot code {
  background: var(--sl-bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}

.sl-message-bot strong {
  font-weight: 700;
}

.sl-message-bot em {
  font-style: italic;
}

/* ============================================================
   No-animate variant (for restored messages)
   ============================================================ */
.sl-no-animate {
  animation: none !important;
}
