@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
:root {
    --bg-main: #FFFFFF;
    --bg-sidebar: #F9FAFB;
    --bg-message-bot: #F3F4F6;
    --bg-message-user: #1F2937;
    --bg-hover: #F0F2F5;
    --bg-related-question: #FFFFFF;
    --bg-related-question-hover: #F0F2F5;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-user-message: #FFFFFF;
    --border-color: #E5E7EB;
    --accent: #111827;
    --accent-hover: #374151;
    --danger-color: #EF4444;
    --shadow-color: rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] {
    --bg-main: #111827;
    --bg-sidebar: #1F2937;
    --bg-message-bot: #374151;
    --bg-message-user: #4F46E5;
    --bg-hover: #374151;
    --bg-related-question: #1F2937;
    --bg-related-question-hover: #374151;
    --text-primary: #F9FAFB;
    --text-secondary: #9CA3AF;
    --text-user-message: #FFFFFF;
    --border-color: #374151;
    --accent: #4F46E5;
    --accent-hover: #6366F1;
    --danger-color: #F87171;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background-color: var(--bg-main); color: var(--text-primary); display: flex; height: 100vh; overflow: hidden; font-size: 14.5px; }
.container { display: flex; width: 100%; height: 100%; position: relative; }

.sidebar { width: 260px; background-color: var(--bg-sidebar); border-right: 1px solid var(--border-color); padding: 0.75rem; display: flex; flex-direction: column; transition: transform 0.3s ease-in-out; position: fixed; top: 0; left: 0; height: 100%; z-index: 100; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem; margin-bottom: 1rem; }
.logo { font-size: 1.1rem; font-weight: 600; }
#sidebar-close { display: none; background: none; border: none; cursor: pointer; color: var(--text-secondary); }

.sidebar-nav { flex-grow: 1; overflow-y: auto; }
.new-chat-btn { background-color: var(--bg-hover); display: flex; align-items: center; gap:5px; width: 100%; padding: 0.5rem; border-radius: 0.375rem; text-decoration: none; color: var(--text-primary); font-weight: 500; margin-bottom: 1rem; border: 1px solid var(--border-color);  cursor: pointer; transition: background-color 0.2s ease; font-size: 0.9rem; }
.new-chat-btn:hover { background-color: var(--bg-main); }
.new-chat-btn .icon { width: 18px; height: 18px; color: var(--text-secondary); }

.sidebar-nav a { display: flex; align-items: center; padding: 0.5rem; border-radius: 0.375rem; text-decoration: none; color: var(--text-primary); margin-bottom: 0.25rem; transition: background-color 0.2s ease; position: relative; font-size: 0.9rem; }
.sidebar-nav a:hover, .sidebar-nav a.active { background-color: var(--bg-hover); }
.sidebar-nav .history-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.delete-chat-btn { display: none; position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 0.25rem; }
.sidebar-nav a:hover .delete-chat-btn { display: block; }
.delete-chat-btn:hover { color: var(--danger-color); }
.delete-chat-btn .icon { width: 16px; height: 16px; }
.sidebar-section-header { padding: 0 0.75rem; margin-bottom: 0.5rem; font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

/* --- Sidebar Footer --- */
.sidebar-footer { margin-top: auto; padding-top: 0.75rem; border-top: 1px solid var(--border-color); }
.theme-switcher { display: flex; justify-content: space-around; margin-bottom: 0.75rem; background-color: var(--bg-hover); padding: 0.25rem; border-radius: 0.5rem; }
.theme-switcher button { flex: 1; padding: 0.4rem; border: none; background-color: transparent; color: var(--text-secondary); cursor: pointer; border-radius: 0.375rem; font-weight: 500; transition: background-color 0.2s, color 0.2s; font-size: 0.85rem; }
.theme-switcher button.active { background-color: var(--bg-main); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

.sidebar-footer .btn { width: 100%; padding: 0.6rem; border-radius: 0.375rem; font-weight: 500; cursor: pointer; border: 1px solid var(--border-color); margin-bottom: 0.5rem; transition: background-color 0.2s, border-color 0.2s; font-size: 0.9rem; }
.sidebar-footer .btn-dark { background-color: var(--accent); color: var(--text-user-message); border-color: var(--accent); }
.sidebar-footer .btn-dark:hover { background-color: var(--accent-hover); border-color: var(--accent-hover); }
.sidebar-footer .btn-light { background-color: var(--bg-main); color: var(--text-primary); }
.sidebar-footer .btn-light:hover { background-color: var(--bg-hover); }
.sidebar-footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.5rem; }
.sidebar-footer-links a { color: var(--text-secondary); text-decoration: none; }
.sidebar-footer-links a:hover { text-decoration: underline; }

/* --- Topics Overlay --- */
.topics-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--bg-sidebar); z-index: 101; display: flex; flex-direction: column; transform: translateX(-100%); transition: transform 0.3s ease-in-out; padding: 0.75rem; }
.topics-overlay.open { transform: translateX(0); }
.topics-header { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem; margin-bottom: 1rem; }
.topics-header h3 { font-size: 1.1rem; font-weight: 600; }
#topics-close-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 1.5rem; line-height: 1; }
.topics-list { flex-grow: 1; overflow-y: auto; }
.topics-list a { display: block; padding: 0.6rem 0.75rem; border-radius: 0.375rem; text-decoration: none; color: var(--text-primary); font-weight: 500; margin-bottom: 0.25rem; transition: background-color 0.2s ease; font-size: 0.9rem; }
.topics-list a:hover { background-color: var(--bg-hover); }

