/**
 * KepezWeb — Public AI Sohbet Asistanı widget stilleri.
 *
 * Deferred yüklenir (render-blocking değil). Token sistemi kepezweb.css'teki
 * --kw-accent / --kw-ink-* değişkenlerini kullanır; palet (v1/v2/v3) değişince
 * widget de otomatik uyar. WhatsApp FAB sağ-altta olduğu için asistan SOL-alta
 * konumlanır — iki buton çakışmaz.
 */

/* ---------- FAB ----------
   Mavi→mor degrade: 2024+ "AI" görsel dili (Gemini/Copilot konvansiyonu).
   Mor ton (#7c3aed) sitede zaten var (mobil menü hover) — palete yabancı değil. */
.kw-aichat-fab {
    position: fixed;
    left: 22px;
    bottom: 22px;
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--kw-accent, #4da6e7) 0%, #7c3aed 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 12px 28px rgba(124, 58, 237, 0.38);
    transition: transform .25s ease, box-shadow .25s ease;
}
.kw-aichat-fab:hover {
    transform: scale(1.06);
    box-shadow: 0 16px 34px rgba(124, 58, 237, 0.5);
}
/* display:block + flex-shrink:0: satır-içi svg baseline kaymalarına ve
   flex daralmasına karşı; beyaz renk attribute'larda da var (çifte güvence) */
.kw-aichat-fab svg { width: 28px; height: 28px; display: block; flex-shrink: 0; }

/* WhatsApp'taki kwPulse deseninin AI moru versiyonu — dikkat çeker, rahatsız etmez */
.kw-aichat-fab::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(124, 58, 237, 0.6);
    animation: kwAiPulse 2.4s infinite;
    pointer-events: none;
}
@keyframes kwAiPulse {
    0%   { transform: scale(1);   opacity: .8; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Yeşil "çevrimiçi" noktası — canlı sohbet konvansiyonu (metin rozeti yerine;
   AI mesajını artık parıltı ikonu taşıyor) */
.kw-aichat-fab-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
    pointer-events: none;
}

/* ---------- Panel ---------- */
.kw-aichat-panel {
    position: fixed;
    left: 22px;
    bottom: 92px;
    width: min(380px, calc(100vw - 32px));
    max-height: min(560px, calc(100dvh - 120px));
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--kw-border-soft, #e2e8f0);
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
    z-index: 1000;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(.98);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}
[data-kw-ai-chat].is-open .kw-aichat-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.kw-aichat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    /* FAB ile aynı AI degradesi — görsel bütünlük */
    background: linear-gradient(135deg, var(--kw-accent, #4da6e7) 0%, #7c3aed 100%);
    color: #fff;
}
.kw-aichat-header-avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.kw-aichat-header-avatar svg { width: 20px; height: 20px; }
.kw-aichat-header-title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.kw-aichat-header-sub { font-size: 11.5px; opacity: .85; }
.kw-aichat-close {
    margin-left: auto;
    border: 0;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}
.kw-aichat-close:hover { background: rgba(255, 255, 255, 0.26); }

/* ---------- Mesaj listesi ---------- */
.kw-aichat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px 8px;
    background: var(--kw-surface-soft, #f8fafc);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    /* Liste sınırına gelince tekerlek arka sayfaya taşmasın
       (Lenis için ayrıca markup'ta data-lenis-prevent var) */
    overscroll-behavior: contain;
}
.kw-aichat-msg { display: flex; }
.kw-aichat-msg--user { justify-content: flex-end; }
.kw-aichat-bubble {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    color: var(--kw-ink-700, #334155);
    background: #fff;
    border: 1px solid var(--kw-border-soft, #e2e8f0);
    border-bottom-left-radius: 5px;
}
.kw-aichat-msg--user .kw-aichat-bubble {
    background: var(--kw-accent-deep, #1f6fb0);
    border-color: var(--kw-accent-deep, #1f6fb0);
    color: #fff;
    border-radius: 14px;
    border-bottom-right-radius: 5px;
}
.kw-aichat-bubble a { color: var(--kw-accent-deep, #1f6fb0); text-decoration: underline; }
.kw-aichat-msg--user .kw-aichat-bubble a { color: #fff; }
.kw-aichat-bubble strong { font-weight: 700; color: var(--kw-ink-900, #0f172a); }
.kw-aichat-msg--user .kw-aichat-bubble strong { color: #fff; }

/* typing indicator */
.kw-aichat-typing { display: inline-flex; gap: 5px; align-items: center; padding: 13px 15px; }
.kw-aichat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--kw-ink-400, #94a3b8);
    animation: kwAiDot 1.2s infinite ease-in-out;
}
.kw-aichat-dot:nth-child(2) { animation-delay: .15s; }
.kw-aichat-dot:nth-child(3) { animation-delay: .3s; }
@keyframes kwAiDot {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Öneri çipleri ---------- */
.kw-aichat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 14px 10px;
    background: var(--kw-surface-soft, #f8fafc);
}
.kw-aichat-chip {
    border: 1px solid var(--kw-accent, #4da6e7);
    background: #fff;
    color: var(--kw-accent-deep, #1f6fb0);
    font-size: 12px;
    padding: 6px 11px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.kw-aichat-chip:hover { background: var(--kw-accent-soft, rgba(77, 166, 231, 0.12)); }

/* ---------- Form ---------- */
.kw-aichat-form {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--kw-border-soft, #e2e8f0);
    background: #fff;
}
.kw-aichat-input {
    flex: 1 1 auto;
    border: 1px solid var(--kw-border-soft, #e2e8f0);
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 13.5px;
    outline: none;
    min-width: 0;
}
.kw-aichat-input:focus { border-color: var(--kw-accent, #4da6e7); box-shadow: 0 0 0 3px var(--kw-accent-soft, rgba(77, 166, 231, 0.12)); }
.kw-aichat-send {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: var(--kw-accent-deep, #1f6fb0);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.kw-aichat-send:disabled, .kw-aichat-input:disabled { opacity: .55; cursor: not-allowed; }
.kw-aichat-send svg { width: 18px; height: 18px; display: block; flex-shrink: 0; stroke: #fff; }

.kw-aichat-disclaimer {
    font-size: 10.5px;
    color: var(--kw-ink-400, #94a3b8);
    text-align: center;
    padding: 0 14px 10px;
    background: #fff;
    margin: 0;
}

/* ---------- Mobil ---------- */
@media (max-width: 576px) {
    .kw-aichat-fab { left: 16px; bottom: 16px; width: 52px; height: 52px; }
    .kw-aichat-panel {
        left: 8px;
        right: 8px;
        bottom: 78px;
        width: auto;
        max-height: calc(100dvh - 96px);
        border-radius: 16px;
    }
}

/* ---------- Erişilebilirlik: azaltılmış hareket ---------- */
@media (prefers-reduced-motion: reduce) {
    .kw-aichat-fab, .kw-aichat-panel { transition: none; }
    .kw-aichat-fab:hover { transform: none; }
    .kw-aichat-fab::after { animation: none; opacity: 0; }
    .kw-aichat-dot { animation: none; }
    .kw-aichat-messages { scroll-behavior: auto; }
}
