/* Bloom Assistant: floating chat widget (customer site). Uses tokens.css. */
/* Handwriting font for the greeting card preview (Latin + Cyrillic). */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500&display=swap');

.chat-root {
  --chat-gap: 24px;
  --chat-w: 380px;
  position: fixed; z-index: 900; right: var(--chat-gap); bottom: var(--chat-gap);
  display: flex; flex-direction: column; align-items: flex-end; gap: 14px;
  font-family: var(--font-body); color: var(--ink);
  pointer-events: none;
}
.chat-root > * { pointer-events: auto; }
.chat-root [hidden] { display: none !important; }
.has-chat .toast-stack { bottom: 100px; }

/* ---- Launcher ---- */
.chat-launcher {
  position: relative; width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--green); color: #fff;
  box-shadow: 0 6px 20px rgba(58, 82, 58, 0.32), 0 1px 3px rgba(35, 37, 31, 0.12);
  transition: background 0.15s, transform 0.2s ease;
}
.chat-launcher:hover { background: var(--green-dark); transform: translateY(-2px); }
.chat-launcher:focus-visible { outline-offset: 4px; }
.chat-launcher-icon { display: grid; transition: transform 0.2s ease; }
.chat-root.is-open .chat-launcher-icon { transform: rotate(-8deg) scale(0.92); }
.chat-unread {
  position: absolute; top: 4px; right: 4px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--rose); border: 2px solid var(--ivory);
}

/* ---- Greeting bubble ---- */
.chat-greeting {
  position: relative; max-width: 260px; padding: 14px 40px 14px 18px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px 16px 4px 16px;
  box-shadow: var(--shadow); animation: chat-rise 0.25s ease-out;
}
.chat-greeting-text {
  border: 0; background: none; padding: 0; text-align: left; cursor: pointer;
  font-size: 14px; font-weight: 500; line-height: 1.45; color: var(--ink);
}
.chat-greeting-text:hover { color: var(--green-dark); }
.chat-greeting-close { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; color: var(--muted); }

