/* ═══════════════════════════════════════════════
 *  RNF Rosy Helper v2.0 — Front CSS
 *  Design System Rose&Fly (DA RAF)
 * ═══════════════════════════════════════════════ */

:root {
  --rnf-rosy-brand: #8B2252;
  --rnf-rosy-accent: #B8956A;
  --rnf-rosy-nude: #F9F1EE;
  --rnf-rosy-white: #FFFFFF;
  --rnf-rosy-text: #333333;
  --rnf-rosy-text-light: #888888;
  --rnf-rosy-border: rgba(139, 34, 82, 0.1);
  --rnf-rosy-shadow: 0 8px 32px rgba(139, 34, 82, 0.15);
  --rnf-rosy-shadow-lg: 0 16px 48px rgba(139, 34, 82, 0.2);
  --rnf-rosy-radius: 16px;
  --rnf-rosy-radius-sm: 12px;
  --rnf-rosy-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --rnf-rosy-font: 'DM Sans', 'Nunito Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --rnf-rosy-font-display: 'Playfair Display', 'DM Serif Display', serif;
}

/* ── Reset scope ─────────────────────────────── */
.rnf-rosy-root,
.rnf-rosy-root * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.rnf-rosy-root {
  font-family: var(--rnf-rosy-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--rnf-rosy-text);
  -webkit-font-smoothing: antialiased;
}

/* ── FAB (Floating Action Button) ────────────── */
.rnf-rosy-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99998;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--rnf-rosy-brand), #a14b68);
  color: #fff;
  border: none;
  padding: 10px 18px 10px 10px;
  border-radius: 999px;
  box-shadow: var(--rnf-rosy-shadow);
  cursor: pointer;
  transition: var(--rnf-rosy-transition);
  animation: rnf-rosy-fab-pulse 3s ease-in-out infinite;
}
.rnf-rosy-fab:hover {
  transform: translateY(-2px);
  box-shadow: var(--rnf-rosy-shadow-lg);
}
.rnf-rosy-fab-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 2px solid rgba(255,255,255,0.3);
}
.rnf-rosy-fab-label {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.rnf-rosy-fab-hidden {
  transform: scale(0) translateY(20px);
  opacity: 0;
  pointer-events: none;
}

@keyframes rnf-rosy-fab-pulse {
  0%, 100% { box-shadow: var(--rnf-rosy-shadow); }
  50% { box-shadow: 0 8px 32px rgba(139, 34, 82, 0.3), 0 0 0 8px rgba(139, 34, 82, 0.06); }
}

/* ── Widget panel ────────────────────────────── */
.rnf-rosy-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99999;
  width: 400px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--rnf-rosy-white);
  border-radius: var(--rnf-rosy-radius);
  box-shadow: var(--rnf-rosy-shadow-lg);
  border: 1px solid var(--rnf-rosy-border);
  overflow: hidden;
  transition: var(--rnf-rosy-transition);
  transform-origin: bottom right;
}
.rnf-rosy-closed {
  transform: scale(0.8) translateY(20px);
  opacity: 0;
  pointer-events: none;
}
.rnf-rosy-open {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ── Inline position ─────────────────────────── */
.rnf-rosy-pos-inline .rnf-rosy-widget {
  position: relative;
  right: auto;
  bottom: auto;
  margin: 0 auto;
}
.rnf-rosy-pos-inline .rnf-rosy-fab { display: none; }

/* ── Header ──────────────────────────────────── */
.rnf-rosy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--rnf-rosy-brand), #a14b68);
  color: #fff;
  flex-shrink: 0;
}
.rnf-rosy-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rnf-rosy-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 2px solid rgba(255,255,255,0.3);
}
.rnf-rosy-name {
  font-family: var(--rnf-rosy-font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.rnf-rosy-status {
  font-size: 12px;
  opacity: 0.85;
}
.rnf-rosy-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--rnf-rosy-transition);
}
.rnf-rosy-close:hover {
  background: rgba(255,255,255,0.3);
}

/* ── Body (messages) ─────────────────────────── */
.rnf-rosy-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--rnf-rosy-nude);
  scroll-behavior: smooth;
  min-height: 200px;
  max-height: 55vh;
}
.rnf-rosy-body::-webkit-scrollbar { width: 4px; }
.rnf-rosy-body::-webkit-scrollbar-thumb { background: rgba(139,34,82,0.2); border-radius: 4px; }

