/* Rumyantsev Cigar Co — Concierge chat widget (storefront only). Loaded by js/chat.js pages.
 * Stacking: above page content/header (100), below cart overlay/drawer (200/201), toast (300), age gate (10000). */
.rcc-chat {
  --chat-lift: 0px;                     /* set by chat.js when a fixed bottom bar (e.g. mobile buy bar) is visible */
  --chat-gap: 1.25rem;
  --chat-bg: rgba(26, 16, 12, 0.94);
  --chat-border: rgba(196, 160, 122, 0.38);
  --chat-peach: var(--peach, #e8c9b9);
  --chat-bronze: var(--bronze, #c4a07a);
  --chat-text: var(--text, #f3ebe3);
  --chat-muted: var(--text-muted, rgba(243, 235, 227, 0.72));
  font-family: var(--font-sans, "DM Sans", system-ui, sans-serif);
  color: var(--chat-text);
}
.rcc-chat[hidden], .rcc-chat [hidden] { display: none !important; }

/* —— Launcher —— */
.rcc-chat__launcher {
  position: fixed;
  right: calc(var(--chat-gap) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--chat-gap) + var(--chat-lift) + env(safe-area-inset-bottom, 0px));
  z-index: 150;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid rgba(255, 240, 230, 0.55);
  background: radial-gradient(circle at 32% 28%, #f6e2d6 0%, var(--chat-peach) 48%, #d3ab95 100%);
  color: #2a1810;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(18, 12, 9, 0.55), 0 0 22px rgba(232, 201, 185, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, bottom 0.25s ease, opacity 0.2s ease;
}
.rcc-chat__launcher:hover { transform: translateY(-2px) scale(1.03); }
.rcc-chat__launcher:focus-visible { outline: 2px solid var(--chat-peach); outline-offset: 5px; }
.rcc-chat__launcher svg { width: 26px; height: 26px; }
.rcc-chat__launcher .rcc-chat__icon-close { display: none; }
.rcc-chat.is-open .rcc-chat__launcher .rcc-chat__icon-open { display: none; }
.rcc-chat.is-open .rcc-chat__launcher .rcc-chat__icon-close { display: block; }
.rcc-chat__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #b5523f;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  display: grid;
  place-items: center;
  border: 2px solid #120c09;
}
/* Cart drawer open: get out of the way entirely. */
body.rcc-cart-open .rcc-chat__launcher,
body.rcc-cart-open .rcc-chat__panel { opacity: 0; visibility: hidden; pointer-events: none; }

/* —— Panel —— */
.rcc-chat__panel {
  position: fixed;
  right: calc(var(--chat-gap) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--chat-gap) + var(--chat-lift) + 72px + env(safe-area-inset-bottom, 0px));
  z-index: 150;
  width: min(380px, calc(100vw - 2rem));
  height: min(600px, calc(100vh - var(--chat-lift) - 140px));
  height: min(600px, calc(100dvh - var(--chat-lift) - 140px));
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(46, 30, 22, 0.92) 0%, rgba(22, 14, 10, 0.95) 100%);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(232, 201, 185, 0.08);
  overflow: hidden;
  transform-origin: bottom right;
  animation: rcc-chat-in 0.22s ease-out;
}
@keyframes rcc-chat-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

.rcc-chat__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 0.85rem 0.85rem 1.1rem;
  border-bottom: 1px solid rgba(196, 160, 122, 0.22);
  background: linear-gradient(180deg, rgba(196, 160, 122, 0.10), rgba(196, 160, 122, 0));
}
.rcc-chat__mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--chat-bronze);
  display: grid;
  place-items: center;
  color: var(--chat-peach);
  font-family: var(--font-serif, "Cinzel", serif);
  font-size: 0.95rem;
  font-weight: 600;
}
.rcc-chat__titles { flex: 1 1 auto; min-width: 0; }
.rcc-chat__title {
  margin: 0;
  font-family: var(--font-serif, "Cinzel", serif);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--chat-peach);
  line-height: 1.2;
}
.rcc-chat__subtitle { margin: 0.15rem 0 0; font-size: 0.74rem; color: var(--chat-muted); letter-spacing: 0.02em; }
.rcc-chat__hbtn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--chat-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
}
.rcc-chat__hbtn:hover { color: var(--chat-peach); border-color: rgba(196, 160, 122, 0.3); }
.rcc-chat__hbtn:focus-visible { outline: 2px solid var(--chat-peach); outline-offset: 1px; }
.rcc-chat__hbtn svg { width: 18px; height: 18px; }
.rcc-chat__hbtn .rcc-chat__dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #d47868;
}

