/* ==========================================================
   Chat assistant. Layers: page < button and window (990)
   < header and its menus (1000) < cookie banner < pop-up.
   On phones the open window covers the whole screen.
   ========================================================== */
.chat-bubble {
    position: fixed; right: 24px; bottom: 24px; z-index: 990; width: 88px; height: 88px; border: 0; border-radius: 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px;
    background: linear-gradient(135deg, var(--primary), var(--dark)); color: #fff;
    box-shadow: 0 12px 30px rgba(59, 20, 66, .35); transition: transform .25s var(--ease);
}
.chat-bubble:hover { transform: translateY(-3px); }
.chat-bubble i { font-size: 22px; line-height: 1; color: var(--accent); }
.chat-bubble span { font-size: 11px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.chat-open .chat-bubble { display: none; }

/* The "back to top" button moves above the chat button, and left of the open window */
.has-chat .back-to-top { right: 43px; bottom: 124px; }
.has-chat.chat-open .back-to-top { right: 432px; bottom: 24px; }

.chat-window {
    position: fixed; right: 24px; bottom: 24px; z-index: 990; width: 390px; height: min(620px, calc(100vh - 190px)); min-height: 340px;
    display: flex; flex-direction: column; overflow: hidden; background: #fff; border-radius: 16px;
    box-shadow: 0 20px 60px rgba(38, 11, 43, .3); animation: chatIn .3s var(--ease);
}
.chat-window[hidden] { display: none; }
@keyframes chatIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

.chat-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: linear-gradient(90deg, var(--dark), var(--primary)); color: #fff; }
.chat-head strong { flex: 1; min-width: 0; font-size: 16px; line-height: 1.25; }
.chat-logo { flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--dark); font-size: 18px; }
.chat-head button { flex-shrink: 0; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: #fff; font-size: 17px; }
.chat-head button:hover { background: rgba(255, 255, 255, .15); }

.chat-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px; display: flex; flex-direction: column; gap: 14px; outline: 0; }
.chat-msg { max-width: 92%; align-self: flex-start; }
.chat-msg.visitor { align-self: flex-end; text-align: right; }
.chat-msg > small { display: block; margin-bottom: 4px; font-size: 12px; color: var(--primary); }
.chat-text { display: inline-block; text-align: left; padding: 9px 13px; border-radius: 12px; background: var(--soft); color: var(--ink); font-size: 14.5px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.chat-text b { display: block; margin-bottom: 3px; color: var(--dark); }
.chat-msg.visitor .chat-text { background: var(--primary); color: #fff; }
.chat-link { display: flex; width: -moz-fit-content; width: fit-content; align-items: center; gap: 6px; margin-top: 8px; padding: 7px 14px; border-radius: 30px; background: var(--accent); color: var(--dark); font-size: 13.5px; font-weight: 700; }
.chat-link:hover { color: var(--dark); filter: brightness(.95); }
.chat-error { align-self: stretch; padding: 9px 13px; border-radius: 12px; background: #fdecec; color: #a12622; font-size: 14px; }

.chat-video { position: relative; width: 100%; aspect-ratio: 16 / 9; border: 0; padding: 0; border-radius: 12px; overflow: hidden; background: #000 center / cover no-repeat; flex-shrink: 0; }
.chat-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.chat-video i { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 58px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: #e62117; color: #fff; font-size: 24px; }

.chat-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.chat-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }

.chat-menu { align-self: stretch; padding: 12px; border-radius: 12px; background: var(--soft); }
.chat-menu p { margin: 0 0 10px; font-size: 14.5px; color: var(--ink); }
.chat-menu div { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chat-menu button { min-height: 40px; padding: 7px 8px; border: 1px solid var(--primary); border-radius: 9px; background: #fff; color: var(--dark); font-size: 13.5px; font-weight: 600; line-height: 1.25; transition: background .2s, color .2s; }
.chat-menu button:hover { background: var(--primary); color: #fff; }

.chat-fields { align-self: stretch; display: grid; gap: 10px; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.chat-fields label { display: block; font-size: 13px; font-weight: 600; color: var(--dark); }
.chat-fields input, .chat-fields select, .chat-fields textarea, .chat-foot input {
    display: block; width: 100%; padding: 8px 10px; border: 1px solid #d9cddc; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; font-size: 14.5px; font-weight: 400;
}
.chat-fields input, .chat-fields select, .chat-fields textarea { margin-top: 4px; }
.chat-fields .invalid { border-color: #c9302c; }
.chat-fields em { display: block; margin-top: 3px; color: #a12622; font-size: 12.5px; font-style: normal; font-weight: 400; }
.chat-fields button[type="submit"] { padding: 10px; border: 0; border-radius: 30px; background: var(--primary); color: #fff; font-size: 14.5px; font-weight: 700; }
.chat-fields button[type="submit"]:hover { background: var(--primary-dark); }
.chat-fields .chat-back { padding: 2px; border: 0; background: none; color: var(--primary); font-size: 13.5px; font-weight: 600; text-decoration: underline; }
.chat-window button:disabled { opacity: .6; cursor: default; }

.chat-typing { align-self: flex-start; display: flex; gap: 5px; padding: 13px 15px; border-radius: 12px; background: var(--soft); }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: chatDot 1.2s infinite; }
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chatDot { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.chat-foot { padding: 10px 14px; border-top: 1px solid var(--line); background: #fbf9fc; }
.chat-foot form { display: flex; margin: 0; }
.chat-foot input { border-radius: 8px 0 0 8px; border-right: 0; min-width: 0; }
.chat-foot form button { flex-shrink: 0; width: 48px; border: 0; border-radius: 0 8px 8px 0; background: var(--primary); color: #fff; font-size: 17px; }
.chat-foot p { margin: 8px 0 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
.chat-foot p a { color: var(--primary); text-decoration: underline; }
.chat-window :focus-visible, .chat-bubble:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* The cookie banner moves left so it does not cover the open chat */
@media (min-width: 992px) {
    .chat-open .cookie-banner { left: 20px; transform: none; width: min(780px, calc(100% - 460px)); animation: none; }
}
/* Smaller screens: the chat button sits above the cookie banner while it is shown (height set by chat.js) */
@media (max-width: 991.98px) {
    .cookie-shown .chat-bubble { bottom: calc(var(--cookie-height) + 24px); }
    .cookie-shown .back-to-top { display: none; }
    .chat-window { z-index: 1060; }
    .chat-fields input, .chat-fields select, .chat-fields textarea, .chat-foot input { font-size: 16px; }   /* iPhones zoom in below 16px */
}
@media (max-width: 575.98px) {
    .chat-bubble { right: 14px; bottom: 14px; width: 74px; height: 74px; gap: 3px; }
    .chat-bubble i { font-size: 18px; }
    .chat-bubble span { font-size: 10px; }
    .has-chat .back-to-top { right: 28px; bottom: 100px; }
    body.chat-open { overflow: hidden; }
    .chat-window { inset: 0; width: auto; height: 100vh; height: 100dvh; min-height: 0; border-radius: 0; z-index: 1060; }
}
@media (prefers-reduced-motion: reduce) {
    .chat-window, .chat-typing span { animation: none; }
}
