/* ==========================================
   CORPORATE CHATBOT CSS SCOPING & RWD
   ========================================== */
#chatbot-brain-wrapper {
    --brand-blue: #0f172a;
    --brand-accent: #2563eb;
    --success: #10b981;
    --bg-light: #f8fafc;
    --border-color: #e2e8f0;
    
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
    position: relative;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    overflow: hidden; 
}

#chatbot-brain-wrapper * { box-sizing: border-box; margin: 0; padding: 0; }

/* Preloader */
#chatbot-brain-wrapper #preloader { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #ffffff; z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity 0.4s; }
#chatbot-brain-wrapper .spinner { width: 35px; height: 35px; border: 3px solid #e2e8f0; border-top: 3px solid var(--brand-accent); border-radius: 50%; animation: spin 1s linear infinite; }
#chatbot-brain-wrapper #loadingText { margin-top: 15px; font-size: 13px; font-weight: 600; color: #475569; }
#chatbot-brain-wrapper #progressPct { font-size: 18px; font-weight: 800; color: var(--brand-accent); margin-top: 8px; }
#chatbot-brain-wrapper .progress-bar-container { width: 200px; height: 4px; background: #e2e8f0; border-radius: 4px; margin-top: 8px; overflow: hidden; }
#chatbot-brain-wrapper .progress-bar-fill { height: 100%; width: 0%; background: var(--brand-accent); transition: width 0.1s linear; }

/* Floating Controls */
#chatbot-brain-wrapper .floating-controls {
    position: absolute;
    top: 10px;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 50;
}

#chatbot-brain-wrapper .status-badge {
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
#chatbot-brain-wrapper .status-badge.loading { background: #fff7ed; color: #ea580c; border: 1px solid #fdba74; }
#chatbot-brain-wrapper .status-badge.active { background: #f0fdf4; color: #15803d; border: 1px solid #86efac; }

#chatbot-brain-wrapper .control-icon-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #475569;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: 0.2s;
}
#chatbot-brain-wrapper .control-icon-btn:hover { background: #f1f5f9; color: var(--brand-blue); border-color: #94a3b8; }
#chatbot-brain-wrapper .control-icon-btn:active { transform: scale(0.95); }

/* Chat Box */
#chatbot-brain-wrapper .chat-box { 
    flex: 1 1 0; 
    min-height: 0; 
    /* Changed padding-top from 40px to 12px to keep it on the same line */
    padding: 12px 15px 10px 15px;
    overflow-y: auto; 
    overflow-x: hidden; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    scroll-behavior: smooth; 
}
#chatbot-brain-wrapper .chat-box::-webkit-scrollbar { width: 5px; }
#chatbot-brain-wrapper .chat-box::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* Messages */
#chatbot-brain-wrapper .msg { 
    padding: 12px 16px; 
    border-radius: 12px; 
    font-size: 14px; 
    line-height: 1.6; 
    max-width: 85%; 
    word-wrap: break-word; 
    overflow-wrap: break-word; 
    word-break: break-word; 
    animation: slideUp 0.3s ease-out forwards; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
#chatbot-brain-wrapper .user-msg { 
    background: var(--brand-accent); 
    color: white; 
    align-self: flex-end; 
    border-bottom-right-radius: 2px; 
}
#chatbot-brain-wrapper .bot-msg { 
    background: #ffffff; 
    color: var(--brand-blue); 
    align-self: flex-start; 
    border-bottom-left-radius: 2px; 
    border: 1px solid var(--border-color); 
    width: 100%; 
}

#chatbot-brain-wrapper .welcome-card { border-left: 3px solid var(--brand-accent); }

/* Suggestions & Progress */
#chatbot-brain-wrapper .pct-badge { display: inline-block; font-size: 11px; font-weight: 600; color: #475569; background: #f1f5f9; padding: 4px 8px; border-radius: 4px; margin-top: 8px; border: 1px solid #e2e8f0; }
#chatbot-brain-wrapper .suggestion-btn { display: flex; justify-content: space-between; align-items: center; width: 100%; background: #ffffff; color: var(--brand-accent); border: 1px solid #bfdbfe; padding: 10px 14px; text-align: left; border-radius: 8px; margin-top: 8px; cursor: pointer; font-size: 13px; font-weight: 500; transition: 0.2s; }
#chatbot-brain-wrapper .suggestion-btn:hover { background: #eff6ff; border-color: #60a5fa; }
#chatbot-brain-wrapper .btn-pct { font-weight: 700; color: #0ea5e9; background: #e0f2fe; padding: 2px 6px; border-radius: 4px; font-size: 11px; }

