/* ============================================================
   Yapay Zeka Sohbet Widget'ı — site tasarım diliyle (blueprint) uyumlu
   ============================================================ */

#cb-wrapper {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 0 !important;
    height: 0 !important;
    overflow: visible !important;
    z-index: 190;
}
#cb-wrapper * { box-sizing: border-box; }
#cb-wrapper *:not(input) { font-family: var(--font-body); }
#cb-container { position: fixed; bottom: 24px; left: 24px; z-index: 190; }

/* Toggle butonu */
#cb-toggle-button {
    width: 58px; height: 58px; border-radius: 50%;
    border: none; cursor: pointer;
    background: var(--navy-deep);
    box-shadow: 0 10px 26px -8px rgba(10, 27, 43, 0.55), 0 2px 6px rgba(0,0,0,0.15);
    display: flex; align-items: center; justify-content: center;
    position: relative;
    color: #fff;
    transition: transform .35s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease;
}
#cb-toggle-button:hover { transform: scale(1.06); box-shadow: 0 14px 30px -8px rgba(10, 27, 43, 0.65); }
#cb-toggle-button:active { transform: scale(.95); }

.cb-toggle-ring {
    position: absolute; width: 100%; height: 100%; border-radius: 50%;
    border: 1.5px solid var(--signal);
    opacity: 0;
    animation: cbPulseRing 2.8s ease-out infinite;
}
@keyframes cbPulseRing { 0% { transform: scale(1); opacity: .5; } 100% { transform: scale(1.6); opacity: 0; } }
#cb-wrapper.is-open .cb-toggle-ring { animation: none; opacity: 0; }

#cb-toggle-button svg { position: absolute; transition: opacity .3s ease, transform .4s cubic-bezier(.34,1.56,.64,1); }
#cb-icon-close { opacity: 0; transform: rotate(-90deg) scale(.5); }
#cb-wrapper.is-open #cb-icon-chat { opacity: 0; transform: rotate(90deg) scale(.5); }
#cb-wrapper.is-open #cb-icon-close { opacity: 1; transform: rotate(0) scale(1); }

/* CTA balonu */
#cb-cta-bubble {
    position: absolute; bottom: 74px; left: -4px;
    background: var(--navy-deep); color: #fff;
    font-size: 12.5px; font-weight: 600;
    padding: 10px 16px 10px 12px; border-radius: 10px; border-bottom-left-radius: 3px;
    box-shadow: 0 10px 24px -10px rgba(10,27,43,0.5);
    white-space: nowrap;
    opacity: 0; transform: translateY(10px) scale(.95);
    transition: opacity .5s cubic-bezier(.16,1,.3,1), transform .5s cubic-bezier(.16,1,.3,1);
    pointer-events: none;
    display: flex; align-items: center; gap: 9px;
}
.cb-cta-icon {
    width: 26px; height: 26px; border-radius: 7px;
    background: var(--signal); color: #fff;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#cb-cta-bubble.visible { opacity: 1; transform: translateY(0) scale(1); }
#cb-wrapper.is-open #cb-cta-bubble { opacity: 0 !important; transform: translateY(10px) scale(.95) !important; }

/* Widget paneli */
#cb-widget {
    position: absolute; bottom: 74px; left: 0;
    width: 380px; height: 560px; max-height: 78vh;
    background: var(--paper-card);
    border-radius: 8px;
    box-shadow: 0 30px 60px -20px rgba(10,27,43,0.4);
    display: flex; flex-direction: column; overflow: hidden;
    opacity: 0; transform: scale(.92) translateY(16px);
    transform-origin: bottom left;
    pointer-events: none;
    transition: opacity .4s cubic-bezier(.16,1,.3,1), transform .4s cubic-bezier(.16,1,.3,1);
}
#cb-wrapper.is-open #cb-widget { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }

