/* ============================================
   Valentina Widget — valentin.love
   Chat widget · Vanilla CSS · No dependencies
   ============================================ */

.valentina-widget {
  --vw-charbon: #1B1B1A;
  --vw-ivoire: #FCFBFA;
  --vw-ivoire-2: #F0EDE6;
  --vw-dore: #956124;
  --vw-dore-hover: #7A4F1C;
  --vw-dore-light: rgba(149, 97, 36, 0.08);
  --vw-gris: #595654;
  --vw-blanc: #FFFFFF;
  --vw-erreur: #9B3A3A;
  --vw-radius: 16px;
  --vw-shadow: 0 8px 32px rgba(27, 27, 26, 0.18);
  --vw-font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --vw-font-serif: 'Playfair Display', Georgia, serif;
}

.valentina-widget,
.valentina-widget *,
.valentina-widget *::before,
.valentina-widget *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.valentina-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: var(--vw-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--vw-charbon);
}

/* ── TRIGGER BUTTON ─────────────────────────── */

.vw-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 8px 8px;
  background: var(--vw-charbon);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: var(--vw-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.vw-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(27, 27, 26, 0.25);
}

.vw-trigger-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--vw-dore);
}

.vw-trigger-name {
  color: var(--vw-blanc);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
}

.vw-trigger-badge {
  position: absolute;
  top: -4px;
  left: 32px;
  width: 20px;
  height: 20px;
  background: var(--vw-erreur);
  color: var(--vw-blanc);
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--vw-blanc);
  animation: vw-pulse 2s ease-in-out infinite;
}

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

/* ── CHAT WINDOW ────────────────────────────── */

.vw-window {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 370px;
  max-height: 500px;
  background: var(--vw-charbon);
  border-radius: var(--vw-radius);
  box-shadow: var(--vw-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: vw-slide-up 0.3s ease-out;
}

@keyframes vw-slide-up {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.vw-hidden { display: none !important; }

/* ── HEADER ─────────────────────────────────── */

.vw-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--vw-charbon);
  flex-shrink: 0;
}

.vw-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--vw-dore);
  flex-shrink: 0;
}

.vw-header-info { flex: 1; min-width: 0; }

.vw-header-name {
  color: var(--vw-blanc);
  font-family: var(--vw-font-serif);
  font-size: 17px;
  font-weight: 600;
}

.vw-header-sub {
  color: var(--vw-dore);
  font-size: 12px;
  font-weight: 500;
  opacity: 0.9;
}

.vw-header-close {
  background: none;
  border: none;
  color: var(--vw-blanc);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.vw-header-close:hover { background: rgba(255, 255, 255, 0.1); }
.vw-header-close svg { width: 20px; height: 20px; }

/* ── MESSAGES AREA ──────────────────────────── */

.vw-messages {
  overflow-y: auto;
  padding: 18px 16px;
  background: var(--vw-ivoire);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--vw-ivoire-2) transparent;
  min-height: 0;
}

.vw-messages::-webkit-scrollbar { width: 4px; }
.vw-messages::-webkit-scrollbar-thumb { background: var(--vw-ivoire-2); border-radius: 4px; }

/* ── BUBBLES ────────────────────────────────── */

.vw-bubble {
  max-width: 85%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  animation: vw-fade-in 0.25s ease-out;
}

@keyframes vw-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.vw-bubble--bot {
  background: var(--vw-ivoire-2);
  color: var(--vw-charbon);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.vw-bubble--user {
  background: var(--vw-dore);
  color: var(--vw-blanc);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* ── QCM CHOICE BUTTONS ────────────────────── */

.vw-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-end;
  justify-content: flex-end;
  max-width: 95%;
  animation: vw-fade-in 0.3s ease-out;
}

.vw-choice-btn {
  background: var(--vw-blanc);
  color: var(--vw-dore);
  border: 1.5px solid var(--vw-dore);
  border-radius: 22px;
  padding: 9px 18px;
  font-family: var(--vw-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  line-height: 1.3;
  white-space: nowrap;
}

.vw-choice-btn:hover:not(:disabled) {
  background: var(--vw-dore);
  color: var(--vw-blanc);
  border-color: var(--vw-dore);
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(149, 97, 36, 0.25);
}

.vw-choice-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.vw-choice-btn.vw-choice-selected {
  background: var(--vw-dore);
  color: var(--vw-blanc);
  border-color: var(--vw-dore);
  opacity: 1;
}

.vw-choice-btn.vw-choice-used:not(.vw-choice-selected) {
  display: none;
}

/* ── ACTION CARDS ───────────────────────────── */

.vw-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-start;
  max-width: 92%;
  animation: vw-fade-in 0.3s ease-out 0.15s both;
}

.vw-action-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 14px;
  text-decoration: none;
  font-family: var(--vw-font);
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  border: none;
  text-align: left;
  line-height: 1.4;
}

.vw-action-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.vw-action-card--primary {
  background: var(--vw-dore);
  color: var(--vw-blanc);
}

.vw-action-card--primary:hover {
  background: var(--vw-dore-hover);
}

.vw-action-card--secondary {
  background: var(--vw-blanc);
  color: var(--vw-charbon);
  border: 1.5px solid var(--vw-ivoire-2);
}

.vw-action-card--secondary:hover {
  border-color: var(--vw-dore);
}

.vw-action-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.vw-action-card--primary .vw-action-icon { background: rgba(255, 255, 255, 0.2); }
.vw-action-card--secondary .vw-action-icon { background: var(--vw-ivoire-2); }
.vw-action-icon svg { width: 16px; height: 16px; }
.vw-action-card--secondary .vw-action-icon svg { color: var(--vw-dore); }

.vw-actions-note {
  font-size: 11px;
  color: var(--vw-gris);
  align-self: flex-start;
  padding-left: 4px;
  max-width: 90%;
  line-height: 1.5;
  animation: vw-fade-in 0.3s ease-out 0.3s both;
}

/* ── INPUT AREA ─────────────────────────────── */

.vw-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--vw-ivoire);
  border-top: none;
  flex-shrink: 0;
}

.vw-input {
  flex: 1;
  border: 1.5px solid var(--vw-ivoire-2);
  border-radius: 24px;
  padding: 10px 16px;
  font-family: var(--vw-font);
  font-size: 14px;
  color: var(--vw-charbon);
  background: var(--vw-blanc);
  outline: none;
  transition: border-color 0.15s ease;
  min-width: 0;
}

.vw-input::placeholder { color: var(--vw-gris); opacity: 0.6; }
.vw-input:focus { border-color: var(--vw-dore); }

.vw-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--vw-dore);
  color: var(--vw-blanc);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.vw-send-btn:hover { background: var(--vw-dore-hover); transform: scale(1.05); }
.vw-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.vw-send-btn svg { width: 18px; height: 18px; }

/* ── TYPING INDICATOR ───────────────────────── */

.vw-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
}

.vw-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--vw-gris);
  opacity: 0.4;
  animation: vw-typing-bounce 1.2s ease-in-out infinite;
}

.vw-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.vw-typing-dot:nth-child(3) { animation-delay: 0.3s; }

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

/* ── RESPONSIVE ─────────────────────────────── */

@media (max-width: 480px) {
  .valentina-widget {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }

  .vw-window {
    width: auto;
    left: 0;
    right: 0;
    max-height: calc(100dvh - 80px);
    border-radius: 14px;
  }

  .vw-trigger {
    padding: 6px 14px 6px 6px;
  }

  .vw-trigger-avatar {
    width: 38px;
    height: 38px;
  }

  .vw-choice-btn {
    white-space: normal;
  }
}
