/* Centre d'assistance Ebookly — tokens repris du site ebookly-shop.com */
:root {
  --bg: #FFFFFF;
  --bg-warm: #FBF6EF;
  --bg-subtle: #F9F6F1;
  --bg-cream: #F7F2EB;
  --acc: #B07740;
  --acc-lt: #DDB888;
  --acc-dk: #7A5028;
  --acc-bg: #FBF0E3;
  --acc-soft: #F6E3C8;
  --acc-btn: linear-gradient(160deg, #C26510 0%, #E8881E 50%, #C26510 100%);
  --acc-shadow: 0 4px 18px rgba(218, 120, 27, .30);
  --orange: #E8881E;
  --dark: #1C1B18;
  --text: #3D3828;
  --muted: #7A7060;
  --border: #E8E0D5;
  --border-warm: #E0D4C0;
  --ok: #1FB45A;
  --r-bubble: 24px;
  --r-pill: 999px;
  --shadow-bubble: 0 6px 24px rgba(122, 80, 40, .07);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-warm);
  color: var(--text);
  font-family: var(--font-jakarta), "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- Structure ---------- */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  background:
    radial-gradient(420px 260px at -60px 55%, rgba(240, 214, 186, .45), transparent 70%),
    radial-gradient(380px 300px at 110% 92%, rgba(240, 214, 186, .45), transparent 70%),
    var(--bg-warm);
  position: relative;
}

.header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px 14px;
  background: rgba(253, 249, 244, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(224, 212, 192, .5);
}
.brand-name { font-size: 26px; font-weight: 800; color: var(--dark); letter-spacing: -.3px; line-height: 1; }
.brand-sub { font-size: 11.5px; letter-spacing: 2.6px; text-transform: uppercase; color: var(--muted); margin-top: 6px; font-weight: 500; }

