/* Built-in AI chat panel (Gemini). Loaded only when the AI button is in chat mode. */

.gw-ai-chat {
    position: fixed; z-index: 950; display: flex; flex-direction: column;
    width: 380px; height: min(600px, calc(100vh - 130px));
    background: #ffffff; border-radius: 20px; overflow: hidden;
    box-shadow: 0 28px 70px -20px rgba(6, 18, 36, .55), 0 0 0 1px rgba(13, 27, 51, .08);
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    opacity: 0; transform: translateY(16px) scale(.98); transition: opacity .22s ease, transform .22s ease;
}
.gw-ai-chat.is-open { opacity: 1; transform: none; }
/* --gw-ai-offset is set by ai-chat.js from the real height of the button stack, so the panel always
   opens just above (or below) the buttons and never covers the AI button itself. */
.gw-ai-chat--bottom-right { right: 20px; bottom: var(--gw-ai-offset, 92px); transform-origin: bottom right; }
.gw-ai-chat--bottom-left  { left: 20px;  bottom: var(--gw-ai-offset, 92px); transform-origin: bottom left; }
.gw-ai-chat--bottom-right, .gw-ai-chat--bottom-left {
    height: min(600px, calc(100vh - var(--gw-ai-offset, 92px) - var(--header-h, 78px) - 16px));
    height: min(600px, calc(100dvh - var(--gw-ai-offset, 92px) - var(--header-h, 78px) - 16px));
}
.gw-ai-chat--top-right { right: 20px; top: var(--gw-ai-offset, calc(var(--header-h, 78px) + 88px)); transform-origin: top right; }
.gw-ai-chat--top-left  { left: 20px;  top: var(--gw-ai-offset, calc(var(--header-h, 78px) + 88px)); transform-origin: top left; }
.gw-ai-chat--top-right, .gw-ai-chat--top-left {
    height: min(600px, calc(100vh - var(--gw-ai-offset, 166px) - 16px));
    height: min(600px, calc(100dvh - var(--gw-ai-offset, 166px) - 16px));
}

