/* --- VARIABLES --- */
:root {
    --ai-primary: #b4d647;       /* ChatGPT-like Green */
    --ai-primary-hover: #b4d647;
    --ai-bg: #b4d647;
    --ai-bg-secondary: #f7f7f8;
    --ai-text-main: #343541;
    --ai-text-sub: #6e6e80;
    --ai-bubble-user: #10a37f;
    --ai-bubble-ai: #f0f0f0;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.2);
    --font-fam: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --- LAUNCH BUTTON --- */
.ai-btn {
    width: 60px; height: 60px; border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-hover));
    color: white; border: none; cursor: pointer; font-size: 30px;
    display: flex; justify-content: center; align-items: center;
    box-shadow: var(--shadow-soft);
    position: fixed; bottom: 25px; right: 25px; z-index: 9998;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.ai-btn:hover { transform: scale(1.1) rotate(10deg); box-shadow: var(--shadow-hover); }

/* --- MAIN WINDOW --- */
#aiAssistantWindow {
    position: fixed; right: 25px; bottom: 100px;
    width: 360px; height: 550px;
    background: var(--ai-bg);
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    border-radius: 16px;
    display: none; z-index: 9999;
    font-family: var(--font-fam);
    overflow: hidden;
    flex-direction: column;
    animation: aiSlideUp 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    border: 1px solid rgba(0,0,0,0.05);
}
@keyframes aiSlideUp { 
    from { transform: translateY(20px) scale(0.95); opacity: 0; } 
    to { transform: translateY(0) scale(1); opacity: 1; } 
}

/* --- HEADER --- */
#aiAssistantHeader {
    background: var(--ai-bg);
    border-bottom: 1px solid #eee;
    padding: 16px 20px;
    color: var(--ai-text-main);
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}
.ai-header-title { font-weight: 700; font-size: 16px; display:flex; align-items:center; gap:8px;}
#aiCloseBtn { 
    cursor: pointer; font-size: 24px; color: #999; line-height: 1; transition: 0.2s; 
    width: 30px; height: 30px; display:flex; align-items:center; justify-content:center; border-radius:50%;
}
#aiCloseBtn:hover { background: #f0f0f0; color: #333; }

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #ccc; }

/* --- VIEWS --- */
.ai-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; background: var(--ai-bg-secondary); }

/* --- MENU VIEW --- */
#aiMenu { padding: 20px; gap: 15px; overflow-y: auto; align-items: stretch; }
.ai-greeting-box {
    background: #fff;
    padding: 20px; border-radius: 12px;
    font-size: 14px; color: var(--ai-text-sub); 
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    text-align: center;
    border: 1px solid #eee;
}
#aiGreetingTitle { 
    display: block; font-weight: 800; font-size: 20px; 
    margin-bottom: 8px; color: var(--ai-text-main); 
}

.ai-menu-btn {
    background: #fff; border: 1px solid #e5e5e5; padding: 18px; border-radius: 12px;
    text-align: left; cursor: pointer; display: flex; flex-direction: row; align-items: center; gap: 12px;
    transition: all 0.2s ease; box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.ai-menu-btn:hover {
    border-color: var(--ai-primary); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(16, 163, 127, 0.15);
}
.ai-menu-icon { font-size: 24px; background: #e8f5e9; width: 45px; height: 45px; display:flex; align-items:center; justify-content:center; border-radius:10px; }
.ai-menu-text { display: flex; flex-direction: column; }
.ai-btn-title { font-weight: 700; font-size: 15px; color: var(--ai-text-main); margin-bottom: 2px; }
.ai-btn-desc { font-size: 12px; color: var(--ai-text-sub); }

/* --- CHAT AREA --- */
#aiBackBar {
    padding: 10px 15px; background: #fff; border-bottom: 1px solid #eee;
    font-size: 13px; color: var(--ai-primary); cursor: pointer; font-weight: 600; flex-shrink: 0;
    display: flex; align-items: center; gap: 5px;
}
#aiBackBar:hover { background: #fafafa; text-decoration: underline; }

#aiChatArea {
    flex: 1; overflow-y: auto; padding: 20px 15px;
    display: flex; flex-direction: column; gap: 16px;
    scroll-behavior: smooth;
}

.chat-bubble {
    padding: 12px 18px; border-radius: 18px; font-size: 14px;
    max-width: 85%; line-height: 1.5; position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    word-wrap: break-word;
}
.ai-msg { 
    align-self: flex-start; background: #fff; color: var(--ai-text-main); 
    border: 1px solid #e5e5e5; border-top-left-radius: 4px; 
}
.user-msg { 
    align-self: flex-end; background: var(--ai-primary); color: white; 
    border-bottom-right-radius: 4px; box-shadow: 0 2px 5px rgba(16, 163, 127, 0.3);
}

/* --- INPUT AREA --- */
.ai-input-area {
    padding: 15px; border-top: 1px solid #eee;
    display: flex; gap: 10px; background: #fff; align-items: center;
    flex-shrink: 0;
}
#aiInput {
    flex: 1; padding: 12px 16px; border: 1px solid #e5e5e5; background: #f9f9f9;
    border-radius: 24px; outline: none; font-size: 14px; color: #333; transition: 0.2s;
}
#aiInput:focus { border-color: var(--ai-primary); background: #fff; box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1); }

#aiSendBtn, #aiMicBtn {
    width: 42px; height: 42px; border: none; border-radius: 50%;
    cursor: pointer; font-size: 18px; display: flex;
    justify-content: center; align-items: center; transition: 0.2s; flex-shrink: 0;
}

#aiSendBtn { background: var(--ai-primary); color: white; }
#aiSendBtn:hover { transform: scale(1.05); background: var(--ai-primary-hover); }

#aiMicBtn { background: #f0f0f0; color: #555; }
#aiMicBtn:hover { background: #e0e0e0; color: #333; }
#aiMicBtn.listening {
    background: #ff4d4d; color: white;
    animation: pulseRed 1.5s infinite;
}
@keyframes pulseRed {
    0% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 77, 77, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}

/* --- BLOCK RESULTS --- */
.ai-results-container { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ai-block-link {
    padding: 8px 14px; background: #eefcf6; color: var(--ai-primary-hover);
    border: 1px solid #ccece4; border-radius: 20px; cursor: pointer;
    font-size: 13px; font-weight: 600; transition: 0.2s;
}
.ai-block-link:hover { background: var(--ai-primary); color: white; transform: translateY(-1px); border-color: var(--ai-primary); }

.ai-block-link-insert {
    background: var(--ai-primary); color: white; border: none; padding: 8px 16px;
    border-radius: 6px; cursor: pointer; font-size: 12px; margin-top: 5px;
}
.ai-block-link-insert:hover { opacity: 0.9; }

/* --- TYPING --- */
.typing-indicator { display: flex; gap: 5px; padding: 4px 2px; }
.dot { width: 6px; height: 6px; background: #bbb; 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); } }

/* --- DEV VIEW --- */
#aiDevView { justify-content: center; align-items: center; text-align: center; padding: 40px; }