/* Input Form */
#chatbot-brain-wrapper .input-form { 
    display: flex; 
    flex-shrink: 0; 
    padding: 12px 20px; 
    background: rgba(255, 255, 255, 0.95); 
    backdrop-filter: blur(12px); 
    border-top: 1px solid var(--border-color); 
    align-items: center; 
    gap: 10px; 
    min-height: 60px;
}

#chatbot-brain-wrapper .icon-btn { 
    display: flex; align-items: center; justify-content: center; 
    width: 40px; height: 40px; border-radius: 8px; border: none; cursor: pointer; transition: 0.2s; outline: none; 
    flex-shrink: 0; 
}
#chatbot-brain-wrapper .mic-btn { background: #f1f5f9; color: #64748b; }
#chatbot-brain-wrapper .mic-btn:hover { background: #e2e8f0; color: var(--brand-blue); }
#chatbot-brain-wrapper .mic-btn.recording { background: #ef4444; color: white; animation: pulse 1.5s infinite; }

#chatbot-brain-wrapper .input-form input { 
    flex: 1; padding: 12px 16px; border: 1px solid #cbd5e1; border-radius: 8px; outline: none; font-size: 14px; background: #f8fafc; color: var(--brand-blue); transition: 0.3s;
    min-width: 0; 
}
#chatbot-brain-wrapper .input-form input:focus { border-color: var(--brand-accent); background: #ffffff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

#chatbot-brain-wrapper .send-btn { background: var(--brand-accent); color: white; }
#chatbot-brain-wrapper .send-btn:hover:not(:disabled) { background: #1d4ed8; }
#chatbot-brain-wrapper .send-btn:disabled { background: #94a3b8; cursor: not-allowed; }
#chatbot-brain-wrapper .send-btn:active:not(:disabled) { transform: scale(0.95); }

/* Actions (TTS & Copy) */
#chatbot-brain-wrapper .typing-indicator { display: inline-block; padding: 6px 12px; background: transparent; border: none; box-shadow: none; animation: none;}
#chatbot-brain-wrapper .typing-pulse { display: inline-block; animation: pulseText 1.5s infinite; font-weight:600;}
#chatbot-brain-wrapper .action-bar { display: flex; justify-content: flex-end; align-items: center; margin-top: 10px; border-top: 1px solid #f1f5f9; padding-top: 8px; gap: 6px; flex-wrap: wrap; }
#chatbot-brain-wrapper .action-btn { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 4px; padding: 5px 10px; cursor: pointer; font-size: 12px; font-weight: 600; color: #64748b; transition: 0.2s; display: flex; align-items: center; gap: 4px; }
#chatbot-brain-wrapper .action-btn:hover { background: #f1f5f9; color: var(--brand-blue); border-color: #cbd5e1; }
#chatbot-brain-wrapper .action-btn.active { background: #e0f2fe; color: #0284c7; border-color: #7dd3fc; }

/* Animations */
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes pulseText { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }
@keyframes slideUp { to { opacity: 1; transform: translateY(0); } }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* =========================================================================
   NEW: NATURAL HUMAN TYPING (3 TIMES) & GLOW (Do Not Modify Above)
   ========================================================================= */

/* 1. High Attraction Glowing Box */
#chatbot-brain-wrapper .high-attention-glow {
    position: relative;
    border-left: 3px solid var(--success) !important; 
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.08) 0%, rgba(255, 255, 255, 0) 60%);
    animation: premiumNeonPulse 2s infinite alternate ease-in-out;
}

@keyframes premiumNeonPulse {
    0% { box-shadow: 0 0 8px rgba(16, 185, 129, 0.15), inset 4px 0 10px rgba(16, 185, 129, 0.05); border-left-color: #10b981; }
    100% { box-shadow: 0 0 18px rgba(16, 185, 129, 0.4), inset 6px 0 15px rgba(16, 185, 129, 0.15); border-left-color: #34d399; }
}

/* 2. Common Properties for Natural Typing */
#chatbot-brain-wrapper .loop-type-title,
#chatbot-brain-wrapper .loop-type-text1,
#chatbot-brain-wrapper .loop-type-text2 {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    max-width: 0; /* Hidden initially */
    vertical-align: bottom;
}

/* 3. The 3 Lines styling & 5 iterations trick (gives EXACTLY 3 plays and stops at end) */
#chatbot-brain-wrapper .loop-type-title {
    color: var(--success);
    font-size: 16px;
    border-right: 2px solid transparent;
    /* 10s total cycle, linear speed for natural feel, 5 alternate iterations */
    animation: naturalType1 10s linear 5 alternate forwards; 
    text-shadow: 0 0 4px rgba(16,185,129,0.2);
}