.gw-ai-chat__head {
    position: relative; display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; color: #fff;
    background: linear-gradient(135deg, #13305a 0%, #0a1a33 100%);
}
.gw-ai-chat__head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, #ef1a3d, #ff8fa3, #ef1a3d); }
.gw-ai-chat__avatar { width: 42px; height: 42px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px; background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .15); }
.gw-ai-chat__avatar img { width: 38px; height: 38px; border-radius: 10px; }
.gw-ai-chat__meta { flex: 1; min-width: 0; }
.gw-ai-chat__meta strong { display: block; font-size: .98rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gw-ai-chat__meta small { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: #b9c6da; }
.gw-ai-chat__dot { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .25); }
.gw-ai-chat__icon { width: 34px; height: 34px; flex-shrink: 0; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer; transition: background-color .2s; }
.gw-ai-chat__icon:hover { background: #ef1a3d; }
.gw-ai-chat__icon:focus-visible, .gw-ai-chat__send:focus-visible, .gw-ai-chip:focus-visible { outline: 3px solid #ff5a76; outline-offset: 2px; }

.gw-ai-chat__body { flex: 1; overflow-y: auto; padding: 18px 14px; background: #f4f7fb; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.gw-ai-msg { display: flex; }
.gw-ai-msg--user { justify-content: flex-end; }
.gw-ai-msg__bubble { max-width: 84%; padding: 10px 14px; border-radius: 16px; font-size: .92rem; line-height: 1.55; word-wrap: break-word; overflow-wrap: anywhere; animation: gwAiIn .25s ease; }
.gw-ai-msg--bot .gw-ai-msg__bubble { background: #ffffff; color: #0d1b33; border: 1px solid #e2e8f1; border-bottom-left-radius: 5px; }
.gw-ai-msg--user .gw-ai-msg__bubble { background: linear-gradient(135deg, #ef1a3d, #c30f2f); color: #fff; border-bottom-right-radius: 5px; }
.gw-ai-msg--error .gw-ai-msg__bubble { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.gw-ai-msg__bubble a { color: inherit; text-decoration: underline; }
.gw-ai-msg--bot .gw-ai-msg__bubble a { color: #d3122f; }
.gw-ai-li { display: block; padding-left: 14px; position: relative; }
.gw-ai-li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: #ef1a3d; }
@keyframes gwAiIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.gw-ai-typing { display: inline-flex; gap: 5px; align-items: center; padding: 14px 16px; }
.gw-ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: #13305a; opacity: .35; animation: gwAiDot 1.2s infinite ease-in-out; }
.gw-ai-typing span:nth-child(2) { animation-delay: .15s; }
.gw-ai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes gwAiDot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

.gw-ai-chat__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; background: #f4f7fb; }
.gw-ai-chip { border: 1px solid #cfdaea; background: #fff; color: #13305a; border-radius: 999px; padding: 6px 12px; font: 600 .8rem/1.3 inherit; font-family: inherit; cursor: pointer; transition: all .2s; text-align: left; }
.gw-ai-chip:hover { border-color: #ef1a3d; color: #ef1a3d; }

.gw-ai-chat__form { display: flex; align-items: flex-end; gap: 8px; padding: 12px; background: #fff; border-top: 1px solid #e2e8f1; }
.gw-ai-chat__form textarea {
    flex: 1; min-width: 0; resize: none; max-height: 120px; padding: 10px 14px; border: 1.5px solid #e2e8f1; border-radius: 14px;
    font: inherit; font-size: .92rem; color: #0d1b33; background: #f8fafc; line-height: 1.4;
}
.gw-ai-chat__form textarea:focus { outline: none; border-color: #2a5a96; background: #fff; box-shadow: 0 0 0 3px rgba(42, 90, 150, .15); }
.gw-ai-chat__send { width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 50%; background: linear-gradient(135deg, #ef1a3d, #c30f2f); color: #fff; cursor: pointer; box-shadow: 0 10px 20px -10px rgba(239, 26, 61, .8); transition: transform .2s; }
.gw-ai-chat__send:hover { transform: scale(1.06); }
.gw-ai-chat__send[disabled] { opacity: .55; cursor: progress; transform: none; }
.gw-ai-chat__note { margin: 0; padding: 0 12px 10px; background: #fff; font-size: .72rem; color: #6b7a90; text-align: center; }
.gw-ai-chat__note a { color: #d3122f; font-weight: 600; }
.gw-ai-chat .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Phones: a compact floating box (not full screen) with smaller text, opened above the buttons. */
@media (max-width: 640px) {
    .gw-ai-chat { width: min(310px, calc(100vw - 28px)); border-radius: 16px; }
    .gw-ai-chat--bottom-right, .gw-ai-chat--top-right { right: 14px; }
    .gw-ai-chat--bottom-left, .gw-ai-chat--top-left { left: 14px; }
    .gw-ai-chat--bottom-right, .gw-ai-chat--bottom-left {
        height: min(400px, calc(100vh - var(--gw-ai-offset, 146px) - var(--header-h, 68px) - 12px));
        height: min(400px, calc(100dvh - var(--gw-ai-offset, 146px) - var(--header-h, 68px) - 12px));
    }
    .gw-ai-chat--top-right, .gw-ai-chat--top-left {
        height: min(400px, calc(100vh - var(--gw-ai-offset, 146px) - 12px));
        height: min(400px, calc(100dvh - var(--gw-ai-offset, 146px) - 12px));
    }
    .gw-ai-chat__head { gap: 9px; padding: 10px 10px 10px 12px; }
    .gw-ai-chat__avatar { width: 34px; height: 34px; border-radius: 10px; }
    .gw-ai-chat__avatar img { width: 30px; height: 30px; border-radius: 8px; }
    .gw-ai-chat__meta strong { font-size: .86rem; }
    .gw-ai-chat__meta small { font-size: .68rem; }
    .gw-ai-chat__icon { width: 30px; height: 30px; font-size: .85rem; }
    .gw-ai-chat__body { padding: 12px 10px; gap: 8px; }
    .gw-ai-msg__bubble { max-width: 88%; padding: 8px 11px; font-size: .82rem; line-height: 1.5; border-radius: 14px; }
    .gw-ai-typing { padding: 11px 13px; }
    .gw-ai-chat__chips { gap: 5px; padding: 8px 10px 0; }
    .gw-ai-chip { padding: 5px 10px; font-size: .72rem; }
    .gw-ai-chat__form { gap: 6px; padding: 8px; }
    /* 16px is the smallest size at which iPhones do not zoom the whole page when the box is tapped. */
    .gw-ai-chat__form textarea { font-size: 16px; padding: 7px 11px; border-radius: 12px; max-height: 96px; }
    .gw-ai-chat__form textarea::placeholder { font-size: 13px; }
    .gw-ai-chat__send { width: 38px; height: 38px; font-size: .85rem; }
    .gw-ai-chat__note { padding: 0 8px 7px; font-size: .64rem; }
}

/* Short screens (phones held sideways): open beside the buttons, using the full height. */
@media (max-height: 520px) {
    .gw-ai-chat, .gw-ai-chat--bottom-right, .gw-ai-chat--bottom-left, .gw-ai-chat--top-right, .gw-ai-chat--top-left {
        top: 8px; bottom: 8px; height: auto; z-index: 1200;
    }
    .gw-ai-chat--bottom-right, .gw-ai-chat--top-right { right: var(--gw-ai-side, 90px); }
    .gw-ai-chat--bottom-left, .gw-ai-chat--top-left { left: var(--gw-ai-side, 90px); }
    .gw-ai-chat__note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .gw-ai-chat, .gw-ai-msg__bubble, .gw-ai-typing span { transition: none; animation: none; }
}