/* ── Message bubbles ─────────────────────────── */
.rnf-rosy-msg {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.rnf-rosy-msg-visible {
  opacity: 1;
  transform: translateY(0);
}
.rnf-rosy-msg-assistant {
  align-items: flex-start;
}
.rnf-rosy-msg-user {
  justify-content: flex-end;
}
.rnf-rosy-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
}
.rnf-rosy-bubble {
  padding: 10px 14px;
  border-radius: var(--rnf-rosy-radius-sm);
  font-size: 14px;
  line-height: 1.5;
  max-width: 85%;
  word-break: break-word;
}
.rnf-rosy-msg-assistant .rnf-rosy-bubble {
  background: var(--rnf-rosy-white);
  border: 1px solid var(--rnf-rosy-border);
  border-top-left-radius: 4px;
}
.rnf-rosy-msg-user .rnf-rosy-bubble {
  background: linear-gradient(135deg, var(--rnf-rosy-brand), #a14b68);
  color: #fff;
  border-top-right-radius: 4px;
}
.rnf-rosy-bubble a {
  color: var(--rnf-rosy-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rnf-rosy-msg-user .rnf-rosy-bubble a {
  color: #fff;
}
.rnf-rosy-bubble strong {
  font-weight: 600;
}

/* ── Actions (quick replies) ─────────────────── */
.rnf-rosy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px 36px;
}
.rnf-rosy-action-btn {
  background: var(--rnf-rosy-white);
  border: 1.5px solid var(--rnf-rosy-brand);
  color: var(--rnf-rosy-brand);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--rnf-rosy-transition);
  white-space: nowrap;
}
.rnf-rosy-action-btn:hover {
  background: var(--rnf-rosy-brand);
  color: #fff;
}

/* ── Product grid ────────────────────────────── */
.rnf-rosy-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 10px 0 12px 0;
}
.rnf-rosy-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rnf-rosy-border);
  border-radius: var(--rnf-rosy-radius-sm);
  overflow: hidden;
  text-decoration: none;
  color: var(--rnf-rosy-text);
  background: var(--rnf-rosy-white);
  transition: var(--rnf-rosy-transition);
}
.rnf-rosy-card:hover {
  box-shadow: 0 4px 16px rgba(139, 34, 82, 0.12);
  transform: translateY(-2px);
}
.rnf-rosy-card-img-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f6f2f0;
}
.rnf-rosy-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}
.rnf-rosy-card:hover img {
  transform: scale(1.05);
}
.rnf-rosy-card-badges {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rnf-rosy-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.rnf-rosy-badge-sale {
  background: var(--rnf-rosy-accent);
  color: #fff;
}
.rnf-rosy-badge-oos {
  background: #ccc;
  color: #666;
}
.rnf-rosy-card-body {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rnf-rosy-card-title {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rnf-rosy-card-rating {
  font-size: 11px;
  color: var(--rnf-rosy-accent);
  letter-spacing: 1px;
}
.rnf-rosy-card-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--rnf-rosy-brand);
}
.rnf-rosy-card-price del {
  color: #999;
  font-weight: 400;
  font-size: 11px;
}
.rnf-rosy-card-price ins {
  text-decoration: none;
}

/* ── Typing indicator ────────────────────────── */
.rnf-rosy-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.rnf-rosy-typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--rnf-rosy-white);
  border: 1px solid var(--rnf-rosy-border);
  border-radius: var(--rnf-rosy-radius-sm);
  border-top-left-radius: 4px;
}
.rnf-rosy-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rnf-rosy-brand);
  opacity: 0.4;
  animation: rnf-rosy-dot 1.4s ease-in-out infinite;
}
.rnf-rosy-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.rnf-rosy-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes rnf-rosy-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ── Satisfaction ────────────────────────────── */
.rnf-rosy-satisfaction {
  text-align: center;
  padding: 12px;
  margin: 8px 0;
  background: var(--rnf-rosy-white);
  border-radius: var(--rnf-rosy-radius-sm);
  border: 1px solid var(--rnf-rosy-border);
}
.rnf-rosy-satisfaction-q {
  font-size: 13px;
  color: var(--rnf-rosy-text-light);
  margin-bottom: 8px;
}
.rnf-rosy-satisfaction-btns {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.rnf-rosy-satisfaction-btns button {
  font-size: 22px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: var(--rnf-rosy-transition);
}
.rnf-rosy-satisfaction-btns button:hover {
  transform: scale(1.3);
  background: var(--rnf-rosy-nude);
}
.rnf-rosy-satisfaction-thanks {
  font-size: 13px;
  color: var(--rnf-rosy-brand);
  font-weight: 500;
  padding: 8px 0;
}

/* ── Footer (input) ──────────────────────────── */
.rnf-rosy-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--rnf-rosy-border);
  background: var(--rnf-rosy-white);
  flex-shrink: 0;
}
.rnf-rosy-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.rnf-rosy-input-wrap input {
  flex: 1;
  border: 1.5px solid var(--rnf-rosy-border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--rnf-rosy-font);
  outline: none;
  transition: var(--rnf-rosy-transition);
  background: var(--rnf-rosy-nude);
  /* iOS zoom fix */
  font-size: 16px;
}
.rnf-rosy-input-wrap input:focus {
  border-color: var(--rnf-rosy-brand);
  background: var(--rnf-rosy-white);
}
.rnf-rosy-send {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: linear-gradient(135deg, var(--rnf-rosy-brand), #a14b68);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--rnf-rosy-transition);
}
.rnf-rosy-send:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(139, 34, 82, 0.3);
}
.rnf-rosy-powered {
  text-align: center;
  font-size: 10px;
  color: var(--rnf-rosy-text-light);
  margin-top: 6px;
  opacity: 0.6;
}

/* ── Bouton inline (fiche produit) ───────────── */
.rnf-rosy-btn-wrap {
  margin-top: 12px;
}
.rnf-rosy-btn-wrap .rnf-rosy-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--rnf-rosy-nude);
  color: var(--rnf-rosy-brand);
  border: 1.5px solid var(--rnf-rosy-brand);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--rnf-rosy-transition);
}
.rnf-rosy-btn-wrap .rnf-rosy-open:hover {
  background: var(--rnf-rosy-brand);
  color: #fff;
}
.rnf-rosy-btn-icon {
  font-size: 16px;
}

/* ── Astra z-index protection ────────────────── */
#ast-scroll-top,
.ast-scroll-top {
  z-index: 99990 !important;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 480px) {
  .rnf-rosy-widget {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .rnf-rosy-body {
    max-height: calc(100vh - 140px);
  }
  .rnf-rosy-fab {
    right: 12px;
    bottom: 12px;
  }
  .rnf-rosy-fab-label {
    display: none;
  }
  .rnf-rosy-fab {
    padding: 8px;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    justify-content: center;
  }
  .rnf-rosy-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .rnf-rosy-widget {
    width: 380px;
    right: 12px;
    bottom: 12px;
  }
}

/* ── Print : masquer ─────────────────────────── */
@media print {
  .rnf-rosy-root { display: none !important; }
}