#chatbot-brain-wrapper .loop-type-text1 {
    color: #475569;
    font-size: 13px;
    border-right: 2px solid transparent;
    animation: naturalType2 10s linear 5 alternate forwards;
    margin-top: 6px;
}

#chatbot-brain-wrapper .loop-type-text2 {
    color: var(--brand-accent);
    font-size: 13.5px;
    font-weight: 600;
    border-right: 2px solid transparent;
    animation: naturalType3 10s linear 5 alternate forwards;
    margin-top: 2px;
}

/* 4. Natural Keyframes Using Exact Character (ch) Widths */
/* Line 1: "Green AI Assistant" -> Approx 20ch */
@keyframes naturalType1 {
    0%, 5% { max-width: 0; border-right-color: var(--success); }
    25% { max-width: 20ch; border-right-color: var(--success); }
    26%, 100% { max-width: 20ch; border-right-color: transparent; }
}

/* Line 2: "Systems online. Initializing..." -> Approx 33ch */
@keyframes naturalType2 {
    0%, 30% { max-width: 0; border-right-color: transparent; }
    31% { border-right-color: #475569; }
    55% { max-width: 33ch; border-right-color: #475569; }
    56%, 100% { max-width: 33ch; border-right-color: transparent; }
}

/* Line 3: "I am ready to answer your questions." -> Approx 38ch */
@keyframes naturalType3 {
    0%, 60% { max-width: 0; border-right-color: transparent; }
    61% { border-right-color: var(--brand-accent); }
    90% { max-width: 38ch; border-right-color: var(--brand-accent); }
    95%, 100% { max-width: 38ch; border-right-color: transparent; } /* Cursor blinks out at end */
}

/* ==========================================
   100% RESPONSIVE (4 Devices Setup)
   ========================================== */
/* Tablet & Small Laptops */
@media (max-width: 992px) {
    #chatbot-brain-wrapper .chat-box { padding: 12px 15px 10px 15px; } /* Fixed padding */
    #chatbot-brain-wrapper .msg { max-width: 90%; }
    #chatbot-brain-wrapper .loop-type-title { font-size: 15px; }
    #chatbot-brain-wrapper .loop-type-text1 { font-size: 12.5px; }
    #chatbot-brain-wrapper .loop-type-text2 { font-size: 13px; }
}

/* Mobile Devices */
@media (max-width: 768px) {
    #chatbot-brain-wrapper .input-form { padding: 10px 12px; gap: 6px; }
    #chatbot-brain-wrapper .icon-btn { width: 38px; height: 38px; }
    #chatbot-brain-wrapper .input-form input { padding: 10px 12px; font-size: 13px; }
    #chatbot-brain-wrapper .floating-controls { right: 10px; top: 8px; }
    #chatbot-brain-wrapper .chat-box { padding: 12px 12px 10px 12px; } /* Fixed padding */
    #chatbot-brain-wrapper .msg { font-size: 13px; max-width: 95%; }
    #chatbot-brain-wrapper .action-btn { font-size: 11px; padding: 4px 8px; }
    
    #chatbot-brain-wrapper .loop-type-title { font-size: 14px; }
    #chatbot-brain-wrapper .loop-type-text1 { font-size: 11.5px; }
    #chatbot-brain-wrapper .loop-type-text2 { font-size: 12px; }
}

/* Ultra Small Mobile Screens (320px - 380px) */
@media (max-width: 380px) {
    #chatbot-brain-wrapper .input-form { gap: 4px; padding: 8px 6px; }
    #chatbot-brain-wrapper .icon-btn { width: 34px; height: 34px; }
    #chatbot-brain-wrapper .input-form input { font-size: 12px; }
    
    #chatbot-brain-wrapper .loop-type-title { font-size: 13px; }
    #chatbot-brain-wrapper .loop-type-text1 { font-size: 11px; }
    #chatbot-brain-wrapper .loop-type-text2 { font-size: 11px; }
    
    @keyframes premiumNeonPulse {
        0% { box-shadow: 0 0 4px rgba(16, 185, 129, 0.1); border-left-color: #10b981; }
        100% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.3); border-left-color: #34d399; }
    }
}