/* ==================================================================== AI ASSISTANT
   Her ask, 30 October 2026: an AI agent on elzatian.com that answers when a visitor clicks to
   chat, and that offers WhatsApp "the moment the viewers cannot get his answer in 2 questions".

   Everything is scoped under .aichat so no rule here can reach the rest of the site. The type is
   the site's own: paper ground, ink type, one accent. Nothing important is small or faint - she
   rejects faint text - and the two floating buttons never overlap: the AI button sits beside the
   WhatsApp button that is already on every page. */

.aichat { --ai-pad: clamp(14px, 2.4vw, 28px); }

/* Her instruction, 30 October 2026: "Don't show up when people don't click on ask ai button."
   The `hidden` attribute is only a default - any display rule in a stylesheet outranks it, and the
   panel below sets display: flex, so it was on screen on load. This keeps every part of the
   assistant out of the way until the visitor asks for it. */
.aichat [hidden] { display: none !important; }

.aichat__btn {
  position: fixed;
  right: calc(var(--ai-pad) + 70px);
  bottom: var(--ai-pad);
  z-index: 72;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 56px;
  padding: 0 20px 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .26);
  transition: transform .2s var(--ease-out), background .2s var(--ease-out);
}
.aichat__btn:hover { transform: translateY(-2px); background: #000; }
.aichat__btn:focus-visible { outline: 3px solid var(--accent, #C9301F); outline-offset: 3px; }
.aichat__btn svg { width: 22px; height: 22px; display: block; }
.aichat__btn-label { white-space: nowrap; }

/* ---------------------------------------------------------------- the panel */
.aichat__panel {
  position: fixed;
  right: var(--ai-pad);
  bottom: calc(var(--ai-pad) + 70px);
  z-index: 74;
  display: flex;
  flex-direction: column;
  width: min(392px, calc(100vw - 2 * var(--ai-pad)));
  max-height: min(620px, calc(100vh - 140px));
  background: var(--paper, #FCFBF9);
  border: 1px solid var(--line, rgba(10, 10, 10, .13));
  border-radius: 16px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .28);
  overflow: hidden;
}

.aichat__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ink);
  color: #fff;
}
.aichat__who { display: flex; gap: 10px; align-items: flex-start; }
.aichat__dot {
  width: 10px; height: 10px; margin-top: 6px; border-radius: 50%;
  background: #35C759; box-shadow: 0 0 0 3px rgba(53, 199, 89, .22);
}
.aichat__name { margin: 0; font-weight: 800; font-size: 16px; line-height: 1.25; }
.aichat__sub { margin: 2px 0 0; font-size: 13px; color: rgba(255, 255, 255, .82); line-height: 1.35; }
.aichat__close {
  flex: 0 0 auto; padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .34);
  background: transparent; color: #fff; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.aichat__close:hover { background: rgba(255, 255, 255, .12); }

.aichat__log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--page, #F4F3EF);
}
.aichat__msg { max-width: 88%; }
.aichat__msg p {
  margin: 0;
  padding: 11px 13px;
  border-radius: 13px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--body, #2B2A27);
  background: var(--surface, #fff);
  border: 1px solid var(--line-2, rgba(10, 10, 10, .07));
  white-space: pre-wrap;
}
.aichat__msg--bot { align-self: flex-start; }
.aichat__msg--me { align-self: flex-end; }
.aichat__msg--me p { background: var(--ink); color: #fff; border-color: transparent; }
.aichat__msg--wait p { color: var(--muted, #4F4B46); font-style: italic; }
.aichat__msg--miss p { border-left: 4px solid var(--accent, #C9301F); }

.aichat__chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 4px; padding: 0; }
.aichat__chips button {
  padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line-strong, rgba(10, 10, 10, .3));
  background: var(--surface, #fff); color: var(--ink); font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer;
}
.aichat__chips button:hover { background: var(--ink); color: #fff; }

/* The standing way out to WhatsApp, inside the panel. It is always there, so a visitor never has
   to hunt for it, and the pop-up card does the louder job after two unanswered questions. */
.aichat__wa {
  padding: 8px 16px 0;
  border-top: 1px solid var(--line-2, rgba(10, 10, 10, .07));
  background: var(--page, #F4F3EF);
}
.aichat__wa-link {
  display: block; padding: 9px 12px; border-radius: 10px; text-align: center;
  background: #25D366; color: #06331A; font-weight: 800; font-size: 14px; text-decoration: none;
}
.aichat__wa-link:hover { background: #1EBE5A; }

/* The close: the card that names what the visitor asked about and puts the message in their hand. */
.aichat__lead {
  margin: 0 16px 4px;
  padding: 12px 13px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
}
.aichat__lead-k { margin: 0; font-size: 14px; font-weight: 800; }
.aichat__lead-b { margin: 4px 0 10px; font-size: 13.5px; line-height: 1.45; color: rgba(255, 255, 255, .86); }
.aichat__lead-wa {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px;
  background: #25D366; color: #06331A; font-weight: 800; font-size: 14.5px; text-decoration: none;
}
.aichat__lead-wa:hover { background: #1EBE5A; }
.aichat__lead-wa svg { width: 19px; height: 19px; display: block; }

.aichat__form { padding: 10px 16px 14px; background: var(--page, #F4F3EF); }
.aichat__label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 800; color: var(--ink); }
.aichat__row { display: flex; gap: 8px; }
.aichat__in {
  flex: 1 1 auto; min-width: 0; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line-strong, rgba(10, 10, 10, .3)); background: var(--surface, #fff);
  font: inherit; font-size: 15px; color: var(--ink);
}
.aichat__in:focus-visible { outline: 3px solid var(--accent, #C9301F); outline-offset: 1px; }
.aichat__send {
  flex: 0 0 auto; padding: 11px 18px; border: 0; border-radius: 10px; background: var(--accent, #C9301F);
  color: #fff; font: inherit; font-weight: 800; font-size: 15px; cursor: pointer;
}
.aichat__send:hover { background: #A8240F; }
.aichat__send[disabled] { opacity: .55; cursor: default; }
.aichat__note { margin: 8px 0 0; font-size: 12.5px; line-height: 1.4; color: var(--muted, #4F4B46); }

/* --------------------------------------------------- the pop-up she asked for */
.aichat__pop {
  position: fixed;
  right: var(--ai-pad);
  bottom: calc(var(--ai-pad) + 70px);
  z-index: 75;
  width: min(344px, calc(100vw - 2 * var(--ai-pad)));
  padding: 16px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 20px 54px rgba(0, 0, 0, .34);
}
.aichat__pop-k { margin: 0; font-weight: 800; font-size: 17px; }
.aichat__pop-b { margin: 6px 0 12px; font-size: 14.5px; line-height: 1.45; color: rgba(255, 255, 255, .88); }
.aichat__pop-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.aichat__pop-wa {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 14px; border-radius: 10px;
  background: #25D366; color: #06331A; font-weight: 800; font-size: 15px; text-decoration: none;
}
.aichat__pop-wa:hover { background: #1EBE5A; }
.aichat__pop-wa svg { width: 20px; height: 20px; display: block; }
.aichat__pop-x {
  padding: 11px 14px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .34);
  background: transparent; color: #fff; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
}
.aichat__pop-x:hover { background: rgba(255, 255, 255, .12); }

@media (max-width: 560px) {
  .aichat__btn { height: 54px; padding: 0 16px 0 13px; font-size: 14px; right: calc(var(--ai-pad) + 64px); }
  .aichat__btn svg { width: 20px; height: 20px; }
  /* On a narrow phone the two buttons would crowd the row, so the AI button keeps its word only
     when there is room; the label stays in the markup for the reader that needs it. */
  /* Her instructions, 30 October 2026: first "Make the window smaller. This pop up too big.", then
     "Still big and not nice when i clicked ask ai." On a phone the panel was 392px wide and up to
     620px tall - nearly the whole screen - and the on-screen keyboard then covered the input. It is
     now a small card: 320px wide, at most 46dvh (36dvh once a field has focus, so the keyboard and
     the whole card fit together), with every padding inside pulled in so it reads as one light piece
     rather than a form. The reply area keeps its own scroll. */
  .aichat__panel {
    width: min(320px, calc(100vw - 2 * var(--ai-pad)));
    /* Tall enough to show the greeting AND the three starting questions, short enough to stay a card
       (45% of the screen on a 932px phone). Below this the reply area was squeezed to ~100px and cut
       the welcome sentence in half, which is what "not nice" looked like. */
    max-height: min(56dvh, 440px);
    border-radius: 14px;
  }
  /* while the visitor is typing, the panel steps out of the keyboard's way */
  .aichat--typing .aichat__panel { max-height: min(42dvh, 340px); }
  .aichat__head { padding: 11px 13px; }
  /* The panel is sized by its content, and the log has no height of its own - so on a phone the log
     came out about 110px and cut the last starting question in half. A floor keeps the greeting and
     all three starter questions fully readable. */
  .aichat__log { padding: 11px 11px 4px; min-height: 168px; }
  .aichat__msg { font-size: 14px; }
  .aichat__msg p { padding: 9px 11px; border-radius: 12px; }
  /* One line, swiped sideways: a wrapped block of three questions took three rows in a narrow panel
     and the last one was always half cut. Nothing is hidden - the row scrolls. */
  .aichat__chips { gap: 6px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px;
                   -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .aichat__chips::-webkit-scrollbar { display: none; }
  .aichat__chips button { padding: 7px 10px; font-size: 12.5px; white-space: nowrap; }
  .aichat__log { min-height: 152px; }
  .aichat__wa { padding: 7px 11px 0; }
  .aichat__wa-link { padding: 8px 10px; font-size: 13.5px; }
  .aichat__lead { margin: 0 11px 4px; padding: 11px 12px; }
  .aichat__form { padding: 9px 11px 11px; }
  .aichat__label { margin-bottom: 5px; font-size: 12.5px; }
  .aichat__in { padding: 10px 11px; font-size: 15px; }
  .aichat__send { padding: 10px 15px; font-size: 14.5px; }
  .aichat__note { margin-top: 7px; font-size: 11.5px; }
}
@media (max-width: 380px) {
  .aichat__btn-label { display: none; }
  .aichat__btn { padding: 0; width: 54px; justify-content: center; }
}
@media print { .aichat { display: none !important; } }