/* ---- Window ---- */
.chat-window {
  width: var(--chat-w); height: min(600px, calc(100dvh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg); transform-origin: bottom right; animation: chat-open 0.2s ease-out;
}
.chat-root.is-restored .chat-window, .chat-root.is-restored .chat-msg, .chat-root.is-restored .chat-order { animation: none; }
@keyframes chat-open { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes chat-rise { from { opacity: 0; transform: translateY(6px); } }

.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 10px 14px 16px;
  background: var(--green); color: #fff;
}
.chat-avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.14); color: #fff; border: 1px solid rgba(255, 255, 255, 0.22);
}
.chat-head-text { flex: 1; min-width: 0; }
.chat-head h2 {
  font-family: var(--font-display); font-size: 22px; font-weight: 600; line-height: 1.1; letter-spacing: 0;
  display: flex; align-items: center; gap: 8px;
}
.chat-head p { font-size: 12.5px; color: #dbe5d4; margin-top: 2px; }
.chat-ai-tag {
  font-family: var(--font-body); font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  padding: 2px 7px; border-radius: 999px; background: var(--ivory); color: var(--green-dark);
}
.chat-icon-btn {
  flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: transparent; color: inherit; cursor: pointer; transition: background 0.15s;
}
.chat-head .chat-icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.chat-greeting-close:hover { background: var(--cream); color: var(--ink); }
.chat-head .chat-icon-btn:focus-visible { outline-color: #fff; outline-offset: -2px; }

.chat-demo-note {
  padding: 7px 16px; font-size: 12px; line-height: 1.4;
  background: var(--st-amber-bg); color: var(--st-amber); border-bottom: 1px solid #ecdcb8;
}

/* ---- Messages ---- */
.chat-body {
  position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 14px; background: var(--ivory);
}
.chat-body:focus-visible { outline-offset: -2px; }
.chat-msg { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.chat-msg.is-new, .chat-typing { animation: chat-rise 0.18s ease-out; }
.chat-msg.from-user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-col { display: flex; flex-direction: column; min-width: 0; }
.from-user .chat-msg-col { align-items: flex-end; }
.chat-msg-avatar {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--green-soft); color: var(--green); margin-bottom: 20px;
}
.chat-bubble {
  padding: 10px 14px; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere;
  border-radius: 16px; background: var(--paper); border: 1px solid var(--line);
}
.from-bot .chat-bubble { border-bottom-left-radius: 4px; }
.from-user .chat-bubble { background: var(--green); border-color: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.from-user.is-error .chat-bubble { background: var(--st-red-bg); border-color: #e8c2ba; color: var(--ink); }
.chat-msg-meta { display: flex; align-items: center; gap: 8px; min-height: 20px; padding: 3px 4px 0; font-size: 11.5px; color: var(--muted); }
.chat-mock-tag {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; padding: 1px 7px; border-radius: 999px;
  background: var(--st-amber-bg); color: var(--st-amber);
}
.chat-msg-error { color: var(--st-red); display: inline-flex; align-items: center; gap: 6px; }
.chat-retry {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; cursor: pointer;
  font-size: 11.5px; font-weight: 700; color: var(--st-red); text-decoration: underline; text-underline-offset: 2px;
}

/* typing */
.chat-typing .chat-msg-avatar { margin-bottom: 0; }
.chat-dots { display: inline-flex; gap: 4px; padding: 5px 2px; }
.chat-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--sage); animation: chat-dot 1.2s infinite ease-in-out; }
.chat-dots i:nth-child(2) { animation-delay: 0.15s; }
.chat-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* quick prompts */
.chat-quick { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 34px; }
.chat-chip {
  border: 1px solid var(--green); background: var(--paper); color: var(--green-dark); cursor: pointer;
  border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; transition: background 0.15s, color 0.15s;
}
.chat-chip:hover { background: var(--green); color: #fff; }

/* loading + connection error */
.chat-loading, .chat-state-error {
  margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px;
  font-size: 14px; color: var(--ink-2); padding: 24px;
}
.chat-state-error p { max-width: 260px; }
.chat-spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid var(--green-soft); border-top-color: var(--green); animation: chat-spin 0.8s linear infinite;
}
@keyframes chat-spin { to { transform: rotate(360deg); } }

/* end-chat confirmation */
.chat-confirm { padding: 14px 16px 16px; border-top: 1px solid var(--line); background: var(--paper); font-size: 14px; }
.chat-confirm-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* ---- Composer ---- */
.chat-compose {
  display: flex; align-items: flex-end; gap: 8px; padding: 12px 12px 6px 16px;
  border-top: 1px solid var(--line); background: var(--paper);
}
.chat-compose textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 132px; padding: 11px 14px;
  border: 1px solid var(--line-strong); border-radius: 22px; background: #fff;
  font-size: 15px; line-height: 1.4; overflow-y: hidden; transition: border-color 0.15s;
}
.chat-compose textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.chat-compose textarea:disabled { background: var(--cream); }
.chat-send {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--green); color: #fff; transition: background 0.15s, opacity 0.15s;
}
.chat-send:hover { background: var(--green-dark); }
.chat-send:disabled { opacity: 0.4; cursor: default; background: var(--green); }
.chat-foot { padding: 0 16px 10px; font-size: 11px; color: var(--muted); background: var(--paper); text-align: center; }