/* —— Views —— */
.rcc-chat__view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.rcc-chat__log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 0.95rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 160, 122, 0.35) transparent;
  overscroll-behavior: contain;
}
.rcc-chat__msg {
  max-width: 86%;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.rcc-chat__msg p { margin: 0 0 0.45rem; }
.rcc-chat__msg p:last-child { margin-bottom: 0; }
.rcc-chat__msg ul { margin: 0.25rem 0 0.4rem; padding-left: 1.1rem; }
.rcc-chat__msg li { margin: 0.15rem 0; }
.rcc-chat__msg--bot {
  align-self: flex-start;
  background: rgba(58, 38, 28, 0.85);
  border: 1px solid rgba(196, 160, 122, 0.2);
  border-bottom-left-radius: 4px;
}
.rcc-chat__msg--user {
  align-self: flex-end;
  background: var(--chat-peach);
  color: #22140d;
  border-bottom-right-radius: 4px;
}
.rcc-chat__msg--shop {
  align-self: flex-start;
  background: rgba(196, 160, 122, 0.16);
  border: 1px solid rgba(196, 160, 122, 0.4);
  border-bottom-left-radius: 4px;
}
.rcc-chat__msg a { color: var(--chat-peach); text-decoration: underline; text-underline-offset: 2px; }
.rcc-chat__msg--user a { color: #22140d; }
.rcc-chat__msg a:focus-visible { outline: 2px solid var(--chat-peach); outline-offset: 2px; border-radius: 2px; }
.rcc-chat__meta { display: block; margin-top: 0.3rem; font-size: 0.68rem; color: var(--chat-muted); letter-spacing: 0.02em; }
.rcc-chat__msg--user .rcc-chat__meta { color: rgba(34, 20, 13, 0.65); }
.rcc-chat__note {
  align-self: center;
  font-size: 0.72rem;
  color: var(--chat-muted);
  text-align: center;
  max-width: 92%;
}
.rcc-chat__products { list-style: none; padding: 0 !important; margin: 0.4rem 0 0 !important; display: grid; gap: 0.35rem; }
.rcc-chat__products li { margin: 0 !important; }
.rcc-chat__products a {
  display: flex; justify-content: space-between; gap: 0.6rem;
  padding: 0.45rem 0.6rem; border-radius: 8px;
  background: rgba(18, 12, 9, 0.55); border: 1px solid rgba(196, 160, 122, 0.18);
  text-decoration: none !important; color: var(--chat-text) !important; font-size: 0.84rem;
}
.rcc-chat__products a:hover { border-color: rgba(232, 201, 185, 0.5); }
.rcc-chat__products .rcc-chat__price { color: var(--chat-peach); white-space: nowrap; font-weight: 500; }
.rcc-chat__action {
  display: inline-flex; align-items: center; gap: 0.4rem;
  margin-top: 0.5rem; padding: 0.4rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--chat-bronze); background: transparent; color: var(--chat-peach);
  font: inherit; font-size: 0.8rem; cursor: pointer;
}
.rcc-chat__action:hover { background: rgba(196, 160, 122, 0.14); }
.rcc-chat__action:focus-visible { outline: 2px solid var(--chat-peach); outline-offset: 2px; }

/* Typing indicator */
.rcc-chat__typing { display: inline-flex; gap: 4px; align-items: center; padding: 0.75rem 0.9rem; }
.rcc-chat__typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--chat-bronze);
  animation: rcc-chat-dot 1.2s infinite ease-in-out;
}
.rcc-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.rcc-chat__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes rcc-chat-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Quick replies */
.rcc-chat__chips {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem 0.2rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  flex: 0 0 auto;
}
.rcc-chat__chips::-webkit-scrollbar { display: none; }
.rcc-chat__chip {
  flex: 0 0 auto;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(196, 160, 122, 0.45);
  background: rgba(18, 12, 9, 0.5);
  color: var(--chat-peach);
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.rcc-chat__chip:hover { background: rgba(196, 160, 122, 0.16); border-color: var(--chat-peach); }
.rcc-chat__chip:focus-visible { outline: 2px solid var(--chat-peach); outline-offset: 2px; }

/* Composer */
.rcc-chat__composer {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.6rem 0.75rem 0.75rem;
  border-top: 1px solid rgba(196, 160, 122, 0.16);
}
.rcc-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  max-height: 110px;
  min-height: 42px;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid rgba(196, 160, 122, 0.3);
  background: rgba(14, 9, 7, 0.65);
  color: var(--chat-text);
  font: inherit;
  font-size: 16px;           /* no iOS zoom on focus */
  line-height: 1.35;
}
.rcc-chat__input::placeholder { color: rgba(243, 235, 227, 0.45); }
.rcc-chat__input:focus { outline: none; border-color: var(--chat-peach); box-shadow: 0 0 0 3px rgba(232, 201, 185, 0.15); }
.rcc-chat__send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--chat-peach);
  color: #22140d;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.rcc-chat__send:disabled { opacity: 0.45; cursor: not-allowed; }
.rcc-chat__send:focus-visible { outline: 2px solid var(--chat-peach); outline-offset: 2px; }
.rcc-chat__send svg { width: 18px; height: 18px; }
.rcc-chat__foot {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 0.95rem 0.6rem;
  font-size: 0.68rem;
  color: var(--chat-muted);
  text-align: center;
}
.rcc-chat__foot a { color: var(--chat-peach); }

