/* ============================================
   SuperChat Widget - Style Kodee/Hostinger
   ============================================ */

:root {
  --sc-primary: #35668d;
  --sc-primary-hover: #2a5170;
  --sc-cta: #fa3939;
  --sc-cta-hover: #e02020;
  --sc-text-on-primary: #ffffff;
  --sc-bg: #ffffff;
  --sc-bg-chat: #f4f5f7;
  --sc-text: #132231;
  --sc-text-light: #6b7280;
  --sc-border: #e5e7eb;
  --sc-user-bubble: #35668d;
  --sc-bot-bubble: #ffffff;
  --sc-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  --sc-radius: 16px;
  --sc-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Reset */
.sc-widget * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--sc-font);
}

/* ---- Bouton flottant ---- */
.sc-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--sc-primary);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background 0.2s ease;
}

.sc-launcher {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .sc-launcher:hover {
    transform: scale(1.08);
    background: var(--sc-primary-hover);
  }
}

.sc-launcher > * {
  pointer-events: none;
}

.sc-launcher svg {
  width: 28px;
  height: 28px;
  fill: var(--sc-text-on-primary);
  transition: transform 0.3s ease, opacity 0.2s ease;
}

.sc-launcher .sc-icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.sc-launcher.sc-open .sc-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.sc-launcher.sc-open .sc-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Badge notification */
.sc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
  display: none;
}

.sc-badge.sc-visible {
  display: block;
  animation: sc-pulse 2s infinite;
}

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

/* ---- Fenêtre de chat ---- */
.sc-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--sc-bg);
  border-radius: var(--sc-radius);
  box-shadow: var(--sc-shadow);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.sc-window.sc-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
  touch-action: pan-y;
  -ms-touch-action: pan-y;
}

/* ---- Header ---- */
.sc-header {
  background: var(--sc-primary);
  color: var(--sc-text-on-primary);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sc-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Avatar Font Awesome icon */
.sc-avatar-fa {
  font-size: 20px;
  color: var(--sc-text-on-primary);
}

/* Avatar image uploadée */
.sc-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.sc-header-info {
  flex: 1;
}

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

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

.sc-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
}

.sc-header-close {
  background: none;
  border: none;
  color: var(--sc-text-on-primary);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.sc-header-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.sc-header-close svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ---- Zone messages ---- */
.sc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--sc-bg-chat);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sc-messages::-webkit-scrollbar {
  width: 4px;
}

.sc-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

/* ---- Bulles de message ---- */
.sc-msg {
  max-width: 85%;
  animation: sc-fadeIn 0.3s ease;
}

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

.sc-msg-bot {
  align-self: flex-start;
}

.sc-msg-user {
  align-self: flex-end;
}

.sc-msg-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
}

.sc-msg-bot .sc-msg-bubble {
  background: var(--sc-bot-bubble);
  color: var(--sc-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.sc-msg-user .sc-msg-bubble {
  background: var(--sc-user-bubble);
  color: var(--sc-text-on-primary);
  border-bottom-right-radius: 4px;
}

/* Markdown dans les bulles */
.sc-msg-bubble strong {
  font-weight: 600;
}

.sc-msg-bubble ul, .sc-msg-bubble ol {
  padding-left: 16px;
  margin: 4px 0;
}

.sc-msg-bubble li {
  margin: 2px 0;
}

/* ---- Boutons rapides ---- */
.sc-quick-buttons {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  padding: 4px 0 !important;
  margin: 0 !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.sc-quick-btn {
  background: var(--sc-bg) !important;
  color: var(--sc-primary) !important;
  border: 1.5px solid var(--sc-primary) !important;
  border-radius: 20px !important;
  padding: 8px 16px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: all 0.2s ease;
  white-space: nowrap !important;
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  line-height: normal !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  min-height: unset !important;
  height: auto !important;
  width: auto !important;
  margin: 0 !important;
}

.sc-quick-btn:hover {
  background: var(--sc-primary) !important;
  color: var(--sc-text-on-primary) !important;
}

.sc-quick-btn.sc-cta {
  background: var(--sc-cta) !important;
  color: var(--sc-text-on-primary) !important;
  border-color: var(--sc-cta) !important;
}

.sc-quick-btn.sc-cta:hover {
  background: var(--sc-cta-hover) !important;
  border-color: var(--sc-cta-hover) !important;
}

/* CTA de conversation (pas welcome, pas tags) : animation + style spécial */
.sc-quick-btn.sc-cta-action {
  animation: sc-ctaDrop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

@keyframes sc-ctaDrop {
  0% { opacity: 0; transform: translateY(-20px) scale(0.9); }
  60% { opacity: 1; transform: translateY(3px) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 480px) {
  .sc-quick-btn.sc-cta-action {
    padding: 11px 20px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border-radius: 24px !important;
    width: 100% !important;
    text-align: center !important;
    box-shadow: 0 3px 10px rgba(250, 57, 57, 0.3) !important;
  }
}

.sc-action-label {
  width: 100% !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  color: #9ca3af !important;
  margin-bottom: -4px !important;
}

.sc-quick-btn-sm {
  font-size: 11px !important;
  padding: 5px 10px !important;
  border-radius: 16px !important;
  white-space: nowrap !important;
}

.sc-article-tags {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
  padding: 4px 0 !important;
}

/* ---- Carte Open Graph (article) ---- */
.sc-og-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--sc-border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--sc-bg);
  cursor: pointer;
  transition: box-shadow 0.2s ease;
  text-decoration: none;
  color: inherit;
  margin-top: 8px;
  max-width: 280px;
}

.sc-og-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.sc-og-card-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #e5e7eb;
}

.sc-og-card-body {
  padding: 10px 12px;
}

.sc-og-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--sc-text);
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sc-og-card-desc {
  font-size: 11px;
  color: var(--sc-text-light);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sc-og-card-domain {
  font-size: 10px;
  color: var(--sc-text-light);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- Lien dans les bulles ---- */
.sc-msg-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--sc-primary);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  transition: opacity 0.2s;
}

.sc-msg-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* ---- Suggestion d'article (bulle avec contour) ---- */
.sc-article-suggest {
  border: 1.5px solid var(--sc-primary);
  color: var(--sc-primary);
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: background 0.2s, border-color 0.2s;
}

.sc-article-suggest:hover {
  background: rgba(53, 102, 141, 0.06);
  border-color: var(--sc-primary-hover);
}

/* ---- Input zone ---- */
.sc-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--sc-border);
  background: var(--sc-bg);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sc-input {
  flex: 1;
  border: 1.5px solid var(--sc-border);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  background: var(--sc-bg-chat);
  color: var(--sc-text);
  -webkit-appearance: none;
}

