/* ============================================================
   Celeste Finds – Chat Widget
   Uses CSS custom properties that inherit DaisyUI's theme vars
   (emerald / forest) so it adapts to light and dark mode
   automatically. No Tailwind rebuild required.
   ============================================================ */

/* ── Bubble ──────────────────────────────────────────────── */
#cf-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99990;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #047857; /* emerald-700 – matches light theme primary */
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(4,120,87,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  transition: transform .2s, box-shadow .2s;
  outline-offset: 3px;
}
#cf-chat-bubble:hover  { transform: scale(1.08); box-shadow: 0 6px 28px rgba(4,120,87,.55); }
#cf-chat-bubble:focus  { outline: 3px solid #6ee7b7; }

#cf-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #dc2626;
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  display: none;
}
#cf-chat-badge.visible { display: flex; }

/* ── Panel ───────────────────────────────────────────────── */
#cf-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 99989;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100dvh - 110px);
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(.95) translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), opacity .18s ease;
}
#cf-chat-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────── */
#cf-chat-header {
  background: #047857;
  color: #fff;
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#cf-chat-header .cf-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #6ee7b7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
#cf-chat-header .cf-title { font-weight: 700; font-size: .92rem; flex: 1; }
#cf-chat-header .cf-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6ee7b7;
  box-shadow: 0 0 0 2px rgba(110,231,183,.35);
  animation: cfPulse 2s infinite;
}
#cf-chat-header .cf-status-dot.human { background: #fbbf24; box-shadow: 0 0 0 2px rgba(251,191,36,.35); }
#cf-chat-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.75);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  line-height: 1;
  border-radius: 6px;
  transition: background .15s;
}
#cf-chat-close:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ── Messages ────────────────────────────────────────────── */
#cf-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  background: #f8fafc;
}
#cf-chat-messages::-webkit-scrollbar { width: 4px; }
#cf-chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.cf-msg-row { display: flex; align-items: flex-end; gap: 6px; }
.cf-msg-row.cf-from-bot   { justify-content: flex-start; }
.cf-msg-row.cf-from-user  { justify-content: flex-end; }
.cf-msg-row.cf-from-admin { justify-content: flex-start; }

