/* ===== AI FEATURES STYLESHEET ===== */

/* ===== AI TOOLBAR (post page) ===== */
.ai-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 20px 0;
    padding: 16px;
    background: linear-gradient(135deg, #1e2a3a, #2c3e50);
    border-radius: 8px;
    border-left: 4px solid #c0392b;
}
.ai-toolbar-title {
    width: 100%;
    font-size: 12px;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    font-weight: 600;
}
.ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #fff;
}
.ai-btn:hover { transform: translateY(-1px); opacity: 0.9; }
.ai-btn:active { transform: translateY(0); }
.ai-btn-summarize { background: linear-gradient(135deg, #8e44ad, #9b59b6); }
.ai-btn-sentiment { background: linear-gradient(135deg, #e67e22, #f39c12); }
.ai-btn-related   { background: linear-gradient(135deg, #16a085, #1abc9c); }
.ai-btn i { font-size: 13px; }
.ai-btn .ai-spinner { display: none; animation: spin 1s linear infinite; }
.ai-btn.loading .ai-btn-text { display: none; }
.ai-btn.loading .ai-spinner { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

/* AI Result Box */
.ai-result-box {
    display: none;
    margin: 16px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    animation: slideDown 0.3s ease;
}
.ai-result-box.show { display: block; }
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ai-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}
.ai-result-header.purple { background: linear-gradient(135deg, #8e44ad, #9b59b6); }
.ai-result-header.orange { background: linear-gradient(135deg, #e67e22, #f39c12); }
.ai-result-header.teal   { background: linear-gradient(135deg, #16a085, #1abc9c); }
.ai-result-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-result-body {
    padding: 16px;
    background: #fff;
    font-size: 14px;
    line-height: 1.7;
    color: #444;
}

/* Sentiment display */
.sentiment-display {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.sentiment-icon { font-size: 40px; }
.sentiment-label {
    font-size: 22px;
    font-weight: 800;
}
.sentiment-bar-wrap {
    flex: 1;
    min-width: 200px;
}
.sentiment-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}
.sentiment-bar-bg {
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}
.sentiment-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease;
}
.sentiment-counts {
    display: flex;
    gap: 16px;
    font-size: 12px;
    margin-top: 8px;
}
.sentiment-pos { color: #27ae60; font-weight: 600; }
.sentiment-neg { color: #e74c3c; font-weight: 600; }

/* Related news grid */
.ai-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}
.ai-related-item {
    border: 1px solid #eee;
    border-radius: 6px;
    overflow: hidden;
    transition: box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.ai-related-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    color: inherit;
}
.ai-related-img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}
.ai-related-no-img {
    width: 100%;
    height: 100px;
    background: linear-gradient(135deg, #e0e0e0, #bdbdbd);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 24px;
}
.ai-related-title {
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    color: #2c3e50;
}

/* ===== FLOATING CHATBOT ===== */
#chatbotToggle {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 54px;
    height: 54px;
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(192,57,43,0.5);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    animation: pulse 2s infinite;
}
#chatbotToggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(192,57,43,0.6);
    animation: none;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(192,57,43,0.5); }
    50%       { box-shadow: 0 4px 30px rgba(192,57,43,0.8); }
}
.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #f39c12;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

#chatbotWindow {
    position: fixed;
    bottom: 148px;
    right: 24px;
    width: 340px;
    max-height: 500px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 9000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: popUp 0.3s ease;
}
#chatbotWindow.open { display: flex; }
@keyframes popUp {
    from { opacity: 0; transform: scale(0.8) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.chatbot-header {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}
.chatbot-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.chatbot-header-info { flex: 1; }
.chatbot-header-name { font-weight: 700; font-size: 14px; }
.chatbot-header-status {
    font-size: 11px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}
.chatbot-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
}
.chatbot-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 280px;
    max-height: 320px;
}
.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-track { background: #f1f1f1; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.chat-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.chat-msg.user { flex-direction: row-reverse; }
.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}
.chat-msg.bot .chat-msg-avatar  { background: #f8d7da; color: #c0392b; }
.chat-msg.user .chat-msg-avatar { background: #d1ecf1; color: #0c5460; }
.chat-msg-bubble {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
}
.chat-msg.bot .chat-msg-bubble {
    background: #f8f9fa;
    color: #333;
    border-bottom-left-radius: 4px;
}
.chat-msg.user .chat-msg-bubble {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-bubble a { color: #c0392b; font-weight: 600; }
.chat-msg.user .chat-msg-bubble a { color: #ffe; }

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}
.typing-dot {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* Quick reply chips */
.quick-replies {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0 14px 8px;
}
.quick-chip {
    background: #f8d7da;
    color: #c0392b;
    border: 1px solid #f5c6cb;
    border-radius: 14px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.quick-chip:hover { background: #c0392b; color: #fff; border-color: #c0392b; }

.chatbot-input-wrap {
    padding: 12px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}
#chatbotInput {
    flex: 1;
    border: 2px solid #eee;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}
#chatbotInput:focus { border-color: #c0392b; }
#chatbotSend {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}
#chatbotSend:hover { transform: scale(1.1); }

/* ===== DARK MODE AI ===== */
body.dark-mode .ai-toolbar { background: linear-gradient(135deg, #13151f, #1a1d27); }
body.dark-mode .ai-result-body { background: #1a1d27; color: #ccc; }
body.dark-mode .ai-related-item { border-color: #2a2d3e; }
body.dark-mode .ai-related-title { color: #ddd; }
body.dark-mode .ai-related-no-img { background: linear-gradient(135deg, #252836, #1a1d27); }
body.dark-mode #chatbotWindow { background: #1a1d27; }
body.dark-mode .chatbot-messages { background: #1a1d27; }
body.dark-mode .chat-msg.bot .chat-msg-bubble { background: #252836; color: #ddd; }
body.dark-mode .chatbot-input-wrap { border-top-color: #2a2d3e; }
body.dark-mode #chatbotInput { background: #252836; border-color: #3a3d4e; color: #ddd; }
body.dark-mode .quick-chip { background: #2a1a1a; border-color: #5a2d2d; }
body.dark-mode .sentiment-bar-bg { background: #252836; }