.sc-input:focus {
  border-color: var(--sc-primary);
}

.sc-input::placeholder {
  color: #9ca3af;
}

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

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

.sc-send-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

.sc-send-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--sc-text-on-primary);
}

/* ---- Typing indicator ---- */
.sc-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
}

.sc-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  animation: sc-typing 1.4s infinite ease-in-out;
}

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

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

/* ---- Powered by ---- */
.sc-powered {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: #9ca3af;
  background: var(--sc-bg);
}

.sc-powered a {
  color: #9ca3af;
  text-decoration: none;
}

.sc-powered a:hover {
  color: var(--sc-text-light);
}

/* ---- Formulaire devis in-chat ---- */
/* Le message contenant le formulaire prend toute la largeur */
.sc-msg-bot:has(.sc-devis-form) {
  width: 100%;
  max-width: 100%;
}

.sc-devis-form {
  background: var(--sc-bg);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--sc-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  animation: sc-fadeIn 0.3s ease;
}

.sc-devis-form h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--sc-text);
  margin: 0 0 12px 0;
  text-align: center;
}

.sc-devis-field {
  position: relative;
  margin-bottom: 8px;
}

.sc-devis-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  fill: var(--sc-text);
  pointer-events: none;
  z-index: 1;
}

.sc-devis-field select,
.sc-devis-field input {
  width: 100% !important;
  height: 40px !important;
  padding: 0 12px 0 34px !important;
  border: 1.5px solid var(--sc-border) !important;
  border-radius: 8px !important;
  font-size: 15px !important;
  font-family: var(--sc-font) !important;
  color: var(--sc-text) !important;
  background: var(--sc-bg) !important;
  outline: none !important;
  transition: border-color 0.2s;
  box-sizing: border-box !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  margin: 0 !important;
  min-height: unset !important;
}

.sc-devis-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236b7280' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.sc-devis-field input:focus,
.sc-devis-field select:focus {
  border-color: var(--sc-primary);
}

.sc-devis-field input::placeholder {
  color: #9ca3af;
}

.sc-devis-tel {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.sc-devis-tel .sc-tel-prefix {
  padding: 0 8px;
  height: 40px;
  line-height: 40px;
  background: #f4f5f7;
  border: 1.5px solid var(--sc-border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--sc-text);
  flex-shrink: 0;
}

.sc-devis-tel input {
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid var(--sc-border);
  border-radius: 8px;
  font-size: 15px;
  font-family: var(--sc-font);
  color: var(--sc-text);
  outline: none;
  box-sizing: border-box;
}

.sc-devis-tel input:focus {
  border-color: var(--sc-primary);
}

.sc-devis-submit {
  width: 100%;
  height: 44px;
  background: var(--sc-cta);
  color: var(--sc-text-on-primary);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--sc-font);
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

.sc-devis-submit:hover {
  background: var(--sc-cta-hover);
}

.sc-devis-legal {
  font-size: 10px;
  color: var(--sc-text-light);
  margin-top: 8px;
  line-height: 1.3;
}

.sc-devis-legal a {
  color: var(--sc-primary);
  text-decoration: none;
}

/* Captcha anti-spam */
.sc-devis-captcha {
  background: #f8f9fa;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--sc-border);
  margin-bottom: 8px;
  animation: sc-fadeIn 0.3s ease;
}

.sc-captcha-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--sc-text);
}