/* --- Sidebar Overlay --- */
.sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 99; opacity: 0; visibility: hidden; transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out; }
.sidebar-overlay.open { opacity: 1; visibility: visible; }

/* --- Main Content --- */
.main-content { margin-left:260px; flex: 1; display: flex; flex-direction: column; height: 100vh; transition: margin-left 0.3s ease-in-out; overflow: hidden; }
.main-header { display: none; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); align-items: center; }
.main-header .logo { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
#menu-toggle { background: none; border: none; font-size: 1rem; cursor: pointer; color: var(--text-primary); margin-right: 1rem; }

/* --- Initial View --- */
.initial-view { flex-grow: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem; text-align: center; }
.initial-view h1 { font-size: 1.8rem; font-weight: 600; margin-bottom: 1.5rem; color: var(--text-primary); }
.initial-view .main-search-bar { position: relative; width: 100%; max-width: 580px; margin-bottom: 1.5rem; }
.initial-view .main-search-bar input { width: 100%; padding: 0.9rem 3.5rem 0.9rem 1rem; border-radius: 0.5rem; border: 1px solid var(--border-color); font-size: 1rem; background-color: var(--bg-main); color: var(--text-primary); }
.initial-view .main-search-bar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.initial-view .main-search-bar button { background: var(--accent); position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%); border: none; border-radius: 0.375rem; width: 32px; height: 32px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.initial-view .main-search-bar button:hover { background-color: var(--accent-hover); }
.suggestion-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
.suggestion-buttons button { background: none; border: 1px solid var(--border-color); padding: 0.5rem 1rem; border-radius: 9999px; cursor: pointer; color: var(--text-secondary); transition: background-color 0.2s, border-color 0.2s; font-size: 0.9rem; }
.suggestion-buttons button:hover { background-color: var(--bg-hover); border-color: var(--accent); color: var(--text-primary); }

/* --- Chat View --- */
#chat-view { display: none; flex-direction: column; height: 100%; width: 100%; }
.jw-width { margin-right: auto; margin-left: auto; padding-left: 1rem; padding-right: 1rem; width:800px; }
.artical-chats{ flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; }
.artical-chats .main-search-bar { position: absolute; width:800px; bottom: 0; background: linear-gradient(to top, var(--bg-main) 70%, transparent 100%); padding: 1.5rem 0; border-top: none; }
.artical-chats .main-search-bar .input-wrapper { position: relative; max-width: 750px; margin: 0 auto; padding: 0 1rem; }
.artical-chats .main-search-bar input { width: 100%; padding: 1rem 3.5rem 1rem 1rem; border-radius: 0.5rem; border: 1px solid var(--border-color); font-size: 1rem; background-color: var(--bg-main); color: var(--text-primary); box-shadow: 0 2px 8px var(--shadow-color); }
.artical-chats .main-search-bar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.artical-chats .main-search-bar button { background: var(--accent); position: absolute; right: 0.5rem; top: 38%; transform: translateY(-50%); border: none; border-radius: 50%; width: 40px; height: 40px; cursor: pointer; display: flex ; align-items: center; justify-content: center; }
.artical-chats .main-search-bar button:hover { background-color: var(--accent-hover); }
.artical-chats .main-search-bar button .icon { width: 16px; height: 16px; color: white; }
.artical-chats .main-search-bar span{ display: block; text-align: center; font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.75rem; }
#chat-messages{ margin-bottom:120px; padding:25px 0 5px; }

.message-wrapper { display: flex; margin-bottom: 1rem; max-width: 100%; align-items: flex-start; }
/*.message-wrapper.user { margin-left: auto; }*/
/*.message-wrapper.bot { margin-right: auto; }*/

.bot .message-content{ padding: 0.7rem 0rem; }
.message-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background-color: var(--bg-hover); flex-shrink: 0; margin: 0.50rem; }
.message-avatar .icon { width: 16px; height: 16px; }
.message-content { color: var(--text-primary); line-height: 1.6; padding: 0.7rem 1.1rem; border-radius: 0.75rem; width:100%; }
.message-wrapper.user .message-content { background-color: var(--bg-message-bot);  border: 1px solid var(--border-color); box-shadow: 0 1px 3px var(--shadow-color);  border-bottom-right-radius: 0.25rem; }
.message-wrapper.bot .message-content { border-bottom-left-radius: 0.25rem; }
.message-content p:not(:last-child) { margin-bottom: 0.75rem; }
.message-content ul, .message-content ol { padding-left: 1.25rem; margin-bottom: 0.75rem; }
.message-content ul li { margin-bottom: 0.25rem; }
.message-content a { color: var(--accent); text-decoration: none; font-weight: 500; }
.message-content a:hover { text-decoration: underline; }
.message-content strong { font-weight: 600; }
.message-content .sources-container { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.message-content .sources-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-primary); }
.message-content .source-link { display: block; font-size: 0.85rem; color: var(--text-secondary); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.25rem; }
.message-content .source-link:hover { text-decoration: underline; }
.related-questions-container { margin-top: 1rem; border-top: 1px solid var(--border-color); padding-top: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.related-questions-container .related-question { background: var(--bg-related-question); border: 1px solid var(--border-color); border-radius: 5px; padding: 0.3rem 0.5rem; text-align: left; cursor: pointer; transition: background-color 0.2s, border-color 0.2s; color: var(--text-primary); }
.related-questions-container .related-question:hover { background-color: var(--bg-related-question-hover); }


/* --- Message Actions --- */
.message-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; }
.action-btn { background: transparent; border: none; cursor: pointer; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; transition: background-color 0.2s, color 0.2s; }
.action-btn:hover { background-color: var(--bg-hover); color: var(--text-primary); }
.action-btn.active { background-color: var(--bg-hover); }
.like-btn.active { color: #3B82F6; }
.dislike-btn.active { color: var(--danger-color); }
.action-btn svg { width: 16px; height: 16px; }

/* --- Responsive --- */
@media (max-width: 1060px) { 
    .artical-chats .main-search-bar { width: 95%; padding: 1rem 0; position: fixed; }
    .jw-width { width: 100%; padding-left: 0.75rem; padding-right: 0.75rem; }
}

@media (max-width: 768px) {
    body { font-size: 14px; }
    .main-content { margin-left:0; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 20px rgba(0,0,0,0.2); }
    .sidebar.open #sidebar-close { display: block; }
    .main-header { display: flex; }
    
    .artical-chats .main-search-bar .input-wrapper { padding: 0 0.75rem; }
    #chat-messages { margin-bottom: 150px; }
    
    .artical-chats .main-search-bar button{ top: 33%; }
    
    
}