/* העוזר של תומר (בוט): כפתור צף וחלון שיחה. משתמש בצבעים ובפונטים של style.css */

/* הכפתור הצף של הצ'אט מחליף את כפתור הוואטסאפ הצף (הוואטסאפ נמצא בראש חלון הצ'אט) */
.has-chat .wa-float { display: none; }
.adm-open .chat { display: none; }

.chat { font-family: var(--font-body); color: var(--ink); }
.chat svg { display: block; width: 100%; height: 100%; }
.chat__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chat button { font: inherit; }
.chat :focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

/* ---------- הכפתור הצף ---------- */
.chat__launcher {
  position: fixed; left: 18px; bottom: 18px; z-index: 70;
  width: 66px; height: 66px; padding: 0; border: 0; border-radius: 50%;
  background: #fff; cursor: pointer;
  box-shadow: 0 12px 28px color-mix(in srgb, var(--teal) 45%, transparent);
  transition: transform .2s ease;
}
.chat__launcher::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--teal); opacity: .4; animation: chat-pulse 2.6s ease-out infinite; z-index: -1; }
.chat--open .chat__launcher::before { animation: none; opacity: 0; }
.chat__launcher:hover { transform: translateY(-2px); }
.chat__launcher-face { display: block; width: 100%; height: 100%; }
.chat__launcher-tag {
  position: absolute; top: -6px; right: -8px;
  padding: 2px 9px; border-radius: 999px; border: 2px solid #fff;
  font-size: 13px; font-weight: 800; line-height: 1.4; color: var(--ink); background: var(--yellow);
}
@keyframes chat-pulse { from { transform: scale(1); opacity: .4; } to { transform: scale(1.6); opacity: 0; } }

/* ---------- ההודעה הקטנה "שאלה?" ---------- */
.chat__teaser {
  position: fixed; left: 96px; bottom: 26px; z-index: 70;
  display: flex; align-items: flex-start; gap: 4px;
  max-width: min(270px, calc(100vw - 120px));
  padding: 12px 8px 12px 14px; border-radius: 22px 22px 22px 6px;
  background: #fff; box-shadow: var(--shadow-pop);
  animation: chat-in .35s ease both;
}
.chat__teaser[hidden] { display: none; }
.chat__teaser-text { padding: 0; border: 0; background: none; text-align: right; font-size: 16px; line-height: 1.4; color: var(--ink); cursor: pointer; }
.chat__teaser-text b { display: block; font-weight: 500; color: var(--muted); font-size: 15px; margin-top: 2px; }
.chat__teaser-x { flex: none; width: 30px; height: 30px; padding: 7px; border: 0; border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; }
.chat--open .chat__teaser { display: none; }

