:root {
    --primary-color: #9A1B24;
    --primary-hover: #7a151c;
    --bg-light: #f8f9fa;
    --text-dark: #333333;
    --chat-width: 400px;
    --chat-height: 600px;
}

/* --- CHATBOT WIDGET STYLES --- */

.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: 'Poppins', sans-serif;
    
    /* ÖNEMLİ: Widget alanı kapalıyken tıklamaları engellemesin (Site butonlarına erişim için) */
    pointer-events: none; 
}

/* Sayfa yüklenirken animasyonları durduran sınıf */
.chat-widget.no-transition * {
    transition: none !important;
}

/* Toggle Button (Ana Buton) */
.chat-toggle-btn {
    background-color: var(--primary-color);
    color: white;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(154, 27, 36, 0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    
    /* Buton her zaman tıklanabilir olmalı */
    pointer-events: auto; 
    
    /* Butonun kendi içindeki layout'u koru */
    flex-shrink: 0; 
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    background-color: var(--primary-hover);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background-color: #fbbf24;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

/* Chat Penceresi */
.chat-box {
    width: var(--chat-width);
    height: var(--chat-height);
    
    /* Ekranın tepesine yapışmaması için max-height hesaplaması */
    max-height: calc(100vh - 140px);
    
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 24px; /* Butonla arasındaki boşluk */
    
    /* Kapalı Durum */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    visibility: hidden;
    
    /* Kapalıyken tıklanamaz */
    pointer-events: none;

    /* DÜZELTME: 'transition' buradan kaldırıldı. 
       Sayfa yenilendiğinde açılıp kapanma sorununu önlemek için 
       animasyon özelliği JS ile .loaded sınıfı eklendikten sonra devreye girecek. */
}

/* Sayfa yüklendikten sonra animasyonları aktif eden sınıf */
.chat-box.loaded {
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.chat-box.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    
    /* Açıkken tıklanabilir olmalı */
    pointer-events: auto;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, var(--primary-color), #6e1219);
    color: white;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    flex-shrink: 0; /* Header büzülmesin */
}

.header-info h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
    letter-spacing: 0.3px;
}

.status-dot {
    height: 8px;
    width: 8px;
    background-color: #4ade80;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

/* Mesaj Alanı */
.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background-color: #f3f4f6;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    
    /* Scroll bar alanı */
    scrollbar-width: thin;
}

.message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    animation: slideIn 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.bot {
    background-color: #ffffff;
    color: var(--text-dark);
    border-bottom-left-radius: 2px;
    margin-right: auto;
}

.message.user {
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 2px;
    margin-left: auto;
    text-align: right;
    box-shadow: 0 4px 10px rgba(154, 27, 36, 0.2);
}

/* Seçenek Butonları (Chips) */
.options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    animation: fadeIn 0.4s ease;
}

.option-btn {
    background-color: #ffffff;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 10px 18px;
    border-radius: 25px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.option-btn:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(154, 27, 36, 0.25);
}

/* Footer (Menü) */
.chat-footer-nav {
    background: #fff;
    border-top: 1px solid #eee;
    padding: 12px;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    flex-shrink: 0; /* Footer büzülmesin */
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #9ca3af;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    padding: 6px 16px;
    border-radius: 8px;
}

.nav-item:hover {
    color: var(--primary-color);
    background-color: #fff1f2;
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

/* Yazıyor Göstergesi */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 12px;
    width: fit-content;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-bottom-left-radius: 2px;
}

.dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 10px; }

/* === MOBİL DÜZENLEMELERİ === */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 20px;
        right: 20px;
        align-items: flex-end; /* Sağ alt köşe hizalamasını koru */
    }

    .chat-box { 
        width: 90vw; /* Mobilde biraz boşluk bırak */
        height: auto; /* İçeriğe göre uza, ama max-height ile sınırlı kal */
        
        /* Mobilde ekranın tepesine yapışmasını engellemek için daha sıkı bir hesaplama */
        max-height: calc(100vh - 130px);
        
        margin-bottom: 16px; /* Butonla arasındaki boşluğu mobilde biraz azalt */
        right: auto; 
        bottom: auto;
    }
}