/* Başlık */
.cb-header {
    background: var(--navy-deep);
    background-image: linear-gradient(rgba(127,176,220,0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(127,176,220,0.08) 1px, transparent 1px);
    background-size: 22px 22px;
    padding: 16px 18px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
    position: relative;
}
.cb-header::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: var(--signal); }
.cb-header-left { display: flex; align-items: center; gap: 12px; }
.cb-avatar {
    width: 38px; height: 38px; border-radius: 8px; flex-shrink: 0;
    background: rgba(127,176,220,0.1); border: 1px solid var(--navy-line);
    color: var(--blue-line);
    display: flex; align-items: center; justify-content: center;
}
.cb-avatar svg { width: 30px; height: 30px; }
.cb-header-left strong { display: block; color: #fff; font-family: var(--font-display); font-size: 14.5px; font-weight: 700; }
.cb-header-sub { color: var(--blue-line); font-size: 10.5px; font-weight: 600; font-family: var(--font-mono); letter-spacing: 0.3px; }
.cb-close-icon { color: rgba(255,255,255,.5); cursor: pointer; display: flex; padding: 4px; transition: .2s; }
.cb-close-icon:hover { color: #fff; transform: scale(1.15); }

/* Sohbet penceresi */
#cb-chat-window {
    flex: 1; overflow-y: auto; padding: 18px 14px;
    display: flex; flex-direction: column; gap: 12px;
    scroll-behavior: smooth;
    background: var(--paper);
}
#cb-chat-window::-webkit-scrollbar { width: 4px; }
#cb-chat-window::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.cb-msg { max-width: 86%; padding: 11px 14px; font-size: 13.5px; line-height: 1.6; border-radius: 14px; animation: cbSlide .35s cubic-bezier(.16,1,.3,1) forwards; word-wrap: break-word; }
@keyframes cbSlide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.cb-msg-ai { align-self: flex-start; background: #fff; color: var(--ink-soft); border: 1px solid var(--line); border-top-left-radius: 4px; }
.cb-msg-ai strong { color: var(--ink); }
.cb-msg-user { align-self: flex-end; background: var(--navy-deep); color: #fff; border-bottom-right-radius: 4px; font-weight: 500; }

.cb-msg-typing { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 14px; border-top-left-radius: 4px; padding: 13px 18px; display: flex; gap: 5px; animation: cbSlide .3s ease forwards; }
.cb-typing-dot { width: 5px; height: 5px; background: var(--signal); border-radius: 50%; animation: cbTypingPulse 1.5s ease-in-out infinite; opacity: .35; }
.cb-typing-dot:nth-child(2) { animation-delay: .2s; }
.cb-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes cbTypingPulse { 0%,70%,100% { transform: scale(1); opacity: .35; } 35% { transform: scale(1.4); opacity: 1; } }

.cb-typing-cursor { display: inline-block; width: 2px; height: 13px; background: var(--signal); margin-left: 2px; vertical-align: middle; animation: cbBlink .9s step-end infinite; }
@keyframes cbBlink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

.cb-msg-error { align-self: flex-start; background: rgba(225,78,29,0.08); color: var(--signal-dark); border: 1px solid rgba(225,78,29,0.2); border-radius: 14px; border-top-left-radius: 4px; padding: 11px 14px; font-size: 13px; animation: cbSlide .3s ease forwards; }

/* Öneriler */
#cb-suggestions { padding: 10px 14px 12px; background: #fff; border-top: 1px solid var(--line); flex-shrink: 0; }
#cb-suggestions.cb-hidden { display: none; }
.cb-suggestions-label { font-family: var(--font-mono); font-size: 10px; font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: .4px; margin-bottom: 8px; }
.cb-suggestions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cb-chip {
    background: rgba(18,58,94,0.06); border: 1px solid var(--line); color: var(--navy);
    font-size: 11px; font-weight: 600; padding: 8px 10px; border-radius: 8px; cursor: pointer;
    transition: all .2s ease; text-align: center; font-family: var(--font-body);
}
.cb-chip:hover { background: var(--signal); border-color: var(--signal); color: #fff; }

/* Alt bölüm / giriş */
.cb-footer { padding: 12px 14px 14px; background: #fff; border-top: 1px solid var(--line); flex-shrink: 0; }
.cb-input-wrap {
    display: flex; align-items: center; background: var(--paper);
    border: 1.5px solid var(--line); border-radius: 10px; padding: 4px;
    transition: border-color .2s ease;
}
.cb-input-wrap:focus-within { border-color: var(--signal); }
#cb-input { flex: 1; border: none; background: transparent; padding: 10px 12px; font-size: 13.5px; outline: none; color: var(--ink); font-family: var(--font-body); }
#cb-input::placeholder { color: var(--muted); }
#cb-send-button { width: 34px; height: 34px; border-radius: 50%; border: none; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .2s ease; flex-shrink: 0; }
#cb-send-button:disabled { opacity: .4; cursor: default; }
#cb-send-button:not(:disabled) { color: var(--signal); }
#cb-send-button:not(:disabled):hover { background: var(--signal-soft); }
.cb-disclaimer { text-align: center; font-size: 9.5px; color: var(--muted); margin-top: 9px; display: flex; align-items: center; justify-content: center; gap: 4px; }

/* Duyarlı tasarım */
@media (max-width: 480px) {
    #cb-container { bottom: 16px; left: 16px; }
    #cb-toggle-button { width: 52px; height: 52px; }
    #cb-widget { width: calc(100vw - 32px); left: 0; bottom: 66px; height: 74vh; }
    #cb-cta-bubble { bottom: 60px; font-size: 11.5px; }
}

.cb-hidden { display: none !important; }