/* ---------- חלון השיחה ---------- */
.chat__panel {
  position: fixed; left: 18px; bottom: 98px; z-index: 71;
  display: flex; flex-direction: column;
  width: min(390px, calc(100vw - 36px));
  height: min(620px, calc(100dvh - 130px));
  border-radius: 26px; overflow: hidden;
  background: var(--bg);
  box-shadow: 0 30px 70px -20px color-mix(in srgb, var(--ink) 55%, transparent), 0 0 0 1px var(--line);
  animation: chat-in .28s ease both;
}
.chat__panel[hidden] { display: none; }
@keyframes chat-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.chat__head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 14px 12px;
  color: #fff; background: linear-gradient(140deg, var(--ink), color-mix(in srgb, var(--teal) 45%, var(--ink)));
}
.chat__face { flex: none; width: 46px; height: 46px; border-radius: 50%; box-shadow: 0 0 0 3px rgb(255 255 255 / .18); }
.chat__who { flex: 1; min-width: 0; line-height: 1.3; }
.chat__who b { display: block; font-family: var(--font-head); font-weight: 800; font-size: 18px; }
.chat__who span { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--on-dark); opacity: .9; }
.chat__bot { font-style: normal; font-weight: 800; font-size: 12px; padding: 1px 8px; border-radius: 999px; color: var(--ink); background: var(--yellow); }
.chat__wa {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 6px 12px 6px 10px; border-radius: 999px;
  font-size: 14px; font-weight: 700; color: #fff; text-decoration: none;
  background: rgb(255 255 255 / .14); border: 1.5px solid rgb(255 255 255 / .35);
}
.chat__wa > span:first-child { width: 20px; height: 20px; }
.chat__wa:hover { background: rgb(255 255 255 / .24); }
.chat__x { flex: none; width: 40px; height: 40px; padding: 10px; border: 0; border-radius: 50%; color: #fff; background: transparent; cursor: pointer; }
.chat__x:hover { background: rgb(255 255 255 / .14); }

/* ---------- ההודעות ---------- */
.chat__log { flex: 1; overflow-y: auto; padding: 18px 14px 8px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.chat__row { display: flex; align-items: flex-end; gap: 8px; animation: chat-in .25s ease both; }
.chat__row--me { justify-content: flex-end; }
.chat__mini { flex: none; width: 30px; height: 30px; }
.chat__msg { max-width: 84%; }
.chat__msg p {
  margin: 0; padding: 11px 15px; white-space: pre-line;
  font-size: 16px; line-height: 1.55;
  border-radius: 20px 20px 20px 6px;
}
.chat__row--bot .chat__msg p { background: #fff; border-radius: 20px 20px 6px 20px; box-shadow: var(--shadow-card); }
.chat__row--me .chat__msg p { color: #fff; background: var(--ink); border-radius: 20px 20px 20px 6px; }
.chat__row--typing .chat__mini { visibility: hidden; }
.chat__dots { display: inline-flex; gap: 5px; padding: 15px 16px; border-radius: 20px 20px 6px 20px; background: #fff; box-shadow: var(--shadow-card); }
.chat__dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); animation: chat-dot 1s ease-in-out infinite; }
.chat__dots i:nth-child(2) { animation-delay: .15s; }
.chat__dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

/* כפתורי פעולה מתחת לתשובה */
.chat__acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chat__act {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 999px;
  font-size: 15px; font-weight: 700; color: var(--ink); text-decoration: none; cursor: pointer;
  background: #fff; border: 2px solid var(--line);
}
.chat__act:hover { border-color: var(--ink); }
.chat__act svg { width: 18px; height: 18px; }
.chat__act--coral { border: 0; background: linear-gradient(135deg, var(--coral-l), var(--yellow)); box-shadow: 0 8px 18px color-mix(in srgb, var(--yellow) 40%, transparent); }
.chat__act--wa { border: 0; color: #fff; background: linear-gradient(135deg, color-mix(in srgb, var(--teal) 80%, #fff), var(--teal-d)); }
.chat__act--ink { border: 0; color: #fff; background: var(--ink); }
.chat__act:disabled { opacity: .6; cursor: default; }

/* ---------- שאלות נפוצות (כפתורים) ---------- */
.chat__chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 14px 12px; max-height: 42%; overflow-y: auto; }
.chat__chips[hidden] { display: none; }
.chat__chips--row { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; max-height: none; scrollbar-width: thin; padding-bottom: 10px; }
.chat__chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 7px 14px; border-radius: 999px;
  font-size: 15px; font-weight: 500; color: var(--ink); cursor: pointer;
  background: var(--pastel-2); border: 1.5px solid color-mix(in srgb, var(--teal) 35%, transparent);
  transition: background .2s;
}
.chat__chip:hover { background: color-mix(in srgb, var(--teal) 24%, #fff); }
.chat__chip svg { width: 16px; height: 16px; }
.chat__chip--ink { color: #fff; background: var(--ink); border-color: var(--ink); font-weight: 700; }
.chat__chip--ink:hover { background: color-mix(in srgb, var(--ink) 85%, var(--teal)); }

/* ---------- שורת הכתיבה ---------- */
.chat__form { display: flex; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); background: #fff; }
.chat__form input {
  flex: 1; min-width: 0; min-height: 46px; padding: 10px 16px; border-radius: 999px;
  font: inherit; font-size: 16px; color: var(--ink);
  border: 1.5px solid var(--line); background: var(--bg);
}
.chat__form input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 25%, transparent); }
.chat__send { flex: none; width: 46px; height: 46px; padding: 12px; border: 0; border-radius: 50%; color: var(--ink); background: linear-gradient(135deg, var(--coral-l), var(--yellow)); cursor: pointer; }

/* ---------- השארת פרטים בתוך השיחה ---------- */
.chat__lead { display: grid; gap: 8px; margin-top: 8px; padding: 14px; border-radius: 18px; background: var(--pastel-1); }
.chat__lead label { display: grid; gap: 3px; font-size: 14px; font-weight: 700; }
.chat__lead label[hidden] { display: none; }
.chat__lead input { min-height: 44px; padding: 8px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; font: inherit; font-size: 16px; color: var(--ink); }
.chat__lead input:focus { outline: none; border-color: var(--teal); }
.chat__lead .chat__act { justify-content: center; }
.chat__lead .chat__act[hidden] { display: none; }
.chat__trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.chat__lead-msg { margin: 0; font-size: 14px; color: var(--muted); }
.chat__lead-msg:empty { display: none; }
.chat__lead-msg--bad { color: var(--coral-d); font-weight: 700; }

/* ---------- טלפון: החלון ממלא את המסך מלמטה ---------- */
@media (max-width: 560px) {
  .chat__panel { left: 8px; right: 8px; bottom: 8px; width: auto; height: min(680px, calc(100dvh - 16px)); border-radius: 24px; }
  .chat--open .chat__launcher { display: none; }
  .chat__wa-text { display: none; }
  .chat__wa { padding: 6px; width: 40px; justify-content: center; }
  .chat__launcher { width: 60px; height: 60px; left: 14px; bottom: 14px; }
  .chat__teaser { left: 84px; bottom: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat__launcher::before, .chat__dots i { animation: none; }
  .chat__panel, .chat__row, .chat__teaser { animation: none; }
  .chat__launcher:hover { transform: none; }
}

@media print { .chat { display: none; } }

/* אחרי שליחה, הטופס נעלם (נשארת רק הודעת התודה) */
.chat__lead[data-done] { display: none; }
.chat__who span { flex-wrap: wrap; }
