/**
 * AI Sohbet Robotu – Frontend Stilleri
 *
 * Modern, responsive tasarım.
 * Sağ alt köşe ikon, modal sohbet penceresi, mesaj balonları.
 */

/* ============================================================
   CSS Değişkenleri (Tema Renkleri)
   ============================================================ */
:root {
    --ai-cb-primary: #6C63FF;
    --ai-cb-primary-dark: #5A52D5;
    --ai-cb-primary-light: #8B85FF;
    --ai-cb-bg: #FFFFFF;
    --ai-cb-surface: #F8F9FC;
    --ai-cb-text: #1E1E2E;
    --ai-cb-text-light: #6B7280;
    --ai-cb-user-bubble: #6C63FF;
    --ai-cb-user-text: #FFFFFF;
    --ai-cb-bot-bubble: #F0F0F8;
    --ai-cb-bot-text: #1E1E2E;
    --ai-cb-border: #E5E7EB;
    --ai-cb-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --ai-cb-radius: 16px;
    --ai-cb-radius-sm: 10px;
    --ai-cb-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   Tetikleyici İkon (Sağ Alt Köşe)
   ============================================================ */
#ai-chatbot-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    cursor: pointer;
    z-index: 999998;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(108, 99, 255, 0.4);
    transition: transform var(--ai-cb-transition), box-shadow var(--ai-cb-transition);
    animation: ai-chatbot-pulse 2s infinite;
}

#ai-chatbot-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(108, 99, 255, 0.55);
}

#ai-chatbot-trigger img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@keyframes ai-chatbot-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(108, 99, 255, 0.4); }
    50%      { box-shadow: 0 4px 30px rgba(108, 99, 255, 0.65); }
}

/* ============================================================
   Overlay (Arka Plan Karartma)
   ============================================================ */
#ai-chatbot-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    z-index: 999998;
    opacity: 0;
    transition: opacity var(--ai-cb-transition);
    pointer-events: none;
}

#ai-chatbot-overlay.ai-chatbot-visible {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================
   Modal Pencere
   ============================================================ */
#ai-chatbot-modal {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-height: 500px;
    background: var(--ai-cb-bg);
    border-radius: var(--ai-cb-radius);
    box-shadow: var(--ai-cb-shadow);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: transform var(--ai-cb-transition), opacity var(--ai-cb-transition);
    pointer-events: none;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

#ai-chatbot-modal.ai-chatbot-visible {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Gizle yardımcı sınıfı */
.ai-chatbot-hidden {
    /* JS tarafından kontrol edilir */
}

/* ============================================================
   Başlık Çubuğu (Header)
   ============================================================ */
.ai-chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--ai-cb-primary), var(--ai-cb-primary-dark));
    color: #FFFFFF;
    flex-shrink: 0;
}

.ai-chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    object-fit: cover;
}

.ai-chatbot-title {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.3px;
}

.ai-chatbot-status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-chatbot-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ADE80;
    display: inline-block;
    animation: ai-chatbot-blink 1.5s infinite;
}

@keyframes ai-chatbot-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

.ai-chatbot-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #FFFFFF;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--ai-cb-transition);
    line-height: 1;
}

.ai-chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ============================================================
   Mesaj Alanı
   ============================================================ */
.ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--ai-cb-surface);
    min-height: 250px;
    max-height: 340px;
}

/* Kaydırma çubuğu özelleştirme */
.ai-chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

.ai-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--ai-cb-border);
    border-radius: 10px;
}

/* ============================================================
   Mesaj Balonları
   ============================================================ */
.ai-chatbot-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: var(--ai-cb-radius-sm);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: ai-chatbot-msg-in 0.3s ease-out;
}

@keyframes ai-chatbot-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Bot mesajı – Sol */
.ai-chatbot-msg.bot {
    align-self: flex-start;
    background: var(--ai-cb-bot-bubble);
    color: var(--ai-cb-bot-text);
    border-bottom-left-radius: 4px;
}

