/* =========================================================================
   FILE: chatbot.css
   PURPOSE: eCafe Mitra AI Chatbot का पूरा डिज़ाइन (100% Original & Safe)
========================================================================= */

:root {
    --bot-primary: #8b5cf6;
    --bot-secondary: #f97316;
    --bot-bg: #ffffff;
    --bot-text: #1f2937;
    --user-bg: #8b5cf6;
    --msg-bg: #f1f5f9;
    --border-color: #e2e8f0;
}

/* Dark Mode Sync */
body.dark-mode { 
    --bot-bg: #1e293b; 
    --bot-text: #f1f5f9; 
    --msg-bg: #0f172a; 
    --border-color: #334155; 
}

/* --- Floating Chat Button & Badge --- */
.chat-btn { position: fixed; bottom: 20px; right: 20px; background: linear-gradient(135deg, var(--bot-secondary), var(--bot-primary)); color: white; width: 60px; height: 60px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 26px; cursor: pointer; box-shadow: 0 10px 20px rgba(139, 92, 246, 0.3); border: none; transition: 0.3s; z-index: 9999; pointer-events: auto; }
.chat-btn:hover { transform: scale(1.1); box-shadow: 0 15px 25px rgba(249, 115, 22, 0.4); }

.notification-badge { position: absolute; top: -2px; right: -2px; background: #ef4444; color: white; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 800; display: flex; justify-content: center; align-items: center; border: 2px solid white; animation: bounceAlert 2s infinite; display: none; }
@keyframes bounceAlert { 0%, 20%, 50%, 80%, 100% {transform: translateY(0);} 40% {transform: translateY(-8px);} 60% {transform: translateY(-4px);} }

/* --- Main Chat Window --- */
.chat-window { position: fixed; bottom: 90px; right: 20px; width: 350px; height: 500px; max-height: 80vh; background: var(--bot-bg); border-radius: 16px; box-shadow: 0 15px 35px rgba(0,0,0,0.25); display: none; flex-direction: column; overflow: hidden; z-index: 9999; border: 1px solid var(--border-color); transform-origin: bottom right; animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); pointer-events: auto; font-family: 'Poppins', 'Hind', sans-serif;}
@keyframes popUp { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* --- Chat Header (Draggable) --- */
.chat-header { background: linear-gradient(135deg, var(--bot-primary), var(--bot-secondary)); color: white; padding: 12px 15px; display: flex; justify-content: space-between; align-items: center; cursor: grab; border-radius: 15px 15px 0 0; margin: -1px -1px 0 -1px; }
.chat-header:active { cursor: grabbing; }
.header-left { display: flex; align-items: center; gap: 10px; pointer-events: none;}
.bot-avatar { width: 36px; height: 36px; background: white; color: var(--bot-primary); border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 18px; }
.chat-header h3 { margin: 0; font-size: 15px; font-weight: 600; color: white;}
.chat-header p { margin: 0; font-size: 11px; opacity: 0.9; transition: 0.3s; color: white;}

.header-actions { display: flex; gap: 12px; align-items: center; }
.head-btn { background: transparent; border: none; color: white; font-size: 16px; cursor: pointer; transition: 0.3s;}
.head-btn:hover { opacity: 0.7; transform: scale(1.1); }

/* ========================================================= */
/* 🎯 CHATBODY SCROLL FIX (Anti-Background Scroll) */
/* ========================================================= */

.chat-body { 
    flex: 1; 
    padding: 15px; 
    overflow-y: auto; 
    background: transparent; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    scroll-behavior: smooth; 
    
    /* 🔥 MAGIC LINE: यह लाइन पीछे वाले पेज (वेबसाइट) को 1 इंच भी नहीं हिलने देगी! */
    overscroll-behavior: contain; 
}

/* 🎨 सुंदर और पतला स्क्रॉल बार (ताकि गंदा न लगे) */
.chat-body::-webkit-scrollbar {
    width: 6px;
}
.chat-body::-webkit-scrollbar-track {
    background: transparent;
    margin: 5px; /* कोनों से दूरी */
}
.chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
.chat-body::-webkit-scrollbar-thumb:hover {
    background: #8b5cf6; /* होवर पर पर्पल */
}

/* 🌙 डार्क मोड स्क्रॉल बार सपोर्ट */
body.dark-mode .chat-body::-webkit-scrollbar-thumb { background: #475569; }
body.dark-mode .chat-body::-webkit-scrollbar-thumb:hover { background: #a78bfa; }

/* --- Messages (User & Bot) --- */
.msg-container { display: flex; flex-direction: column; max-width: 85%; }
.msg-container.bot { align-self: flex-start; }
.msg-container.user { align-self: flex-end; }
.msg { padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.6; font-family: 'Hind', sans-serif; word-wrap: break-word;}
.bot-msg { background: var(--msg-bg); color: var(--bot-text); border-bottom-left-radius: 3px; border: 1px solid var(--border-color); }
.user-msg { background: var(--user-bg); color: white; border-bottom-right-radius: 3px; box-shadow: 0 4px 10px rgba(139,92,246,0.2); }

.time-stamp { font-size: 9px; margin-top: 4px; font-weight: 600; display: flex; align-items: center; }
.bot .time-stamp { color: #94a3b8; justify-content: flex-start; margin-left: 2px;}
.user .time-stamp { color: #cbd5e1; justify-content: flex-end; margin-right: 2px;}

/* --- Smart Compact List Style for Tools --- */
.bot-tool-card { display: flex; flex-direction: row; align-items: center; gap: 10px; background: var(--bot-bg); border: 1px solid var(--border-color); padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--bot-text) !important; margin-top: 6px; transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.02); width: 100%; box-sizing: border-box;}
.bot-tool-card:hover { border-color: var(--bot-primary); background: var(--msg-bg); }

.bot-tool-icon-box { width: 32px; height: 32px; border-radius: 8px; background: #f3e8ff; color: var(--bot-primary); display: flex; justify-content: center; align-items: center; font-size: 14px; flex-shrink: 0; }
body.dark-mode .bot-tool-icon-box { background: #334155; }

.bot-tool-info { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.bot-tool-title { font-size: 12px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-tool-desc { font-size: 9px; color: #64748b; margin-top: 2px; }

.bot-tool-go { background: var(--bot-primary); color: white; padding: 4px 10px; border-radius: 12px; font-size: 10px; font-weight: 600; flex-shrink: 0; display: flex; align-items: center; gap: 4px;}
.bot-tool-go:hover { background: var(--bot-secondary); }

.bot-link-btn { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 6px 12px; background: var(--bot-primary); color: white !important; text-decoration: none; border-radius: 6px; font-size: 12px; font-weight: bold; transition: 0.3s; border: 1px solid transparent;}
.bot-link-btn:hover { background: transparent; color: var(--bot-primary) !important; border-color: var(--bot-primary); }

/* --- Quick Replies (Smart Chips) --- */
.quick-replies { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.chip-btn { background: var(--bot-bg); border: 1px solid var(--bot-primary); color: var(--bot-primary); padding: 5px 10px; border-radius: 15px; font-size: 11px; cursor: pointer; transition: 0.2s; font-weight: 600; text-decoration: none; display: inline-block; }
.chip-btn:hover { background: var(--bot-primary); color: white; }

/* --- Typing Indicator --- */
.typing { display: none; gap: 4px; padding: 8px 12px; background: var(--msg-bg); align-self: flex-start; border-radius: 12px; border-bottom-left-radius: 3px; }
.dot { width: 6px; height: 6px; background: #94a3b8; border-radius: 50%; animation: type 1.4s infinite ease-in-out both; }
.dot:nth-child(1) { animation-delay: -0.32s; } .dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes type { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* --- Chat Footer (Input, Mic, Send) --- */
.chat-footer { padding: 12px; background: var(--bot-bg); border-top: 1px solid var(--border-color); display: flex; gap: 8px; align-items: center; position: relative; width: 100% !important; box-sizing: border-box !important; }
.chat-input { flex: 1; padding: 10px 15px; border: 1px solid var(--border-color); border-radius: 20px; background: var(--msg-bg); color: var(--bot-text); outline: none; font-size: 13px; transition: 0.3s; min-width: 0 !important; font-size: 16px !important; }
.chat-input:focus { border-color: var(--bot-primary); }
.mic-btn { background: transparent; border: none; color: var(--bot-primary); font-size: 20px; cursor: pointer; transition: 0.3s; padding: 0 5px;}
.mic-btn.listening { color: #ef4444; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
.send-btn { background: var(--bot-primary); color: white; border: none; width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.3s; font-size: 16px; flex-shrink: 0 !important; }
.send-btn:hover { background: var(--bot-secondary); }

/* --- Auto Suggest Box --- */
.auto-suggest-box { position: absolute; bottom: 60px; left: 10px; right: 10px; background: var(--bot-bg); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: 0 -5px 15px rgba(0,0,0,0.1); max-height: 150px; overflow-y: auto; display: none; z-index: 10; padding: 5px; }
.suggest-item { padding: 8px 12px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--msg-bg); display: flex; align-items: center; gap: 10px; color: var(--bot-text); font-weight: 500;}
.suggest-item:hover { background: var(--msg-bg); border-radius: 6px;}
.suggest-item:last-child { border-bottom: none; }

/* ========================================================= */
/* 🎯 CHATBOT AUTO-SUGGEST SCROLLBAR (Slim & Premium) */
/* ========================================================= */

/* 1. स्क्रॉल बार की चौड़ाई को एकदम पतला (4px) किया */
.auto-suggest-box::-webkit-scrollbar {
    width: 5px; 
}

/* 2. ट्रैक (रास्ता) को पारदर्शी (Transparent) रखा */
.auto-suggest-box::-webkit-scrollbar-track {
    background: transparent;
    margin: 5px; /* कोनों से दूरी */
}

/* 3. पकड़ने वाला हिस्सा (Thumb) - गोल कैप्सूल जैसा */
.auto-suggest-box::-webkit-scrollbar-thumb {
    background-color: #cbd5e1; /* लाइट मोड के लिए हल्का ग्रे */
    border-radius: 10px;
}

/* 4. डार्क मोड के लिए स्पेशल कलर्स */
body.dark-mode .auto-suggest-box::-webkit-scrollbar-thumb {
    background-color: #475569; /* गहरा ग्रे जो बैकग्राउंड से मैच करे */
}

/* 5. होवर करने पर आपकी थीम का पर्पल कलर दिखेगा */
.auto-suggest-box::-webkit-scrollbar-thumb:hover {
    background-color: #8b5cf6;
}

/* =========================================================
   📱 UNIVERSAL MOBILE RESPONSIVENESS (For all Phones)
   ========================================================= */
@media(max-width: 480px) { 
    /* 1. विंडो को सेंटर और चौड़ा किया ताकि छोटे फोन पर जगह मिले */
    .chat-window { 
        width: 92% !important; 
        right: 4% !important; 
        left: 3% !important; 
        bottom: 80px !important; 
        height: 400px !important; 
        max-height: 65vh !important;
        border-radius: 16px !important;
        border: 1px solid rgba(0, 0, 0, 0.08) !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.25) !important;
    } 

    /* 2. हेडर को सिकोड़ा (Compact Header) */
    .chat-header { padding: 8px 12px !important; } 
    .chat-header h3 { font-size: 13px !important; }
    .bot-avatar { width: 30px !important; height: 30px !important; font-size: 14px !important; }
    .header-actions { gap: 5px !important; }
    .head-btn { font-size: 14px !important; }

    /* 3. मैसेज और टेक्स्ट (Text Fix) */
    .msg { font-size: 13px !important; padding: 8px 12px !important; }
    
    /* 4. टूल कार्ड्स को पतला किया (Slim Cards) */
    .bot-tool-card { 
        padding: 6px 8px !important; 
        gap: 6px !important; 
    }
    .bot-tool-title { font-size: 11px !important; }
    .bot-tool-go { padding: 3px 8px !important; font-size: 9px !important; }

    /* 5. फुटर और बटन (No-Cut Footer Magic) */
    .chat-footer { 
        padding: 8px !important; 
        gap: 5px !important; 
        width: 100% !important; 
        box-sizing: border-box !important; /* पैडिंग अंदर रखेगा */
    }
    .chat-input { 
        flex: 1 !important; 
        min-width: 0 !important; /* बॉक्स को छोटा होने देगा */
        font-size: 16px !important; /* iOS पर ज़ूम रोकेगा */
        padding: 8px 12px !important; 
    }
    .send-btn { 
        width: 36px !important; 
        height: 36px !important; 
        flex-shrink: 0 !important; /* बटन को पिचकने से रोकेगा */
        font-size: 14px !important;
    }
}