.sc-captcha-body {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sc-captcha-opt {
  flex: 1;
  cursor: pointer;
}

.sc-captcha-opt input {
  display: none;
}

.sc-captcha-opt span {
  display: block;
  padding: 6px 8px;
  background: white;
  border: 1px solid var(--sc-border);
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}

.sc-captcha-opt span:hover {
  border-color: #adb5bd;
  background: #f8f9fa;
}

.sc-captcha-opt input:checked + span {
  background: #0db1f6;
  border-color: #0db1f6;
  color: white;
  font-weight: 600;
}

/* ---- Responsive mobile ---- */
@media (max-width: 480px) {
  .sc-window.sc-open {
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .sc-launcher {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }
}

/* ---- Ecran consentement RGPD (bloquant) ---- */
.sc-consent-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  margin: auto 0;
  animation: sc-fadeIn 0.4s ease;
}

.sc-consent-icon {
  font-size: 44px;
  margin-bottom: 16px;
  line-height: 1;
  color: var(--sc-primary);
}

.sc-consent-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 8px;
}

.sc-consent-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--sc-text);
  margin-bottom: 20px;
}

.sc-consent-text a {
  color: var(--sc-primary);
  text-decoration: underline;
}

.sc-consent-text a:hover {
  color: var(--sc-primary-hover);
}

.sc-consent-accept {
  background: var(--sc-primary);
  color: var(--sc-text-on-primary);
  border: none;
  border-radius: 24px;
  padding: 10px 32px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  font-family: var(--sc-font);
}

.sc-consent-accept:hover {
  background: var(--sc-primary-hover);
  transform: scale(1.03);
}

/* ---- Mode hors-ligne ---- */
.sc-launcher-offline {
  background: #999 !important;
}

.sc-launcher-offline:hover {
  background: #888 !important;
}

.sc-header-status-offline::before {
  background: #999 !important;
}

.sc-offline-message {
  text-align: center;
  padding: 24px 20px;
  color: var(--sc-text);
  font-size: 14px;
  line-height: 1.6;
  background: var(--sc-bg);
  border-radius: 12px;
  margin: 16px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.sc-offline-message p {
  margin: 0 0 16px 0;
}

.sc-offline-contact {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.sc-offline-contact a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--sc-bg-chat);
  border: 1px solid var(--sc-border);
  border-radius: 8px;
  color: var(--sc-text);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s;
}

.sc-offline-contact a:hover {
  background: var(--sc-border);
}

.sc-input-disabled {
  color: #999 !important;
  cursor: not-allowed !important;
  background: #f0f0f0 !important;
  text-align: center;
  font-style: italic;
  border: none !important;
  user-select: none;
  pointer-events: none;
}

/* ---- B6 — Timestamps ---- */
.sc-msg-time {
  display: block;
  font-size: 10px;
  color: #9ca3af;
  margin-top: 2px;
  line-height: 1;
}

.sc-msg-user .sc-msg-time {
  text-align: right;
}

/* ---- B4 — Message système (warning timeout) ---- */
.sc-msg-system {
  align-self: center;
  max-width: 90%;
  animation: sc-fadeIn 0.3s ease;
}

.sc-msg-system-text {
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 14px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid #fde68a;
}

/* ---- Sous-titre bienvenue ---- */
.sc-welcome-subtitle {
  color: #8899a6;
  font-size: 12px;
  line-height: 1.4;
  padding: 2px 0 4px 0;
}

/* ---- B7 — Scroll-to-bottom button ---- */
.sc-scroll-btn {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sc-bg);
  border: 1px solid var(--sc-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: opacity 0.2s;
}

.sc-scroll-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--sc-text-light);
}

.sc-scroll-btn.sc-visible {
  display: flex;
}

.sc-scroll-btn:hover {
  background: var(--sc-bg-chat);
}

/* ---- B8 — Sound toggle ---- */
.sc-sound-toggle {
  background: none;
  border: none;
  color: var(--sc-text-on-primary);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  opacity: 0.7;
}

.sc-sound-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  opacity: 1;
}

.sc-sound-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ---- B5 — Retry button ---- */
.sc-retry-btn {
  border-color: #f59e0b !important;
  color: #d97706 !important;
}

.sc-retry-btn:hover {
  background: #f59e0b !important;
  color: white !important;
}
