/* ─────────────────────────────────────────────────────────────
   Viexor AI Sohbet Asistanı — widget stilleri
   Palet, site çerez bildirimiyle (lib/privacy_bar.php) uyumludur.
   Vurgu rengi JS tarafından --vx-c değişkeniyle enjekte edilir.
   Konum: data-pos="right|left"
   ───────────────────────────────────────────────────────────── */

.vx-chat {
    --vx-c: #4f7cff;
    --vx-c-soft: color-mix(in srgb, var(--vx-c) 16%, transparent);
    --vx-panel: #12151f;
    --vx-panel-2: #0e111a;
    --vx-border: #262b3a;
    --vx-text: #e6e8ef;
    --vx-muted: #98a0b4;
    position: fixed;
    bottom: 22px;
    z-index: 9970; /* çerez bildirimi (9998) üstte kalır */
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--vx-text);
}
.vx-chat[data-pos="right"] { right: 22px; }
.vx-chat[data-pos="left"]  { left: 22px; }

/* ── Başlatıcı ── */
.vx-chat__launcher {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: var(--vx-c);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    transition: transform .18s ease, box-shadow .18s ease;
    position: relative;
    /* overflow: hidden bilinçli olarak yok: durum noktası (vx-chat__dot)
       dairenin sağ üst köşesinde yay boyunca durur; kırpma yüzünden
       noktasının sağ üst kısmı görünmüyordu. Avatar zaten kendi
       border-radius: 50% ile dairesel, ikon da taşmıyor. */
}
.vx-chat__launcher:hover { transform: scale(1.06); box-shadow: 0 14px 34px rgba(0, 0, 0, .5); }
.vx-chat__launcher svg { width: 26px; height: 26px; }
.vx-chat__launcher .vx-chat__ico-close { display: none; }
.vx-chat.is-open .vx-chat__launcher .vx-chat__ico-chat { display: none; }
.vx-chat.is-open .vx-chat__launcher .vx-chat__ico-close { display: block; }
.vx-chat__launcher-avatar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    display: block;
}

/* ── Bağlantı durumu noktası (yeşil/mavi nabız) ── */
.vx-chat__dot {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-sizing: border-box;
    z-index: 4;
    animation: vx-dot-pulse 1.8s ease-out infinite;
}
.vx-chat__dot[hidden] { display: none; }
.vx-chat__dot.is-ok { background: #22c55e; animation-name: vx-dot-pulse-green; }
.vx-chat__dot.is-error { background: #3b82f6; animation-name: vx-dot-pulse-blue; }

/* Launcher: yuvarlağın sağ üst köşesi, beyaz halka ile ayrılır */
.vx-chat__launcher .vx-chat__dot {
    top: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    border: 2px solid #fff;
    animation-name: vx-dot-pulse-green;
}
.vx-chat__launcher .vx-chat__dot.is-error { animation-name: vx-dot-pulse-blue; }

/* Başlık: "Viexor Asistan" yazısının sağ üstü */
.vx-chat__title { position: relative; display: inline-block; max-width: 100%; }
.vx-chat__title .vx-chat__dot { top: -1px; right: -14px; width: 9px; height: 9px; }

.vx-chat__status.is-error { color: #93c5fd; }
.vx-chat__status.is-error::before { background: #3b82f6; box-shadow: 0 0 6px #3b82f6; }

/* Karar destek modu notu (canlı bağlantı yokken bilgi bankası yanıtlar) */
.vx-chat__note {
    margin: 4px auto 10px;
    max-width: 90%;
    text-align: center;
    font-size: 11px;
    line-height: 1.5;
    color: #94a3b8;
    background: rgba(148, 163, 184, .1);
    border: 1px dashed rgba(148, 163, 184, .4);
    border-radius: 999px;
    padding: 4px 14px;
}

@keyframes vx-dot-pulse-green {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); }
    70%  { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
@keyframes vx-dot-pulse-blue {
    0%   { box-shadow: 0 0 0 0 rgba(59, 130, 246, .55); }
    70%  { box-shadow: 0 0 0 7px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}
@keyframes vx-dot-pulse { /* yedek: sınıf eklenmeden önce */
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); }
    70%  { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .vx-chat__dot { animation: none; }
}

/* ── Karşılama balonu ── */
.vx-chat__bubble {
    position: absolute;
    bottom: 74px;
    max-width: 330px;
    background: var(--vx-panel);
    border: 1px solid var(--vx-border);
    color: var(--vx-text);
    padding: 12px 34px 12px 14px;
    border-radius: 14px;
    border-bottom-right-radius: 4px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
    cursor: pointer;
    animation: vxChatPop .25s ease-out;
}
.vx-chat[data-pos="right"] .vx-chat__bubble { right: 0; }
.vx-chat[data-pos="left"]  .vx-chat__bubble { left: 0; border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }
.vx-chat__bubble[hidden] { display: none; }
.vx-chat__bubble-text {
    display: inline-block;
    width: 270px;
    white-space: normal;
    vertical-align: middle;
}
.vx-chat__bubble-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: var(--vx-muted);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
}
.vx-chat__bubble-close:hover { color: #fff; }

/* ── Panel ── */
.vx-chat__panel {
    position: absolute;
    bottom: 74px;
    width: min(380px, calc(100vw - 44px));
    height: min(560px, calc(100vh - 130px));
    background: var(--vx-panel);
    border: 1px solid var(--vx-border);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: vxChatPop .22s ease-out;
}
.vx-chat[data-pos="right"] .vx-chat__panel { right: 0; }
.vx-chat[data-pos="left"]  .vx-chat__panel { left: 0; }
.vx-chat__panel[hidden] { display: none; }

.vx-chat__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    background: linear-gradient(135deg, var(--vx-c-soft), transparent 70%), var(--vx-panel-2);
    border-bottom: 1px solid var(--vx-border);
}
.vx-chat__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--vx-c);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.vx-chat__avatar svg { width: 19px; height: 19px; }
.vx-chat__title { font-weight: 650; font-size: 14.5px; }
.vx-chat__status { font-size: 11.5px; color: #4ade80; display: flex; align-items: center; gap: 5px; }
.vx-chat__status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px #4ade80;
}
.vx-chat__header-actions { margin-left: auto; display: flex; gap: 4px; }
.vx-chat__iconbtn {
    background: none;
    border: none;
    color: var(--vx-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
}
.vx-chat__iconbtn:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.vx-chat__iconbtn svg { width: 17px; height: 17px; }

/* ── Mesajlar ── */
.vx-chat__msgs {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    scroll-behavior: smooth;
}
.vx-chat__msg {
    max-width: 84%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 13.5px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}
.vx-chat__msg--bot {
    align-self: flex-start;
    background: var(--vx-panel-2);
    border: 1px solid var(--vx-border);
    border-bottom-left-radius: 5px;
}
.vx-chat__msg--user {
    align-self: flex-end;
    background: var(--vx-c);
    color: #fff;
    border-bottom-right-radius: 5px;
}
.vx-chat__msg b, .vx-chat__msg strong { font-weight: 700; }
.vx-chat__msg--typing { display: inline-flex; gap: 5px; align-items: center; padding: 13px 14px; }
.vx-chat__msg--typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--vx-muted);
    animation: vxChatBlink 1.2s infinite;
}
.vx-chat__msg--typing i:nth-child(2) { animation-delay: .2s; }
.vx-chat__msg--typing i:nth-child(3) { animation-delay: .4s; }
.vx-chat__msg--error {
    align-self: center;
    background: #2a1420;
    border: 1px solid #5b2437;
    color: #fca5a5;
    font-size: 12.5px;
    max-width: 94%;
}

/* Hızlı cevaplar */
.vx-chat__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 4px; }
.vx-chat__chips[hidden] { display: none; }
.vx-chat__chip {
    font: inherit;
    font-size: 12.5px;
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid var(--vx-c);
    background: transparent;
    color: var(--vx-c);
    cursor: pointer;
    transition: background .15s;
}
.vx-chat__chip:hover { background: var(--vx-c-soft); }

