/* CPC custom chat widget - tabac-stop.net / tabac-en-ligne-livraison-domicile.com
 * Single-file CSS, namespace .cpcw-* to avoid theme collisions, !important on
 * positioning so site CSS can't fight us.
 */
.cpcw-root, .cpcw-root * { box-sizing: border-box; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }

/* ============ Launcher ============ */
.cpcw-launcher {
  position: fixed !important; bottom: 22px !important; right: 22px !important;
  width: 64px !important; height: 64px !important; border-radius: 50% !important;
  background: linear-gradient(135deg, #DC9815 0%, #b07810 100%) !important;
  color: #fff !important; border: 0 !important; cursor: pointer !important;
  box-shadow: 0 8px 24px rgba(220,152,21,0.4), 0 2px 6px rgba(0,0,0,0.15) !important;
  z-index: 2147483646 !important; display: flex !important;
  align-items: center !important; justify-content: center !important;
  transition: transform .18s ease, box-shadow .18s ease !important;
  animation: cpcw-pulse 2.4s infinite !important;
}
.cpcw-launcher:hover { transform: scale(1.07); box-shadow: 0 12px 32px rgba(220,152,21,0.5); }
.cpcw-launcher svg { width: 28px; height: 28px; fill: #fff; }
.cpcw-launcher .cpcw-badge {
  position: absolute; top: 4px; right: 4px; min-width: 20px; height: 20px;
  background: #ef4444; color: #fff; border-radius: 99px; font-size: 11px;
  font-weight: 700; display: flex; align-items: center; justify-content: center;
  padding: 0 6px; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
@keyframes cpcw-pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(220,152,21,0.4), 0 2px 6px rgba(0,0,0,0.15), 0 0 0 0 rgba(220,152,21,0.5); }
  50%      { box-shadow: 0 8px 24px rgba(220,152,21,0.4), 0 2px 6px rgba(0,0,0,0.15), 0 0 0 14px rgba(220,152,21,0); }
}

/* ============ Teaser tooltip (auto-popup) ============ */
.cpcw-teaser {
  position: fixed !important; bottom: 100px !important; right: 22px !important;
  max-width: 260px !important;
  background: #fff !important; color: #0f172a !important;
  border-radius: 14px !important; padding: 12px 14px !important;
  box-shadow: 0 10px 28px rgba(0,0,0,0.15) !important; z-index: 2147483645 !important;
  font-size: 13px !important; line-height: 1.4 !important;
  cursor: pointer !important;
  animation: cpcw-teaser-in .35s ease !important;
}
.cpcw-teaser-strong { font-weight: 700; color: #DC9815; margin-bottom: 2px; }
.cpcw-teaser-close {
  position: absolute; top: 6px; right: 8px; background: transparent; border: 0;
  color: #94a3b8; font-size: 18px; cursor: pointer; padding: 0; line-height: 1;
}
@keyframes cpcw-teaser-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ============ Panel ============ */
.cpcw-panel {
  position: fixed !important; bottom: 100px !important; right: 22px !important;
  width: 380px !important; max-width: calc(100vw - 24px) !important;
  height: 580px !important; max-height: calc(100vh - 130px) !important;
  background: #fff !important;
  border-radius: 16px !important;
  box-shadow: 0 18px 48px rgba(0,0,0,0.18) !important;
  z-index: 2147483645 !important;
  display: none !important; flex-direction: column !important;
  overflow: hidden !important;
  animation: cpcw-panel-in .25s cubic-bezier(.2,.8,.2,1) !important;
  font-size: 14px !important;
  color: #0f172a !important;
}
.cpcw-panel-open { display: flex !important; }
@keyframes cpcw-panel-in {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

@media (max-width: 480px) {
  .cpcw-panel {
    bottom: 0 !important; right: 0 !important; left: 0 !important; top: 0 !important;
    width: 100% !important; height: 100% !important; max-height: none !important;
    max-width: none !important; border-radius: 0 !important;
  }
  .cpcw-launcher { bottom: 16px !important; right: 16px !important; }
  .cpcw-teaser { bottom: 90px !important; right: 16px !important; }
}

/* ============ Header ============ */
.cpcw-head {
  background: linear-gradient(135deg, #DC9815 0%, #b07810 100%);
  color: #fff; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.cpcw-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: #fff; color: #b07810;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; letter-spacing: 0.5px;
  flex-shrink: 0;
}
.cpcw-headinfo { flex: 1; min-width: 0; line-height: 1.25; }
.cpcw-name { font-weight: 700; font-size: 15px; }
.cpcw-status { font-size: 11.5px; opacity: 0.92; display: flex; align-items: center; gap: 5px; }
.cpcw-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #4ade80;
  display: inline-block;
  animation: cpcw-dot-pulse 1.6s infinite;
  box-shadow: 0 0 0 0 rgba(74,222,128,0.7);
}
@keyframes cpcw-dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74,222,128,0.7); }
  70%  { box-shadow: 0 0 0 6px rgba(74,222,128,0);   }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0);     }
}
.cpcw-close, .cpcw-back {
  background: transparent !important; border: 0 !important;
  color: rgba(255,255,255,0.95) !important;
  font-size: 22px !important; cursor: pointer !important;
  padding: 6px 10px !important; border-radius: 8px !important;
  line-height: 1 !important; z-index: 10 !important;
  min-width: 36px; min-height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.cpcw-close:hover, .cpcw-back:hover { background: rgba(255,255,255,0.18) !important; }
.cpcw-close:active { background: rgba(255,255,255,0.30) !important; }

/* ============ Body ============ */
.cpcw-body {
  flex: 1; overflow-y: auto; padding: 14px 14px 8px;
  background: #f8fafc;
  scroll-behavior: smooth;
}
.cpcw-body::-webkit-scrollbar { width: 6px; }
.cpcw-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* ============ Greeting card (prelaunch) ============ */
.cpcw-greet {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #fde6b8; border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px;
  font-size: 13.5px; line-height: 1.5; color: #5a3a08;
}
.cpcw-greet b { color: #b07810; }
.cpcw-quick {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px;
}
.cpcw-quick button {
  background: #fff; border: 1px solid #fde6b8; color: #b07810;
  padding: 8px 12px; border-radius: 99px; font-size: 12.5px;
  font-weight: 600; cursor: pointer;
  transition: all .15s ease;
  flex: 1; min-width: 130px; text-align: center;
}
.cpcw-quick button:hover { background: #b07810; color: #fff; border-color: #b07810; }

/* ============ Messages ============ */
.cpcw-msg {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 14px;
  margin-bottom: 6px;
  font-size: 14px; line-height: 1.45;
  word-wrap: break-word; overflow-wrap: break-word;
  animation: cpcw-msg-in .18s ease;
}
@keyframes cpcw-msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.cpcw-msg-bot {
  background: #fff; color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  align-self: flex-start; margin-right: auto;
}
.cpcw-msg-user {
  background: linear-gradient(135deg, #DC9815 0%, #b07810 100%); color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end; margin-left: auto;
}
.cpcw-msg-time {
  font-size: 11px; color: #64748b; margin-top: 3px;  /* AA-compliant 4.5:1 on white */
}
.cpcw-msg a {
  color: inherit; text-decoration: underline; word-break: break-all;
}
.cpcw-msg-pay {
  display: block; background: #DC9815; color: #fff !important;
  text-decoration: none !important; text-align: center;
  padding: 10px 14px; border-radius: 10px; margin-top: 8px;
  font-weight: 700; font-size: 13.5px;
  box-shadow: 0 4px 12px rgba(220,152,21,0.35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.cpcw-msg-pay:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(220,152,21,0.45); }

.cpcw-thread { display: flex; flex-direction: column; }

/* Date separator */
.cpcw-day {
  align-self: center; font-size: 11px; color: #94a3b8;
  background: rgba(148,163,184,0.12); padding: 3px 12px;
  border-radius: 99px; margin: 8px 0 4px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: capitalize;
}

/* ============ Typing indicator ============ */
.cpcw-typing-wrap {
  display: flex; align-items: flex-end; gap: 6px;
  margin-bottom: 8px; align-self: flex-start;
}
.cpcw-typing-wrap .cpcw-bubble-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg,#DC9815 0%,#b07810 100%);
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.cpcw-typing-wrap .cpcw-typing-col { display: flex; flex-direction: column; }
.cpcw-typing-label {
  font-size: 10.5px; color: #64748b; margin-bottom: 2px; padding-left: 4px;
}
.cpcw-typing {
  display: inline-flex; padding: 9px 13px;
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 14px; border-bottom-left-radius: 4px;
  align-items: center; gap: 4px;
}
.cpcw-typing span {
  width: 7px; height: 7px; background: #94a3b8;
  border-radius: 50%; opacity: 0.4;
  animation: cpcw-typing-dot 1.2s infinite;
}
.cpcw-typing span:nth-child(2) { animation-delay: 0.2s; }
.cpcw-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cpcw-typing-dot {
  0%, 80% { opacity: 0.3; transform: scale(.8); }
  40%     { opacity: 1; transform: scale(1.1); }
}

/* ============ Bot message with avatar ============ */
.cpcw-msg-row {
  display: flex; align-items: flex-end; gap: 6px;
  margin-bottom: 6px;
}
.cpcw-msg-row.cpcw-row-user { justify-content: flex-end; }
.cpcw-msg-row.cpcw-row-bot { justify-content: flex-start; }
.cpcw-bubble-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg,#DC9815 0%,#b07810 100%);
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-bottom: 4px;
}
.cpcw-msg-col { display: flex; flex-direction: column; max-width: 80%; }
.cpcw-msg-row .cpcw-msg { margin: 0; }
.cpcw-msg-meta {
  font-size: 10.5px; color: #94a3b8; margin-top: 3px;
  display: flex; align-items: center; gap: 4px;
}
.cpcw-row-user .cpcw-msg-meta { justify-content: flex-end; padding-right: 2px; }
.cpcw-row-bot  .cpcw-msg-meta { padding-left: 4px; }
.cpcw-msg-status {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 10.5px;
}
.cpcw-msg-status svg { width: 12px; height: 12px; opacity: 0.6; }

/* ============ Footer / Input ============ */
.cpcw-foot {
  flex-shrink: 0;
  padding: 10px 12px; background: #fff;
  border-top: 1px solid #e2e8f0;
}
.cpcw-row {
  display: flex; align-items: flex-end; gap: 8px;
}
.cpcw-row textarea {
  flex: 1; resize: none;
  border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 10px 12px; font-size: 16px;     /* >=16 prevents iOS Safari zoom-on-focus */
  font-family: inherit; min-height: 42px; max-height: 120px;
  outline: none; line-height: 1.4;
}
.cpcw-row textarea:focus { border-color: #DC9815; }
.cpcw-row textarea:focus-visible,
.cpcw-send:focus-visible,
.cpcw-close:focus-visible,
.cpcw-launcher:focus-visible,
.cpcw-quick button:focus-visible {
  outline: 2px solid #DC9815;
  outline-offset: 2px;
}
.cpcw-attach {
  width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: transparent; color: #94a3b8; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: color .15s ease;
}
.cpcw-attach:hover { color: #DC9815; }
.cpcw-send {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, #DC9815 0%, #b07810 100%);
  color: #fff; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s ease, transform .15s ease;
  flex-shrink: 0;
}
.cpcw-send:disabled { opacity: 0.4; cursor: not-allowed; }
.cpcw-send:not(:disabled):hover { transform: scale(1.05); }
.cpcw-send svg { width: 18px; height: 18px; fill: #fff; }
.cpcw-credit {
  text-align: center; font-size: 11px; color: #64748b; padding: 6px 0 2px;
}

/* ============ A11y: respect reduced-motion + safe-area + dark hint ============ */
@media (prefers-reduced-motion: reduce) {
  .cpcw-launcher, .cpcw-dot, .cpcw-typing span, .cpcw-msg, .cpcw-panel, .cpcw-teaser {
    animation: none !important;
    transition: none !important;
  }
}

/* iOS / Android safe-area */
@supports (padding: env(safe-area-inset-bottom)) {
  .cpcw-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .cpcw-launcher { bottom: calc(22px + env(safe-area-inset-bottom)) !important; }
  .cpcw-teaser { bottom: calc(100px + env(safe-area-inset-bottom)) !important; }
}

@media (max-width: 480px) {
  .cpcw-row textarea { font-size: 16px; }   /* belt & suspenders for iOS */
  .cpcw-body { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
}