/* ---- Mobile: window becomes a full-screen sheet ---- */
@media (max-width: 600px) {
  .chat-root { --chat-gap: 16px; right: var(--chat-gap); bottom: calc(var(--chat-gap) + env(safe-area-inset-bottom)); }
  .chat-launcher { width: 56px; height: 56px; }
  .chat-greeting { max-width: calc(100vw - 32px); }
  .chat-window {
    position: fixed; inset: 0; width: 100%; height: 100dvh; border: 0; border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .chat-head { padding-top: calc(14px + env(safe-area-inset-top)); }
  .chat-root.is-open .chat-launcher, .chat-root.is-open .chat-greeting { display: none; }
  html.chat-open, html.chat-open body { overflow: hidden; }
  .chat-compose textarea { font-size: 16px; } /* no iOS zoom on focus */
  .chat-msg { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-root *, .chat-root *::before { animation: none !important; transition: none !important; }
}

/* links to shop pages inside replies */
.chat-bubble a { color: var(--green-dark); font-weight: 600; text-underline-offset: 2px; }
.from-user .chat-bubble a { color: #fff; }

/* ---- Order form inside the chat ---- */
.chat-order {
  margin-left: 34px; padding: 14px; border-radius: 14px; background: var(--paper);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  font-size: 13.5px;
}
.co-head { display: flex; gap: 12px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.co-head img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; }
.co-head strong { display: block; font-family: var(--font-display); font-size: 20px; font-weight: 600; line-height: 1.15; }
.co-head span { font-size: 12px; color: var(--muted); }
.co-group { border: 0; margin: 0; padding: 12px 0 0; min-width: 0; }
.co-group legend, .co-label { padding: 0; margin-bottom: 7px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.co-group legend span { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted); margin-left: 4px; }
.co-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.co-chip { position: relative; cursor: pointer; }
.co-chip input { position: absolute; opacity: 0; pointer-events: none; }
.co-chip > span {
  display: flex; flex-direction: column; padding: 6px 11px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: #fff; transition: border-color 0.15s, background 0.15s;
}
.co-chip strong { font-size: 13px; font-weight: 600; }
.co-chip small { font-size: 11.5px; color: var(--muted); }
.co-chip:hover > span { border-color: var(--green); }
.co-chip input:checked + span { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.co-chip input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }

.co-qty-row { display: flex; align-items: center; justify-content: space-between; }
.co-qty-row .co-label { margin: 0; }
.co-stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; }
.co-stepper button { width: 34px; height: 34px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.co-stepper button:hover { background: var(--cream); }
.co-stepper output { min-width: 26px; text-align: center; font-weight: 700; }

.co-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.co-switch input { position: absolute; opacity: 0; pointer-events: none; }
.co-switch-track { position: relative; width: 36px; height: 21px; border-radius: 999px; background: var(--line-strong); transition: background 0.15s; flex: none; }
.co-switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.15s; }
.co-switch input:checked + .co-switch-track { background: var(--green); }
.co-switch input:checked + .co-switch-track::after { transform: translateX(15px); }
.co-switch input:focus-visible + .co-switch-track { outline: 2px solid var(--green); outline-offset: 2px; }

.co-card-box { margin-top: 10px; }
.co-card-box textarea {
  width: 100%; resize: vertical; min-height: 64px; padding: 9px 12px; font-size: 14px; line-height: 1.4;
  border: 1px solid var(--line-strong); border-radius: 10px; background: #fff;
}
.co-card-box textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.co-card-meta { display: flex; justify-content: flex-end; font-size: 11px; color: var(--muted); margin-top: 2px; }
.co-preview { margin: 8px 0 0; }
.co-paper {
  position: relative; width: 100%; padding: 9% 9% 14%; border-radius: 4px; overflow: hidden;
  background: linear-gradient(135deg, #fffdf6 0%, #f8f1e3 100%);
  border: 1px solid #e8dcc4; box-shadow: 0 1px 2px rgba(35, 37, 31, 0.08), 0 8px 18px rgba(35, 37, 31, 0.08);
  transform: rotate(-1deg);
}
.co-paper::before { content: ''; position: absolute; inset: 6px; border: 1px solid rgba(79, 107, 78, 0.25); border-radius: 2px; pointer-events: none; }
.co-paper-text {
  height: 100%; margin: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  font-family: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive; font-weight: 500; line-height: 1.15;
  color: #2b3350; white-space: pre-wrap; overflow-wrap: anywhere; overflow: hidden;
}
.co-paper-text.is-placeholder { color: #b8ae9c; }
.co-paper-brand { position: absolute; left: 0; right: 0; bottom: 6%; text-align: center; font-family: var(--font-display); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--sage); }
.co-preview figcaption { margin-top: 8px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }

.co-error { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--st-red-bg); color: var(--st-red); font-size: 12.5px; }
.co-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.co-total span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.co-total strong { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1; }
.chat-order .btn-sm { height: 38px; padding: 0 16px; font-size: 13.5px; }

.co-done { display: flex; gap: 10px; align-items: flex-start; }
.co-done-icon { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.co-done strong { display: block; font-size: 14px; }
.co-done p { color: var(--ink-2); margin-top: 2px; }
.co-done-card { font-family: 'Caveat', cursive; font-size: 18px; color: #2b3350 !important; }
.co-next { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.co-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chat-order:not(.is-mounted) { animation: chat-rise 0.2s ease-out; }
@media (max-width: 600px) { .chat-order { margin-left: 0; } }

/* ---- Order wizard: steps, fields, review ---- */
.co-steps { display: flex; gap: 6px; list-style: none; margin: 0 0 12px; padding: 0; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.co-steps li { flex: 1; display: flex; align-items: center; gap: 6px; padding-bottom: 8px; border-bottom: 2px solid var(--line); }
.co-steps li span { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; background: var(--cream); color: var(--ink-2); flex: none; }
.co-steps li span svg { width: 11px; height: 11px; }
.co-steps .is-current { color: var(--green-dark); border-color: var(--green); }
.co-steps .is-current span { background: var(--green); color: #fff; }
.co-steps .is-done { color: var(--ink-2); border-color: var(--sage); }
.co-steps .is-done span { background: var(--green-soft); color: var(--green); }

.co-hint { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.co-fields { display: flex; flex-direction: column; gap: 8px; }
.co-field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 3px; }
.co-field label span { font-weight: 400; color: var(--muted); }
.co-field input, .co-field select, .co-field textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px;
  background: #fff; font-size: 14px;
}
.co-field textarea { height: auto; padding: 8px 11px; resize: vertical; line-height: 1.4; }
.co-field input:focus, .co-field select:focus, .co-field textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.co-field.has-error input, .co-field.has-error select { border-color: var(--st-red); }
.co-field-error { display: block; margin-top: 3px; font-size: 11.5px; color: var(--st-red); }
.co-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.co-recipient { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.co-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.co-check input { width: 16px; height: 16px; accent-color: var(--green); }

.co-back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 6px 0; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.co-back:hover { color: var(--ink); }
.co-link { display: block; margin: 10px auto 0; border: 0; background: none; cursor: pointer; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.co-link:hover { color: var(--green-dark); }

.co-review { margin: 0; display: flex; flex-direction: column; gap: 0; }
.co-review > div { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.co-review dt { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.co-review dd { margin: 0; line-height: 1.4; }
.co-review small { color: var(--muted); font-size: 11.5px; }
.co-hand { font-family: 'Caveat', cursive; font-style: normal; font-size: 18px; color: #2b3350; }
.co-edit { border: 0; background: none; padding: 0; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--green-dark); text-decoration: underline; text-underline-offset: 2px; }
.co-pay { display: flex; flex-direction: column; gap: 6px; }
.co-chip-wide > span { width: 100%; }
.co-group.has-error .co-pay .co-chip > span { border-color: #e2b4ab; }
.co-sum { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--ivory); }
.co-sum > div { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.co-sum dt { color: var(--ink-2); }
.co-sum dd { margin: 0; }
.co-sum-total { margin-top: 4px; padding-top: 6px !important; border-top: 1px solid var(--line); font-weight: 700; }
.co-sum-total dd { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.co-placed strong { font-size: 15px; }
.co-count.is-over { color: var(--st-red); font-weight: 600; }
.co-chip .demo-tag { font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--st-amber); background: var(--st-amber-bg); padding: 1px 6px; border-radius: 999px; margin-left: 4px; }