.cf-msg-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: .84rem;
  line-height: 1.45;
  word-break: break-word;
}
.cf-from-bot   .cf-msg-bubble { background: #e0f2fe; color: #0c4a6e; border-bottom-left-radius: 4px; }
.cf-from-user  .cf-msg-bubble { background: #047857; color: #fff;     border-bottom-right-radius: 4px; }
.cf-from-admin .cf-msg-bubble { background: #fef3c7; color: #78350f;  border-bottom-left-radius: 4px; }

.cf-msg-time { font-size: .6rem; color: #9ca3af; margin-top: 2px; }
.cf-from-user .cf-msg-time { text-align: right; }

/* ── Typing indicator ────────────────────────────────────── */
#cf-typing-indicator {
  display: none;
  padding: 4px 0 4px 6px;
}
#cf-typing-indicator.visible { display: flex; }
#cf-typing-indicator .cf-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  background: #e0f2fe;
  padding: 8px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
#cf-typing-indicator .cf-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #0c4a6e;
  animation: cfBounce .9s infinite ease-in-out;
  opacity: .6;
}
#cf-typing-indicator .cf-dot:nth-child(2) { animation-delay: .15s; }
#cf-typing-indicator .cf-dot:nth-child(3) { animation-delay: .30s; }

/* ── Result cards ────────────────────────────────────────── */
.cf-cards-wrap { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.cf-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 9px 11px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  text-decoration: none;
}
.cf-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.1); border-color: #6ee7b7; }
.cf-card-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: #f3f4f6; }
.cf-card-placeholder { width: 52px; height: 52px; border-radius: 8px; flex-shrink: 0; background: #d1fae5; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.cf-card-body { flex: 1; min-width: 0; }
.cf-card-code { display: inline-block; font-size: .65rem; font-weight: 700; letter-spacing: .04em; color: #047857; background: #d1fae5; border-radius: 4px; padding: 1px 5px; margin-bottom: 3px; }
.cf-card-title { font-size: .8rem; font-weight: 700; color: #1a202c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cf-card-excerpt { font-size: .72rem; color: #6b7280; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cf-card-cta { font-size: .7rem; font-weight: 700; color: #047857; margin-top: 5px; }

/* ── Status bar (human mode) ─────────────────────────────── */
#cf-status-bar {
  display: none;
  background: #fef3c7;
  color: #78350f;
  font-size: .73rem;
  padding: 5px 14px;
  text-align: center;
  flex-shrink: 0;
  font-weight: 600;
}
#cf-status-bar.visible { display: block; }

/* ── Input area ──────────────────────────────────────────── */
#cf-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #f0f0f0;
  background: #fff;
  flex-shrink: 0;
}
#cf-chat-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 22px;
  padding: 9px 14px;
  font-size: .85rem;
  outline: none;
  resize: none;
  height: 40px;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.3;
  background: #f9fafb;
  transition: border-color .15s, background .15s;
}
#cf-chat-input:focus { border-color: #047857; background: #fff; }
#cf-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #047857;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
#cf-chat-send:hover   { background: #065f46; }
#cf-chat-send:active  { transform: scale(.92); }
#cf-chat-send:disabled { background: #9ca3af; cursor: not-allowed; }

/* ── Dark mode (DaisyUI forest theme) ───────────────────── */
[data-theme="forest"] #cf-chat-panel {
  background: #1a2e1a;
  box-shadow: 0 8px 40px rgba(0,0,0,.45);
}
[data-theme="forest"] #cf-chat-messages        { background: #1f2d1f; }
[data-theme="forest"] .cf-from-bot .cf-msg-bubble  { background: #1e3a2e; color: #a7f3d0; }
[data-theme="forest"] .cf-from-user .cf-msg-bubble { background: #047857; color: #fff; }
[data-theme="forest"] .cf-from-admin .cf-msg-bubble { background: #3d2b00; color: #fde68a; }
[data-theme="forest"] #cf-chat-input-area      { background: #1a2e1a; border-top-color: #2d3d2d; }
[data-theme="forest"] #cf-chat-input           { background: #253525; border-color: #3d533d; color: #e5e7eb; }
[data-theme="forest"] #cf-chat-input:focus     { background: #2a3d2a; border-color: #6ee7b7; }
[data-theme="forest"] #cf-typing-indicator .cf-dots { background: #1e3a2e; }
[data-theme="forest"] #cf-typing-indicator .cf-dot  { background: #6ee7b7; }
[data-theme="forest"] .cf-card { background: #253525; border-color: #3d533d; }
[data-theme="forest"] .cf-card-title   { color: #e5e7eb; }
[data-theme="forest"] .cf-card-excerpt { color: #9ca3af; }
[data-theme="forest"] .cf-card-code    { background: #064e3b; color: #6ee7b7; }
[data-theme="forest"] #cf-status-bar   { background: #3d2b00; color: #fde68a; }
[data-theme="forest"] .cf-msg-time     { color: #6b7280; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes cfBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .6; }
  30%           { transform: translateY(-5px); opacity: 1; }
}
@keyframes cfPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  #cf-chat-panel {
    right: 0; bottom: 0;
    width: 100vw; max-width: 100vw;
    height: 90dvh; max-height: 90dvh;
    border-radius: 18px 18px 0 0;
    transform-origin: bottom center;
  }
  #cf-chat-bubble { bottom: 16px; right: 16px; }
}

/* ── Suggestion chips ("Did you mean?") ─────────────────── */
.cf-suggestions-row { align-items: flex-start; }
.cf-suggestion-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 0 2px 0; max-width: 100%;
}
.cf-suggestion-chip {
  display: inline-flex; align-items: center;
  padding: 5px 12px; border-radius: 999px;
  border: 1.5px solid #6ee7b7; background: #f0fdf4;
  color: #065f46; font-size: .76rem; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s;
  white-space: nowrap; line-height: 1.3;
}
.cf-suggestion-chip:hover { background: #d1fae5; border-color: #047857; }
.cf-suggestion-chip:active { background: #a7f3d0; }
[data-theme="forest"] .cf-suggestion-chip {
  background: #1a2e1a; border-color: #4ade80; color: #86efac;
}
[data-theme="forest"] .cf-suggestion-chip:hover { background: #2d3d2d; }

/* ── Filter tag breadcrumbs ──────────────────────────────── */
#cf-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-top: 1px solid #f0f4f0;
  background: #f0fdf4;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
#cf-filter-bar::-webkit-scrollbar { display: none; }
.cf-filter-label {
  font-size: .68rem;
  font-weight: 700;
  color: #047857;
  margin-right: 2px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.cf-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  border-radius: 999px;
  padding: 2px 8px 2px 9px;
  font-size: .73rem;
  font-weight: 600;
  color: #065f46;
  white-space: nowrap;
  cursor: default;
}
.cf-filter-subject {
  background: #047857;
  border-color: #047857;
  color: #fff;
}
.cf-filter-tag-text { line-height: 1.2; }
.cf-filter-remove {
  background: transparent;
  border: none;
  padding: 0 0 0 2px;
  margin: 0;
  font-size: .8rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: .65;
  transition: opacity .12s;
}
.cf-filter-remove:hover { opacity: 1; }
.cf-filter-subject .cf-filter-remove { color: #fff; }

[data-theme="forest"] #cf-filter-bar      { background: #1a2e1a; border-top-color: #2d3d2d; }
[data-theme="forest"] .cf-filter-tag      { background: #1e3a2e; border-color: #4ade80; color: #86efac; }
[data-theme="forest"] .cf-filter-subject  { background: #047857; border-color: #047857; color: #fff; }

/* ── @-Command Menu overlay ──────────────────────────────── */
#cf-cmd-menu {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  overflow: hidden;
}
.cf-cmd-header {
  padding: 5px 14px 4px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #9ca3af;
  border-bottom: 1px solid #f3f4f6;
}
#cf-cmd-list { display: flex; flex-direction: column; }
.cf-cmd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 7px 14px;
  cursor: pointer;
  transition: background .12s;
  border-bottom: 1px solid #f9fafb;
}
.cf-cmd-item:last-child { border-bottom: none; }
.cf-cmd-item:hover, .cf-cmd-item.cf-cmd-focused  { background: #f0fdf4; }
.cf-cmd-icon    { font-size: 1rem; width: 22px; text-align: center; flex-shrink: 0; }
.cf-cmd-trigger { font-size: .8rem; font-weight: 700; color: #047857; min-width: 80px; }
.cf-cmd-hint    { font-size: .76rem; color: #6b7280; }

[data-theme="forest"] #cf-cmd-menu            { background: #1a2e1a; border-top-color: #2d3d2d; }
[data-theme="forest"] .cf-cmd-header          { color: #6b7280; border-color: #2d3d2d; }
[data-theme="forest"] .cf-cmd-item            { border-color: #253525; color: #e5e7eb; }
[data-theme="forest"] .cf-cmd-item:hover,
[data-theme="forest"] .cf-cmd-item.cf-cmd-focused { background: #253525; }
[data-theme="forest"] .cf-cmd-trigger         { color: #4ade80; }
[data-theme="forest"] .cf-cmd-hint            { color: #9ca3af; }

/* ── Card number badge (QuickPick numbered mode) ───────── */
.cf-card { position: relative; }
.cf-card-num {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #047857;
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(4,120,87,.4);
  flex-shrink: 0;
  z-index: 1;
}
[data-theme="forest"] .cf-card-num { background: #4ade80; color: #052e16; }

/* ── QuickPick buttons [1] [2] [3] ─────────────────────── */
.cf-qp-buttons {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  padding: 2px 0;
}
.cf-qp-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: #f0fdf4;
  border: 1.5px solid #6ee7b7;
  border-radius: 10px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background .13s, border-color .13s;
}
.cf-qp-btn:hover  { background: #d1fae5; border-color: #047857; }
.cf-qp-btn:active { background: #a7f3d0; }
.cf-qp-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #047857;
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cf-qp-title {
  font-size: .78rem;
  font-weight: 600;
  color: #065f46;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
[data-theme="forest"] .cf-qp-btn   { background: #1a2e1a; border-color: #4ade80; }
[data-theme="forest"] .cf-qp-btn:hover { background: #253525; }
[data-theme="forest"] .cf-qp-num   { background: #4ade80; color: #052e16; }
[data-theme="forest"] .cf-qp-title { color: #86efac; }

/* ============================================================
   CF Code Badge — shared across product cards, specs table,
   compare page header cells
   ============================================================ */
.cf-code-badge {
  display: inline-block;
  font-family: ui-monospace, 'Cascadia Code', 'Fira Mono', monospace;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1;
  padding: 2px 7px;
  border-radius: 4px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #6ee7b7;
  user-select: all;
  vertical-align: middle;
  white-space: nowrap;
}
[data-theme="forest"] .cf-code-badge {
  background: #052e16;
  color: #6ee7b7;
  border-color: #4ade80;
}

/* ============================================================
   Specs block on single-product pages
   ============================================================ */
.cf-specs-block {
  margin-top: 1.25rem;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  overflow: hidden;
  font-size: .85rem;
}
.cf-specs-block table {
  width: 100%;
  border-collapse: collapse;
}
.cf-specs-block th,
.cf-specs-block td {
  padding: .45rem .75rem;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}
.cf-specs-block th {
  width: 40%;
  color: #6b7280;
  font-weight: 600;
  background: #f9fafb;
}
.cf-specs-block td { color: #111827; }
.cf-specs-block tr:last-child th,
.cf-specs-block tr:last-child td { border-bottom: none; }
[data-theme="forest"] .cf-specs-block { border-color: #2d4a2d; }
[data-theme="forest"] .cf-specs-block th { background: #1a2e1a; color: #9ca3af; }
[data-theme="forest"] .cf-specs-block td { color: #d1fae5; }
[data-theme="forest"] .cf-specs-block th,
[data-theme="forest"] .cf-specs-block td { border-color: #253525; }

/* ============================================================
   Compare-slot pill inside QuickPick
   ============================================================ */
.cf-compare-slot {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e40af;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  white-space: nowrap;
}
[data-theme="forest"] .cf-compare-slot { background: #1e3a5f; color: #93c5fd; }
.cf-compare-slot-x {
  cursor: pointer;
  opacity: .6;
  line-height: 1;
  padding: 0 2px;
}
.cf-compare-slot-x:hover { opacity: 1; }
