/* ===== 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: 99998;
    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, .chatbot-window, #chatbotВетерow {
    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: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: popUp 0.3s ease;
}
#chatbotWindow.open, .chatbot-window.open, #chatbotВетерow.open { display: flex !important; }
@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; }

/* TUKEN MEDIA mono editorial skin */
.ai-toolbar {
    gap: 8px;
    margin: 28px 0;
    padding: 18px;
    border: 0;
    border-top: 4px solid var(--tuken-ink);
    border-radius: 0;
    background: #f0f0ee;
}
.ai-toolbar-title {
    margin-bottom: 8px;
    color: var(--tuken-ink);
    font: 800 12px/1.2 var(--tuken-display);
    letter-spacing: .1em;
}
.ai-toolbar-title i { color: var(--tuken-accent); }
.ai-btn {
    min-height: 40px;
    padding: 9px 15px;
    border: 1px solid var(--tuken-ink);
    border-radius: 999px;
    background: transparent;
    color: var(--tuken-ink);
    font: 700 13px/1 var(--tuken-display);
    transition: transform var(--tuken-fast) var(--tuken-ease), background-color var(--tuken-fast) var(--tuken-ease), color var(--tuken-fast) var(--tuken-ease);
}
.ai-btn-summarize,
.ai-btn-sentiment,
.ai-btn-related { background: transparent; }
.ai-btn:hover { background: var(--tuken-ink); color: #fff; opacity: 1; transform: translateY(-1px); }
.ai-btn:active { transform: scale(.98); }
.ai-btn:focus-visible,
.ai-result-close:focus-visible,
#chatbotToggle:focus-visible,
.chatbot-close:focus-visible,
.quick-chip:focus-visible,
#chatbotSend:focus-visible { outline: 3px solid var(--tuken-accent); outline-offset: 3px; }
.ai-btn.loading { background: var(--tuken-ink); color: #fff; }
.ai-result-box { border-radius: 0; box-shadow: var(--tuken-shadow); }
.ai-result-header,
.ai-result-header.purple,
.ai-result-header.orange,
.ai-result-header.teal { background: var(--tuken-ink); color: #fff; }
.ai-result-header::before { content: ''; width: 7px; height: 7px; margin-inline-end: 9px; border-radius: 50%; background: var(--tuken-accent); }
.ai-result-header > span { margin-inline-end: auto; }
.ai-result-body { background: #fff; color: var(--tuken-text); font-size: 15px; }
.ai-related-item { border: 0; border-bottom: 1px solid var(--tuken-line); border-radius: 0; }
.ai-related-item:hover { box-shadow: none; background: #f4f4f2; }
.ai-related-no-img { background: #dededb; color: #77777b; }
.ai-related-title { color: var(--tuken-ink); font-family: var(--tuken-display); font-weight: 800; }

#chatbotToggle {
    bottom: 82px;
    right: 22px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--tuken-ink);
    box-shadow: 0 12px 28px rgba(10,10,10,.24);
    animation: none;
}
#chatbotToggle:hover { background: var(--tuken-accent); transform: translateY(-2px); box-shadow: 0 16px 32px rgba(10,10,10,.28); }
.chatbot-badge { background: var(--tuken-accent); }
#chatbotWindow { border-radius: 0; box-shadow: 0 22px 60px rgba(10,10,10,.24); }
.chatbot-header { background: var(--tuken-ink); }
.chatbot-avatar { border-radius: 0; background: var(--tuken-accent); }
.chatbot-close { background: #2f2f32; }
.chat-msg.bot .chat-msg-avatar { background: #ededeb; color: var(--tuken-ink); }
.chat-msg.user .chat-msg-avatar { background: var(--tuken-ink); color: #fff; }
.chat-msg-bubble { border-radius: 0; }
.chat-msg.bot .chat-msg-bubble { background: #efefed; color: var(--tuken-ink); }
.chat-msg.user .chat-msg-bubble { background: var(--tuken-ink); color: #fff; }
.quick-chip { border: 1px solid var(--tuken-line); border-radius: 999px; background: #fff; color: var(--tuken-ink); }
.quick-chip:hover { border-color: var(--tuken-ink); background: var(--tuken-ink); color: #fff; }
#chatbotInput { border: 1px solid var(--tuken-line); border-radius: 0; font-size: 16px; }
#chatbotInput:focus { border-color: var(--tuken-ink); }
#chatbotSend { border-radius: 50%; background: var(--tuken-ink); }
#chatbotSend:hover { background: var(--tuken-accent); transform: translateY(-1px); }

body.dark-mode .ai-toolbar { border-top-color: #f4f4f2; background: #171719; }
body.dark-mode .ai-toolbar-title,
body.dark-mode .ai-btn { color: #f4f4f2; }
body.dark-mode .ai-btn { border-color: #f4f4f2; }
body.dark-mode .ai-btn:hover,
body.dark-mode .ai-btn.loading { background: #f4f4f2; color: #0a0a0a; }
body.dark-mode .ai-result-body { background: #171719; color: #f4f4f2; }
body.dark-mode .ai-related-title { color: #f4f4f2; }
body.dark-mode .ai-related-item { border-color: #3a3a3f; }
body.dark-mode #chatbotWindow,
body.dark-mode .chatbot-messages { background: #111113; }
body.dark-mode .chat-msg.bot .chat-msg-bubble { background: #252528; color: #f4f4f2; }
body.dark-mode .quick-chip { background: #171719; border-color: #424247; color: #f4f4f2; }

@media (max-width: 520px) {
    .ai-toolbar { padding: 15px; }
    .ai-btn { width: 100%; justify-content: center; }
    #chatbotWindow { right: 12px; bottom: 138px; width: calc(100vw - 24px); max-height: min(590px, calc(100svh - 160px)); }
    #chatbotToggle { right: 16px; bottom: 74px; }
}
