/* TastyHouse AI Assistant on the website (TastyHouse Mobile API 1.12.0).
   The floating chat and "Write it for me", drawn with the theme's own tokens (prototype.css :root). */

.thm-ai, .thm-ai * { box-sizing: border-box; }
.thm-ai { font-family: var(--font-body, system-ui, sans-serif); color: var(--ink, #1E1E1E); }
.thm-ai button { font: inherit; }

/* The button. Chaty's WhatsApp bubble lives bottom-left, so this one sits bottom-right. */
.thm-ai-fab {
  /* --thm-ai-lift: the height of the theme's mobile tab bar when it shows (ai-chat.js). */
  position: fixed; right: 20px; bottom: calc(20px + var(--thm-ai-lift, 0px)); z-index: 99990; display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 20px 0 8px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--primary, #F26A1B); color: #fff; box-shadow: 0 10px 28px rgba(242, 106, 27, .38), 0 2px 6px rgba(0,0,0,.12);
  transition: transform .15s ease, box-shadow .15s ease;
}
.thm-ai-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(242, 106, 27, .45), 0 2px 6px rgba(0,0,0,.12); }
.thm-ai-fab:focus-visible { outline: 3px solid var(--primary-700, #C2500F); outline-offset: 3px; }
.thm-ai-fab-disc { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.18); display: inline-flex; align-items: center; justify-content: center; }
.thm-ai-fab-label { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.thm-ai-fab[hidden] { display: none; }
@media (max-width: 640px) {
  .thm-ai-fab { right: 14px; bottom: calc(14px + var(--thm-ai-lift, 0px)); height: 52px; padding: 0 6px; width: 52px; justify-content: center; }
  .thm-ai-fab-label { display: none; }
  .thm-ai-fab-disc { background: none; }
}

/* The panel */
.thm-ai-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 99991; width: 400px; height: min(660px, calc(100vh - 40px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg, #FBF7F2); border: 1px solid var(--line, #ECE6DE); border-radius: var(--r-xl, 22px);
  box-shadow: var(--shadow-lg, 0 24px 60px rgba(0,0,0,.25));
  animation: thm-ai-in .18s ease-out;
}
.thm-ai-panel[hidden] { display: none; }
@keyframes thm-ai-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  .thm-ai-panel { inset: 0; right: 0; bottom: 0; width: 100%; height: 100%; border-radius: 0; border: 0; }
  html.thm-ai-open { overflow: hidden; }
}

.thm-ai-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 12px; background: var(--surface, #fff); border-bottom: 1px solid var(--line, #ECE6DE); }
.thm-ai-avatar { flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; background: var(--primary, #F26A1B); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.thm-ai-title { flex: 1; min-width: 0; }
.thm-ai-title b { display: block; font-family: var(--font-display, inherit); font-size: 17px; line-height: 1.2; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thm-ai-title span { display: block; font-size: 12.5px; color: var(--ink-3, #7a7a7a); }
.thm-ai-icon {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line, #ECE6DE); background: var(--surface, #fff);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2, #4a4a4a); cursor: pointer;
}
.thm-ai-icon:hover { border-color: var(--primary, #F26A1B); color: var(--primary, #F26A1B); }

.thm-ai-menu { position: absolute; top: 62px; right: 56px; z-index: 3; min-width: 210px; padding: 6px; background: var(--surface, #fff); border: 1px solid var(--line, #ECE6DE); border-radius: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.14); }
.thm-ai-menu[hidden] { display: none; }
.thm-ai-menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: 10px; background: none; text-align: left; font-size: 14.5px; color: var(--ink, #1E1E1E); cursor: pointer; }
.thm-ai-menu button:hover { background: var(--bg-2, #F1EBE3); }

.thm-ai-loc { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 13px; color: var(--ink-2, #4a4a4a); background: var(--bg-2, #F1EBE3); border-bottom: 1px solid var(--line, #ECE6DE); }
.thm-ai-loc b { color: var(--ink, #1E1E1E); font-weight: 600; }
.thm-ai-loc button { margin-left: auto; border: 0; background: none; padding: 2px 0; color: var(--primary-700, #C2500F); font-weight: 600; font-size: 13px; cursor: pointer; }

.thm-ai-body { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; }

/* Messages */
.thm-ai-msg { display: flex; flex-direction: column; gap: 8px; max-width: 100%; }
.thm-ai-msg.me { align-items: flex-end; }
.thm-ai-bubble { max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.5; word-wrap: break-word; overflow-wrap: anywhere; }
.thm-ai-msg.me .thm-ai-bubble { background: var(--primary, #F26A1B); color: #fff; border-bottom-right-radius: 6px; }
.thm-ai-msg.bot .thm-ai-bubble { background: var(--surface, #fff); border: 1px solid var(--line, #ECE6DE); border-bottom-left-radius: 6px; }
.thm-ai-msg.note .thm-ai-bubble { background: var(--secondary-soft, #E3F1EC); border: 0; color: var(--secondary-700, #0F5C47); }
.thm-ai-bubble p { margin: 0 0 8px; }
.thm-ai-bubble p:last-child, .thm-ai-bubble ul:last-child { margin-bottom: 0; }
.thm-ai-bubble ul { margin: 0 0 8px; padding-left: 18px; }
.thm-ai-bubble li { margin: 2px 0; }
.thm-ai-bubble strong { font-weight: 700; }
.thm-ai-photos { display: flex; gap: 6px; }
.thm-ai-photos span { font-size: 12px; color: var(--ink-3, #7a7a7a); }

/* Cards */
.thm-ai-cards { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; scroll-snap-type: x mandatory; }
.thm-ai-card {
  flex: 0 0 210px; scroll-snap-align: start; display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: var(--surface, #fff); border: 1px solid var(--line, #ECE6DE); border-radius: var(--r-lg, 18px); overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.thm-ai-card:hover { border-color: var(--primary, #F26A1B); transform: translateY(-1px); }
.thm-ai-card-img { position: relative; height: 118px; background: var(--bg-2, #F1EBE3) center/cover no-repeat; }
.thm-ai-card-img.logo { background-size: contain; background-color: var(--surface, #fff); border-bottom: 1px solid var(--line, #ECE6DE); }
.thm-ai-card-tags { position: absolute; left: 8px; top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.thm-ai-tag { padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: rgba(255,255,255,.94); color: var(--ink, #1E1E1E); }
.thm-ai-tag.promo { background: var(--ink, #1E1E1E); color: #fff; }
.thm-ai-tag.deal { background: var(--primary, #F26A1B); color: #fff; }
.thm-ai-card-t { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.thm-ai-card-t b { font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thm-ai-price { font-weight: 800; color: var(--primary-700, #C2500F); font-size: 14.5px; }
.thm-ai-was { font-weight: 500; color: var(--ink-3, #7a7a7a); text-decoration: line-through; font-size: 12px; margin-left: 4px; }
.thm-ai-meta { font-size: 12.5px; color: var(--ink-3, #7a7a7a); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thm-ai-meta .ok { color: var(--secondary, #138A6A); font-weight: 700; }

.thm-ai-locs, .thm-ai-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.thm-ai-loccard {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 14px; cursor: pointer; text-align: left;
  border: 1px solid var(--line, #ECE6DE); background: var(--surface, #fff); color: var(--ink, #1E1E1E); font-size: 13.5px;
}
.thm-ai-loccard:hover { border-color: var(--primary, #F26A1B); }
.thm-ai-loccard small { display: block; color: var(--ink-3, #7a7a7a); font-size: 12px; }
.thm-ai-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 999px; cursor: pointer; text-decoration: none;
  border: 1.5px solid var(--primary, #F26A1B); background: var(--surface, #fff); color: var(--primary-700, #C2500F); font-weight: 700; font-size: 13.5px;
}
.thm-ai-btn:hover { background: var(--primary-soft, #FDEBDC); }
.thm-ai-btn.solid { background: var(--primary, #F26A1B); color: #fff; }

/* Suggestions, feedback */
.thm-ai-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.thm-ai-chip {
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 13.5px; text-align: left;
  border: 1px solid var(--line-2, #E2DACF); background: var(--surface, #fff); color: var(--ink, #1E1E1E);
}
.thm-ai-chip:hover { border-color: var(--primary, #F26A1B); color: var(--primary-700, #C2500F); }
.thm-ai-fb { display: flex; align-items: center; gap: 2px; margin-top: -2px; }
.thm-ai-fb button { border: 0; background: none; padding: 4px 6px; border-radius: 8px; color: var(--ink-3, #7a7a7a); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.thm-ai-fb button:hover, .thm-ai-fb button.on { color: var(--primary-700, #C2500F); background: var(--bg-2, #F1EBE3); }
.thm-ai-fb .thanks { font-size: 12px; color: var(--ink-3, #7a7a7a); margin-left: 6px; }

/* Welcome */
.thm-ai-welcome { display: flex; flex-direction: column; gap: 12px; }
.thm-ai-modes { display: inline-flex; align-self: flex-start; padding: 3px; border-radius: 999px; background: var(--bg-2, #F1EBE3); }
.thm-ai-modes button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-2, #4a4a4a); cursor: pointer; }
.thm-ai-modes button.on { background: var(--surface, #fff); color: var(--ink, #1E1E1E); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* Consent */
.thm-ai-consent { margin: auto 0; padding: 18px; border-radius: var(--r-lg, 18px); background: var(--surface, #fff); border: 1px solid var(--line, #ECE6DE); display: flex; flex-direction: column; gap: 10px; }
.thm-ai-consent h3 { margin: 0; font-family: var(--font-display, inherit); font-size: 18px; }
.thm-ai-consent p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ink-2, #4a4a4a); }
.thm-ai-consent a { color: var(--primary-700, #C2500F); }

/* Typing */
.thm-ai-typing { display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 18px; background: var(--surface, #fff); border: 1px solid var(--line, #ECE6DE); font-size: 13px; color: var(--ink-3, #7a7a7a); align-self: flex-start; }
.thm-ai-dots { display: inline-flex; gap: 4px; }
.thm-ai-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary, #F26A1B); opacity: .35; animation: thm-ai-dot 1.1s infinite ease-in-out; }
.thm-ai-dots i:nth-child(2) { animation-delay: .15s; }
.thm-ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes thm-ai-dot { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
.thm-ai-error { align-self: stretch; padding: 10px 12px; border-radius: 12px; background: #FDECEC; color: #9B1C1C; font-size: 13.5px; display: flex; align-items: center; gap: 10px; }
.thm-ai-error button { margin-left: auto; border: 0; background: none; color: #9B1C1C; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* Composer */
.thm-ai-foot { padding: 10px 12px 12px; background: var(--surface, #fff); border-top: 1px solid var(--line, #ECE6DE); }
.thm-ai-attach { display: flex; gap: 8px; margin-bottom: 8px; }
.thm-ai-attach[hidden] { display: none; }
.thm-ai-thumb { position: relative; width: 52px; height: 52px; border-radius: 10px; background: center/cover no-repeat var(--bg-2, #F1EBE3); }
.thm-ai-thumb button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--ink, #1E1E1E); color: #fff; font-size: 12px; line-height: 20px; cursor: pointer; padding: 0; }
.thm-ai-compose { display: flex; align-items: flex-end; gap: 8px; }
.thm-ai-compose textarea {
  flex: 1; min-width: 0; resize: none; max-height: 120px; min-height: 44px; padding: 11px 14px; border-radius: 22px; outline: 0;
  border: 1px solid var(--line-2, #E2DACF); background: var(--bg-2, #F1EBE3); font: inherit; font-size: 15px; line-height: 1.4; color: var(--ink, #1E1E1E);
}
.thm-ai-compose textarea:focus { border-color: var(--primary, #F26A1B); background: var(--surface, #fff); }
.thm-ai-send { flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--primary, #F26A1B); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.thm-ai-send:disabled { opacity: .45; cursor: default; }
.thm-ai-note { margin: 6px 4px 0; font-size: 11.5px; color: var(--ink-3, #7a7a7a); text-align: center; }

/* "Write it for me" on the Add listing form */
.thm-ai-writer { display: flex; flex-direction: column; gap: 10px; margin: 0 0 4px; }
.thm-ai-writer-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thm-ai-writer-bar span { font-size: 12.5px; color: var(--ink-3, #7a7a7a); }
.thm-ai-writer-out { padding: 14px; border-radius: 16px; background: var(--primary-soft, #FDEBDC); border: 1px solid var(--primary, #F26A1B); display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.thm-ai-writer-out b { font-size: 15px; }
.thm-ai-writer-out p { margin: 0; white-space: pre-line; line-height: 1.5; }
.thm-ai-writer-out ul { margin: 0; padding-left: 18px; color: var(--ink-2, #4a4a4a); font-size: 13px; }
.thm-ai-writer-out .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.thm-ai-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: thm-ai-spin .7s linear infinite; }
@keyframes thm-ai-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .thm-ai-panel, .thm-ai-dots i, .thm-ai-spin { animation: none; }
  .thm-ai-fab, .thm-ai-card { transition: none; }
}