.thread { flex: 1; padding: 22px 18px 12px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- Agent ---------- */
.agent { display: flex; align-items: center; gap: 18px; margin: 4px 2px 10px; }
.avatar { position: relative; width: 84px; height: 84px; flex: none; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar .dot {
  position: absolute; right: 2px; bottom: 4px; width: 17px; height: 17px;
  border-radius: 50%; background: var(--ok); border: 3px solid var(--bg-warm);
}
.agent-name { font-size: 19px; font-weight: 800; color: var(--dark); }
.agent-role { font-size: 15px; color: var(--muted); margin-top: 3px; }

/* ---------- Bulles ---------- */
.row { display: flex; flex-direction: column; }
.row.left { align-items: flex-start; padding-left: 52px; }
.row.right { align-items: flex-end; padding-left: 60px; }

.bubble {
  max-width: 100%;
  padding: 16px 20px;
  border-radius: var(--r-bubble);
  font-size: 16.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble.bot { background: #FFFDFB; box-shadow: var(--shadow-bubble); border-top-left-radius: 8px; }
.bubble.agent { background: #FFFDFB; box-shadow: var(--shadow-bubble); border-top-left-radius: 8px; border-left: 3px solid var(--acc-lt); }
.bubble.client { background: var(--acc-btn); color: #fff; border-top-right-radius: 8px; box-shadow: var(--acc-shadow); }
.bubble.ticket { background: var(--acc-bg); border: 1px solid var(--acc-soft); }
.bubble strong { font-weight: 800; color: var(--dark); }
.bubble.client strong { color: #fff; }
.author { font-size: 12px; font-weight: 700; color: var(--acc-dk); margin: 0 0 4px 6px; }
.time { font-size: 12.5px; color: #A79C8C; margin: 6px 0 2px 22px; }
.row.right .time { margin: 6px 8px 2px 0; }
.bubble img.media { max-width: 220px; border-radius: 14px; display: block; }
.bubble audio { width: 230px; max-width: 100%; }

/* ---------- Cartes (livraison, lien) ---------- */
.card { background: #FFFDFB; border-radius: var(--r-bubble); box-shadow: var(--shadow-bubble); padding: 16px; width: 100%; }
.card-title { font-size: 16.5px; font-weight: 800; color: var(--dark); margin: 2px 4px 12px; }
.ebook { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; background: var(--bg-subtle); margin-bottom: 10px; }
.ebook img { width: 46px; height: 60px; object-fit: cover; border-radius: 6px; flex: none; }
.ebook .cover-ph { width: 46px; height: 60px; border-radius: 6px; background: var(--acc-bg); flex: none; display: grid; place-items: center; }
.ebook-name { font-weight: 700; color: var(--dark); font-size: 15px; line-height: 1.35; }
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  background: var(--acc-btn); color: #fff; font-weight: 800; font-size: 16px; letter-spacing: .2px;
  border: none; border-radius: 16px; padding: 15px 18px; text-decoration: none; cursor: pointer;
  box-shadow: var(--acc-shadow); transition: transform .15s;
}
.btn-primary:active { transform: scale(.98); }
.btn-outline {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  background: transparent; color: var(--acc-dk); font-weight: 800; font-size: 15.5px;
  border: 1.5px solid var(--acc-lt); border-radius: 16px; padding: 13px 16px; text-decoration: none; margin-top: 12px;
}

/* ---------- Suggestions ---------- */
.suggestions { display: flex; flex-direction: column; gap: 12px; padding: 8px 0 4px 36px; }
.suggestion {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
  padding: 11px 20px 11px 12px; min-height: 64px;
  background: rgba(255, 252, 247, .92); border: 1.5px solid var(--border-warm); border-radius: 34px;
  font-size: 16.5px; line-height: 1.3; color: var(--dark); font-weight: 500; cursor: pointer;
  box-shadow: 0 2px 10px rgba(122, 80, 40, .04);
  transition: background .15s, transform .12s, border-color .15s;
}
.suggestion:hover { background: #FFF8EF; border-color: var(--acc-lt); }
/* « Comment accéder à mon ebook déjà acheté ? » : le choix que certains acheteurs ne voient pas */
.suggestion.star { border: 2px solid var(--acc); background: #FFF4E3; font-weight: 600; box-shadow: 0 0 0 4px rgba(232, 140, 40, .12); }
.star-badge { margin-left: auto; font-size: 20px; animation: starPulse 1.6s ease-in-out infinite; }
@keyframes starPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
.suggestion:active { transform: scale(.985); }
.suggestion .ico {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--acc-soft); display: grid; place-items: center; color: var(--acc);
}
.suggestion .ico svg { width: 24px; height: 24px; }

/* ---------- Saisie ---------- */
.composer-wrap {
  position: sticky; bottom: 0; z-index: 10;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(251, 246, 239, 0), var(--bg-warm) 30%);
}
.field {
  display: flex; align-items: center; gap: 8px; background: #fff; border: 1.5px solid var(--border-warm);
  border-radius: 30px; padding: 6px 6px 6px 14px; box-shadow: 0 4px 18px rgba(122, 80, 40, .08);
}
.field:focus-within { border-color: var(--acc-lt); }
.field input, .field textarea {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-size: 16.5px; padding: 10px 4px; resize: none; max-height: 120px;
}
.field select {
  border: none; background: var(--bg-subtle); border-radius: 20px; padding: 9px 8px; font-size: 15px;
  max-width: 116px; outline: none;
}
.icon-btn {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center; background: transparent; color: var(--acc);
}
.icon-btn.primary { background: var(--acc-btn); color: #fff; box-shadow: var(--acc-shadow); }
.icon-btn:disabled { opacity: .45; cursor: default; }
.icon-btn svg { width: 22px; height: 22px; }
.recording { color: #DC2626; font-weight: 700; flex: 1; padding-left: 4px; }
.hint { font-size: 13px; color: var(--muted); padding: 6px 14px 0; }

/* ---------- Divers ---------- */
.typing { display: inline-flex; gap: 5px; padding: 18px 20px; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--acc-lt); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
.row.left.typing-row { flex-direction: row; align-items: center; gap: 10px; }
.typing-label { font-size: 13px; color: #7A7060; font-style: italic; }
@keyframes blink { 0%, 80%, 100% { opacity: .3 } 40% { opacity: 1 } }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 50;
  background: var(--dark); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14.5px;
  max-width: calc(100% - 32px); box-shadow: 0 8px 28px rgba(0,0,0,.2);
}
.center-note { text-align: center; color: var(--muted); padding: 40px 20px; }
.newreq { background: none; border: none; color: var(--acc-dk); font-weight: 700; text-decoration: underline; cursor: pointer; padding: 10px; }

@media (max-width: 380px) {
  .row.left { padding-left: 24px; }
  .suggestions { padding-left: 12px; }
  .bubble, .suggestion { font-size: 15.5px; }
}
.btn-primary svg, .btn-outline svg { width: 20px; height: 20px; flex: none; }

/* ===== Version compacte (retour de Richie : gagner de l'espace) ===== */
.header { padding: 10px 14px; gap: 10px; }
.header .avatar { width: 42px; height: 42px; }
.header .avatar .dot { width: 11px; height: 11px; right: 0; bottom: 1px; border-width: 2px; }
.header .who { flex: 1; min-width: 0; }
.header .agent-name { font-size: 16px; line-height: 1.2; }
.header .agent-role { font-size: 12.5px; margin-top: 1px; }
.header .brand { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: var(--acc-dk); opacity: .85; }
.thread { padding: 14px 12px 10px; gap: 6px; }
.row.left { padding-left: 0; padding-right: 34px; }
.row.right { padding-left: 48px; }
.bubble { font-size: 15px; line-height: 1.45; padding: 11px 15px; border-radius: 18px; }
.bubble.bot, .bubble.agent { border-top-left-radius: 6px; }
.bubble.client { border-top-right-radius: 6px; }
.time { font-size: 11px; margin: 3px 0 2px 12px; }
.row.right .time { margin: 3px 6px 2px 0; }
.card { padding: 12px; border-radius: 18px; }
.card-title { font-size: 15px; margin: 0 2px 8px; }
.ebook { padding: 8px; margin-bottom: 8px; }
.ebook img, .ebook .cover-ph { width: 38px; height: 50px; }
.ebook-name { font-size: 14px; }
.btn-primary { font-size: 15px; padding: 12px 14px; border-radius: 14px; }
.btn-outline { font-size: 14.5px; padding: 10px 14px; border-radius: 14px; margin-top: 10px; }
.suggestions { gap: 8px; padding: 6px 0 2px 26px; }
.suggestion { min-height: 48px; padding: 7px 14px 7px 8px; gap: 11px; font-size: 15px; border-radius: 26px; }
.suggestion .ico { width: 32px; height: 32px; }
.suggestion .ico svg { width: 18px; height: 18px; }
.suggestion.back { min-height: 40px; background: transparent; border-style: dashed; color: var(--muted); font-size: 14px; }
.suggestion.back .ico { background: transparent; color: var(--muted); }
.composer-wrap { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
.field { padding: 4px 4px 4px 10px; border-radius: 26px; }
.field input, .field textarea { font-size: 15.5px; padding: 8px 4px; }
.field select { max-width: 92px; font-size: 14px; padding: 7px 6px; }
.icon-btn { width: 40px; height: 40px; }
.icon-btn svg { width: 20px; height: 20px; }
@media (max-width: 380px) { .suggestions { padding-left: 10px; } .row.left { padding-right: 16px; } }

.icon-btn.danger { color: #DC2626; }

/* ---------- Chargement (squelette animé) ---------- */
.loading-skel { animation: skel-in .35s ease-out both; }
.skel {
  border-radius: 18px;
  background: linear-gradient(100deg, #EFDCC6 30%, #FFF8EF 50%, #EFDCC6 70%);
  background-size: 300% 100%;
  animation: skel-shine 1.4s ease-in-out infinite, skel-in .45s ease-out both;
}
.skel-bubble { height: 52px; border-top-left-radius: 6px; }
.loading-skel .typing { background: #fff; }
.skel-sugs { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.skel-pill { height: 50px; border-radius: 26px; width: 88%; align-self: flex-end; }
@keyframes skel-shine { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes skel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .skel, .loading-skel { animation: none; } }
.mwrap { display: contents; }

/* Upsell après livraison : carrousel horizontal d'ebooks proches */
.thread { min-width: 0; overflow-x: hidden; }
.upsell-row { flex-direction: column; align-items: stretch; min-width: 0; max-width: 100%; }
.upsell-row .bubble { align-self: flex-start; }
.upsell { display: flex; gap: 10px; overflow-x: auto; width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; padding: 8px 2px 10px; margin-top: 6px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.upsell::-webkit-scrollbar { display: none; }
.upsell-card { flex: 0 0 148px; scroll-snap-align: start; background: #FFFDFB; border-radius: 16px; box-shadow: var(--shadow-bubble);
  padding: 10px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--dark); }
.upsell-card img, .upsell-noimg { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 10px; background: #F3EBDD; }
.upsell-noimg { display: flex; align-items: center; justify-content: center; font-size: 34px; }
.upsell-name { font-size: 13px; font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 3.75em; }
.upsell-price { font-size: 12.5px; color: #7A7060; }
.upsell-cta { margin-top: auto; text-align: center; font-size: 13px; font-weight: 800; color: #fff; border-radius: 10px; padding: 7px 0;
  background: linear-gradient(160deg,#C26510,#E8881E,#C26510); }
@media (max-width: 640px) { .row.left.upsell-row { padding-right: 0; } }

/* Lien discret sous le carrousel, pour ceux qui n'y trouvent pas leur bonheur */
.upsell-more { display: block; text-align: right; margin: 4px 4px 0 0; font-size: 13px; color: var(--acc); text-decoration: underline; text-underline-offset: 3px; }