/* —— Message-the-shop form —— */
.rcc-chat__form { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1rem 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.rcc-chat__form h3 { margin: 0; font-family: var(--font-serif, "Cinzel", serif); font-size: 0.98rem; letter-spacing: 0.05em; color: var(--chat-peach); font-weight: 600; }
.rcc-chat__form .rcc-chat__lead { margin: 0; font-size: 0.82rem; color: var(--chat-muted); line-height: 1.5; }
.rcc-chat__field { display: flex; flex-direction: column; gap: 0.3rem; }
.rcc-chat__field > label, .rcc-chat__legend { font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--chat-bronze); }
.rcc-chat__field input[type="text"],
.rcc-chat__field input[type="email"],
.rcc-chat__field input[type="tel"],
.rcc-chat__field textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(196, 160, 122, 0.3);
  background: rgba(14, 9, 7, 0.65);
  color: var(--chat-text);
  font: inherit;
  font-size: 16px;
}
.rcc-chat__field textarea { min-height: 96px; resize: vertical; }
.rcc-chat__field input:focus, .rcc-chat__field textarea:focus { outline: none; border-color: var(--chat-peach); box-shadow: 0 0 0 3px rgba(232, 201, 185, 0.15); }
.rcc-chat__field [aria-invalid="true"] { border-color: #d47868 !important; }
.rcc-chat__err { font-size: 0.75rem; color: #e39a8c; min-height: 0; }
.rcc-chat__seg { display: flex; gap: 0.4rem; border: 0; padding: 0; margin: 0; }
.rcc-chat__seg legend { padding: 0; margin-bottom: 0.3rem; }
.rcc-chat__seg label {
  flex: 1 1 0;
  display: flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.5rem 0.4rem; border-radius: 10px;
  border: 1px solid rgba(196, 160, 122, 0.3);
  font-size: 0.84rem; cursor: pointer; color: var(--chat-muted);
}
.rcc-chat__seg input { accent-color: var(--chat-peach); }
.rcc-chat__seg label:has(input:checked) { border-color: var(--chat-peach); color: var(--chat-peach); background: rgba(232, 201, 185, 0.08); }
.rcc-chat__seg label:has(input:focus-visible) { outline: 2px solid var(--chat-peach); outline-offset: 2px; }
.rcc-chat__check { display: flex; gap: 0.55rem; align-items: flex-start; font-size: 0.84rem; color: var(--chat-text); line-height: 1.4; cursor: pointer; }
.rcc-chat__check input { margin-top: 0.2rem; accent-color: var(--chat-peach); width: 16px; height: 16px; flex: 0 0 auto; }
.rcc-chat__formactions { display: flex; gap: 0.5rem; align-items: center; }
.rcc-chat__btn {
  flex: 1 1 auto;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--chat-peach);
  background: var(--chat-peach);
  color: #22140d;
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.rcc-chat__btn--ghost { background: transparent; color: var(--chat-peach); flex: 0 0 auto; }
.rcc-chat__btn:disabled { opacity: 0.55; cursor: progress; }
.rcc-chat__btn:focus-visible { outline: 2px solid var(--chat-peach); outline-offset: 2px; }
.rcc-chat__status { font-size: 0.82rem; line-height: 1.5; padding: 0.6rem 0.75rem; border-radius: 10px; }
.rcc-chat__status--error { background: rgba(212, 120, 104, 0.12); border: 1px solid rgba(212, 120, 104, 0.45); color: #f1c3b9; }
.rcc-chat__status--ok { background: rgba(196, 160, 122, 0.12); border: 1px solid rgba(196, 160, 122, 0.45); color: var(--chat-peach); }
.rcc-chat__status a { color: var(--chat-peach); }
.rcc-chat__privacy { margin: 0; font-size: 0.7rem; color: var(--chat-muted); line-height: 1.45; }

.rcc-chat__sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* —— Mobile: full-height sheet —— */
@media (max-width: 640px) {
  .rcc-chat { --chat-gap: 1rem; }
  .rcc-chat__launcher { width: 56px; height: 56px; }
  .rcc-chat__panel {
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--chat-border);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: linear-gradient(180deg, rgba(40, 26, 19, 0.98) 0%, rgba(18, 12, 9, 0.99) 100%);
    z-index: 160;
    animation-name: rcc-chat-sheet;
  }
  @keyframes rcc-chat-sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  /* The sheet has its own close button; hide the launcher under it. */
  .rcc-chat.is-open .rcc-chat__launcher { opacity: 0; pointer-events: none; }
  .rcc-chat__msg { max-width: 90%; }
}
body.rcc-chat-sheet-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .rcc-chat__panel, .rcc-chat__launcher { animation: none; transition: none; }
  .rcc-chat__typing span { animation: none; opacity: 0.7; }
}