/* ── Lead formu ── */
.vx-chat__lead {
    margin: 2px 12px 8px;
    padding: 12px;
    background: var(--vx-panel-2);
    border: 1px solid var(--vx-border);
    border-radius: 12px;
}
.vx-chat__lead[hidden] { display: none; }
.vx-chat__lead-title { font-weight: 650; font-size: 13.5px; margin-bottom: 3px; }
.vx-chat__lead-sub { font-size: 12px; color: var(--vx-muted); margin-bottom: 9px; }
.vx-chat__lead label { display: block; font-size: 11.5px; color: var(--vx-muted); margin: 7px 0 3px; }
.vx-chat__lead input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--vx-border);
    background: #0a0d15;
    color: var(--vx-text);
    font: inherit;
    font-size: 13px;
    outline: none;
}
.vx-chat__lead input:focus { border-color: var(--vx-c); }
.vx-chat__lead-actions { display: flex; gap: 8px; margin-top: 11px; }
.vx-chat__lead-actions button { flex: 1; font-size: 12.5px; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.vx-chat__lead-submit { background: var(--vx-c); border: none; color: #fff; }
.vx-chat__lead-skip { background: transparent; border: 1px solid var(--vx-border); color: var(--vx-muted); }

/* ── Giriş alanı ── */
.vx-chat__foot { border-top: 1px solid var(--vx-border); padding: 10px 12px; background: var(--vx-panel-2); }
.vx-chat__inputrow { display: flex; align-items: flex-end; gap: 8px; }
.vx-chat__input {
    flex: 1;
    resize: none;
    border: 1px solid var(--vx-border);
    background: #0a0d15;
    color: var(--vx-text);
    border-radius: 11px;
    padding: 9px 11px;
    font: inherit;
    font-size: 13.5px;
    max-height: 96px;
    outline: none;
    line-height: 1.4;
}
.vx-chat__input:focus { border-color: var(--vx-c); }
.vx-chat__send {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: none;
    border-radius: 11px;
    background: var(--vx-c);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.vx-chat__send:disabled { opacity: .5; cursor: default; }
.vx-chat__send svg { width: 17px; height: 17px; }
.vx-chat__note { font-size: 10.5px; color: #6b7285; margin-top: 7px; text-align: center; }
.vx-chat__note[hidden] { display: none; }

/* ── Animasyonlar ── */
@keyframes vxChatPop { from { transform: translateY(12px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes vxChatBlink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .vx-chat__panel, .vx-chat__bubble { animation: none; }
    .vx-chat__msgs { scroll-behavior: auto; }
}

/* ── Mobil: alt sayfa görünümlü ── */
@media (max-width: 480px) {
    .vx-chat { bottom: 14px; }
    .vx-chat[data-pos="right"] { right: 14px; }
    .vx-chat[data-pos="left"]  { left: 14px; }
    .vx-chat__panel {
        position: fixed;
        inset: auto 8px 82px 8px;
        width: auto;
        height: min(74vh, 560px);
    }
    .vx-chat__feedback { display: flex; gap: 6px; margin-top: 6px; }
    .vx-chat__fb { background: transparent !important; border: 1px solid var(--vx-border, #262b3a); color: var(--vx-muted, #98a0b4); border-radius: 6px; padding: 2px 6px; font-size: 0.75rem; cursor: pointer; }
    .vx-chat__fb:hover { color: var(--vx-text, #e6e8ef); }