/* Kullanıcı mesajı – Sağ */
.ai-chatbot-msg.user {
    align-self: flex-end;
    background: var(--ai-cb-user-bubble);
    color: var(--ai-cb-user-text);
    border-bottom-right-radius: 4px;
}

/* Yazıyor göstergesi */
.ai-chatbot-typing {
    align-self: flex-start;
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: var(--ai-cb-bot-bubble);
    border-radius: var(--ai-cb-radius-sm);
    border-bottom-left-radius: 4px;
}

.ai-chatbot-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ai-cb-text-light);
    animation: ai-chatbot-dot-bounce 1.4s infinite ease-in-out;
}

.ai-chatbot-typing span:nth-child(2) { animation-delay: 0.16s; }
.ai-chatbot-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes ai-chatbot-dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* ============================================================
   Yazı Alanı (Input Area)
   ============================================================ */
.ai-chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--ai-cb-border);
    background: var(--ai-cb-bg);
    flex-shrink: 0;
}

#ai-chatbot-input {
    flex: 1;
    border: 1px solid var(--ai-cb-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    background: var(--ai-cb-surface);
    color: var(--ai-cb-text);
    transition: border-color var(--ai-cb-transition), box-shadow var(--ai-cb-transition);
}

#ai-chatbot-input:focus {
    border-color: var(--ai-cb-primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

#ai-chatbot-input::placeholder {
    color: var(--ai-cb-text-light);
}

/* Mikrofon ve Gönder butonları */
.ai-chatbot-mic-btn,
.ai-chatbot-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--ai-cb-transition), transform var(--ai-cb-transition);
    flex-shrink: 0;
}

.ai-chatbot-mic-btn {
    background: var(--ai-cb-surface);
    color: var(--ai-cb-text-light);
}

.ai-chatbot-mic-btn:hover {
    background: var(--ai-cb-border);
    color: var(--ai-cb-text);
}

.ai-chatbot-mic-btn.recording {
    background: #EF4444;
    color: #FFFFFF;
    animation: ai-chatbot-record-pulse 1s infinite;
}

@keyframes ai-chatbot-record-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    50%      { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.ai-chatbot-send-btn {
    background: var(--ai-cb-primary);
    color: #FFFFFF;
}

.ai-chatbot-send-btn:hover {
    background: var(--ai-cb-primary-dark);
    transform: scale(1.05);
}

.ai-chatbot-send-btn:active {
    transform: scale(0.95);
}

/* ============================================================
   Responsive Tasarım
   ============================================================ */

/* Tablet */
@media (max-width: 768px) {
    #ai-chatbot-modal {
        width: 90vw;
        right: 5vw;
        bottom: 90px;
        max-height: 480px;
    }

    #ai-chatbot-trigger {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
}

/* Mobil */
@media (max-width: 480px) {
    #ai-chatbot-modal {
        width: 92vw;
        right: 4vw;
        bottom: 84px;
        max-height: 70vh;
        border-radius: 14px;
    }

    #ai-chatbot-trigger {
        bottom: 12px;
        right: 12px;
        width: 52px;
        height: 52px;
    }

    .ai-chatbot-messages {
        padding: 12px;
        min-height: 200px;
    }

    .ai-chatbot-msg {
        max-width: 88%;
        font-size: 13px;
    }

    #ai-chatbot-input {
        font-size: 13px;
        padding: 8px 14px;
    }
}

/* ============================================================
   Erişilebilirlik – Klavye odaklanma
   ============================================================ */
#ai-chatbot-trigger:focus-visible,
.ai-chatbot-close-btn:focus-visible,
.ai-chatbot-mic-btn:focus-visible,
.ai-chatbot-send-btn:focus-visible {
    outline: 3px solid var(--ai-cb-primary-light);
    outline-offset: 2px;
}
