﻿/* ========================================
   KYSTENO AI CHAT - Claude-Clean Design
   ======================================== */

/* ===== WIDGET & TOGGLE BUTTON ===== */
.ai-chat-widget {
    position: fixed;
    bottom: 50px;
    right: 50px;
    z-index: 9999;
}

.ai-chat-button {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 6px;
}

.ai-chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 28px rgba(79, 70, 229, 0.45);
}

.ai-chat-button .ai-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
}

.ai-chat-button .ai-icon-light { display: block; }
.ai-chat-button .ai-icon-dark { display: none; }
.dark-mode .ai-chat-button .ai-icon-light { display: none; }
.dark-mode .ai-chat-button .ai-icon-dark { display: block; }

/* ===== CHAT WINDOW ===== */
.ai-chat-window {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 50vw;
    min-width: 600px;
    max-width: 900px;
    height: 100vh;
    background: #FFFFFF;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.1);
    flex-direction: row;
    overflow: hidden;
}

.ai-chat-window.active {
    display: flex;
    animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.dark-mode .ai-chat-window {
    background: #1a1a1a;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.4);
}

/* ===== SIDEBAR ===== */
.ai-sidebar {
    width: 260px;
    min-width: 260px;
    height: 100%;
    background: #F7F7F7;
    border-right: 1px solid #E5E5E5;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, min-width 0.2s ease;
    overflow: hidden;
}

.dark-mode .ai-sidebar {
    background: #171717;
    border-right-color: #2a2a2a;
}

.ai-sidebar:not(.expanded) {
    width: 0;
    min-width: 0;
    border-right: none;
}

.ai-sidebar:not(.expanded) * {
    display: none;
}

/* Sidebar Header */
.ai-sidebar-header {
    padding: 12px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #E5E5E5;
}

.dark-mode .ai-sidebar-header {
    border-bottom-color: #2a2a2a;
}

.ai-new-chat-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #FFFFFF;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-new-chat-btn:hover {
    background: #F0F0F0;
    border-color: #ccc;
}

.dark-mode .ai-new-chat-btn {
    background: #252525;
    border-color: #3a3a3a;
    color: #e5e5e5;
}

.dark-mode .ai-new-chat-btn:hover {
    background: #303030;
}

.ai-new-chat-btn i {
    width: 18px;
    height: 18px;
}

.ai-sidebar-toggle-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    cursor: pointer;
    color: #666;
    transition: all 0.15s;
}

.ai-sidebar-toggle-btn:hover {
    background: #F0F0F0;
}

.dark-mode .ai-sidebar-toggle-btn {
    border-color: #3a3a3a;
    color: #999;
}

.dark-mode .ai-sidebar-toggle-btn:hover {
    background: #303030;
}

.ai-sidebar-toggle-btn i {
    width: 18px;
    height: 18px;
}

/* Sidebar Navigation */
.ai-sidebar-nav {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    color: #444;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.ai-nav-btn:hover {
    background: #EBEBEB;
}

.dark-mode .ai-nav-btn {
    color: #b0b0b0;
}

.dark-mode .ai-nav-btn:hover {
    background: #252525;
}

.ai-nav-btn i {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

/* Sidebar Divider */
.ai-sidebar-divider {
    height: 1px;
    background: #E5E5E5;
    margin: 8px 12px;
}

.dark-mode .ai-sidebar-divider {
    background: #2a2a2a;
}

/* Sidebar Scroll Content */
.ai-sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
}

.ai-sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.ai-sidebar-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.dark-mode .ai-sidebar-scroll::-webkit-scrollbar-thumb {
    background: #444;
}

/* Navigation Sections */
.ai-nav-section {
    margin-bottom: 16px;
}

.ai-nav-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    padding: 8px 12px 6px;
}

.dark-mode .ai-nav-header {
    color: #666;
}

.ai-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 14px;
    color: #333;
}

.ai-nav-item:hover {
    background: #EBEBEB;
}

.ai-nav-item.active {
    background: #E0E0E0;
}

.dark-mode .ai-nav-item {
    color: #ccc;
}

.dark-mode .ai-nav-item:hover {
    background: #252525;
}

.dark-mode .ai-nav-item.active {
    background: #303030;
}

.ai-nav-item i {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

.ai-nav-item i.starred {
    color: #F59E0B;
    opacity: 1;
}

.ai-nav-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-nav-count {
    font-size: 12px;
    color: #999;
    background: #E5E5E5;
    padding: 2px 6px;
    border-radius: 10px;
}

.dark-mode .ai-nav-count {
    background: #333;
    color: #888;
}

.ai-nav-empty {
    padding: 12px;
    font-size: 13px;
    color: #999;
    font-style: italic;
}

/* Sidebar Footer */
.ai-sidebar-footer {
    padding: 12px;
    border-top: 1px solid #E5E5E5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dark-mode .ai-sidebar-footer {
    border-top-color: #2a2a2a;
}

.ai-sidebar-user {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: default;
}

.ai-sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.ai-sidebar-username {
    font-size: 14px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dark-mode .ai-sidebar-username {
    color: #ccc;
}

.ai-settings-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #666;
    transition: all 0.15s;
}

.ai-settings-btn:hover {
    background: #E5E5E5;
}

.dark-mode .ai-settings-btn {
    color: #888;
}

.dark-mode .ai-settings-btn:hover {
    background: #2a2a2a;
}

.ai-settings-btn i {
    width: 18px;
    height: 18px;
}

/* ===== MAIN CHAT AREA ===== */
.ai-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #FFFFFF;
}

.dark-mode .ai-chat-main {
    background: #1a1a1a;
}

/* Chat Header */
.ai-chat-header {
    height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid #E5E5E5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FFFFFF;
}

.dark-mode .ai-chat-header {
    background: #1a1a1a;
    border-bottom-color: #2a2a2a;
}

.ai-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-header-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dark-mode .ai-header-icon {
    border-color: var(--primary-light);
}

.ai-chat-title {
    font-size: 15px;
    font-weight: 500;
    color: #1a1a1a;
}

.dark-mode .ai-chat-title {
    color: #e5e5e5;
}

.ai-header-actions {
    display: flex;
    gap: 4px;
}

.ai-header-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: #666;
    transition: all 0.15s;
}

.ai-header-btn:hover {
    background: #F0F0F0;
}

.dark-mode .ai-header-btn {
    color: #888;
}

.dark-mode .ai-header-btn:hover {
    background: #252525;
}

.ai-header-btn i {
    width: 18px;
    height: 18px;
}

/* Chat Messages */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

.dark-mode .ai-chat-messages::-webkit-scrollbar-thumb {
    background: #444;
}

/* Empty State */
.ai-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.ai-empty-state .ai-empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 24px;
    opacity: 0.9;
}

.ai-empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 8px;
}

.dark-mode .ai-empty-state h3 {
    color: #e5e5e5;
}

.ai-empty-state p {
    font-size: 14px;
    color: #666;
    margin: 0;
    max-width: 320px;
}

.dark-mode .ai-empty-state p {
    color: #888;
}

/* Messages */
.ai-msg {
    display: flex;
    max-width: 100%;
}

.ai-msg.user {
    justify-content: flex-end;
}

.ai-msg.user .ai-msg-content {
    background: #F0F0F0;
    border-radius: 20px 20px 4px 20px;
    max-width: 80%;
}

.dark-mode .ai-msg.user .ai-msg-content {
    background: #2a2a2a;
}

.ai-msg.assistant .ai-msg-content {
    background: transparent;
    max-width: 100%;
}

.ai-msg-content {
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.6;
    color: #1a1a1a;
}

.dark-mode .ai-msg-content {
    color: #e5e5e5;
}

.ai-msg-content code {
    background: #F5F5F5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
}

.dark-mode .ai-msg-content code {
    background: #2a2a2a;
}

.ai-msg-content pre {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.ai-msg-content pre code {
    background: transparent;
    padding: 0;
    color: #e5e5e5;
}

/* Typing Indicator */
.ai-msg.typing .ai-msg-content {
    padding: 16px;
}

.ai-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.ai-typing-dots span:nth-child(1) { animation-delay: 0s; }
.ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* Input Container */
.ai-chat-input-container {
    padding: 16px 24px 20px;
    background: #FFFFFF;
}

.dark-mode .ai-chat-input-container {
    background: #1a1a1a;
}

.ai-chat-input {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #F7F7F7;
    border: 1px solid #E0E0E0;
    border-radius: 24px;
    padding: 8px 8px 8px 20px;
    transition: all 0.2s;
}

.ai-chat-input:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.dark-mode .ai-chat-input {
    background: #252525;
    border-color: #3a3a3a;
}

.dark-mode .ai-chat-input:focus-within {
    border-color: #818CF8;
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.18);
}

.ai-chat-input textarea {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    outline: none;
    color: #1a1a1a;
    max-height: 150px;
    padding: 6px 0;
}

.ai-chat-input textarea:focus {
    box-shadow: none;
    border: none;
    outline: none;
}

.dark-mode .ai-chat-input textarea {
    color: #e5e5e5;
}

.ai-chat-input textarea::placeholder {
    color: #999;
}

.ai-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1a1a1a;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.15s;
    flex-shrink: 0;
}

.ai-send-btn:hover {
    background: #333;
}

.ai-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.dark-mode .ai-send-btn {
    background: var(--primary);
}

.dark-mode .ai-send-btn:hover {
    background: var(--primary-hover);
}

.ai-send-btn i {
    width: 18px;
    height: 18px;
}

.ai-input-footer {
    text-align: center;
    padding-top: 8px;
}

.ai-input-footer span {
    font-size: 12px;
    color: #999;
}

/* ===== VIEW HEADERS ===== */
.ai-view-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0 24px;
    border-bottom: 1px solid #E5E5E5;
    margin-bottom: 24px;
}

.dark-mode .ai-view-header {
    border-bottom-color: #2a2a2a;
}

.ai-view-header h2 {
    flex: 1;
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: #1a1a1a;
}

.dark-mode .ai-view-header h2 {
    color: #e5e5e5;
}

.ai-back-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    cursor: pointer;
    color: #666;
}

.ai-back-btn:hover {
    background: #F0F0F0;
}

.dark-mode .ai-back-btn {
    border-color: #3a3a3a;
    color: #888;
}

.ai-back-btn i {
    width: 18px;
    height: 18px;
}

.ai-btn-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #1a1a1a;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-btn-primary:hover {
    background: #333;
}

.dark-mode .ai-btn-primary {
    background: var(--primary);
}

.dark-mode .ai-btn-primary:hover {
    background: var(--primary-hover);
}

.ai-btn-primary i {
    width: 16px;
    height: 16px;
}

/* ===== PROJECTS VIEW ===== */
.ai-projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.ai-project-card {
    background: #F7F7F7;
    border: 1px solid #E5E5E5;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
}

.ai-project-card:hover {
    border-color: #ccc;
    background: #F0F0F0;
}

.dark-mode .ai-project-card {
    background: #222;
    border-color: #333;
}

.dark-mode .ai-project-card:hover {
    background: #2a2a2a;
}

.ai-project-card i {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.ai-project-name {
    font-weight: 500;
    color: #1a1a1a;
}

.dark-mode .ai-project-name {
    color: #e5e5e5;
}

.ai-project-count {
    font-size: 13px;
    color: #888;
}

/* ===== LIBRARY VIEW ===== */
.ai-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.ai-library-item {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-library-item:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ai-library-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== SEARCH VIEW ===== */
.ai-search-container {
    padding: 20px 0;
}

.ai-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #F7F7F7;
    border: 1px solid #E0E0E0;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.dark-mode .ai-search-input-wrap {
    background: #252525;
    border-color: #3a3a3a;
}

.ai-search-input-wrap i {
    width: 20px;
    height: 20px;
    color: #888;
}

.ai-search-input-wrap input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    outline: none;
    color: #1a1a1a;
}

.dark-mode .ai-search-input-wrap input {
    color: #e5e5e5;
}

.ai-search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-search-result {
    padding: 16px;
    background: #F7F7F7;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-search-result:hover {
    background: #EBEBEB;
}

.dark-mode .ai-search-result {
    background: #252525;
}

.dark-mode .ai-search-result:hover {
    background: #303030;
}

.ai-search-result-title {
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.dark-mode .ai-search-result-title {
    color: #e5e5e5;
}

.ai-search-result-preview {
    font-size: 13px;
    color: #666;
}

.dark-mode .ai-search-result-preview {
    color: #888;
}

/* ===== CHATS LIST ===== */
.ai-chats-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-chat-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #F7F7F7;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-chat-list-item:hover {
    background: #EBEBEB;
}

.dark-mode .ai-chat-list-item {
    background: #252525;
}

.dark-mode .ai-chat-list-item:hover {
    background: #303030;
}

.ai-chat-list-item i {
    width: 18px;
    height: 18px;
    color: #888;
}

.ai-chat-list-item span {
    flex: 1;
    color: #1a1a1a;
}

.dark-mode .ai-chat-list-item span {
    color: #e5e5e5;
}

.ai-chat-date {
    font-size: 13px;
    color: #888 !important;
}

/* ===== EMPTY MESSAGE ===== */
.ai-empty-message {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-size: 14px;
}

/* ===== CONTEXT MENU ===== */
.ai-context-menu {
    position: fixed;
    background: white;
    border: 1px solid #E5E5E5;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 10000;
    overflow: hidden;
}

.dark-mode .ai-context-menu {
    background: #252525;
    border-color: #3a3a3a;
}

.ai-context-header {
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    border-bottom: 1px solid #E5E5E5;
}

.dark-mode .ai-context-header {
    border-bottom-color: #3a3a3a;
}

.ai-context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: background 0.1s;
}

.ai-context-item:hover {
    background: #F5F5F5;
}

.dark-mode .ai-context-item {
    color: #ccc;
}

.dark-mode .ai-context-item:hover {
    background: #303030;
}

.ai-context-item.danger {
    color: #DC2626;
}

.ai-context-item i {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

/* ===== IMAGE MODAL ===== */
.ai-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 40px;
}

.ai-image-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 800px;
    max-height: 90vh;
    overflow: auto;
    position: relative;
}

.dark-mode .ai-image-modal-content {
    background: #1a1a1a;
}

.ai-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ai-image-modal-content img {
    width: 100%;
    display: block;
    border-radius: 16px 16px 0 0;
}

.ai-image-details {
    padding: 20px;
}

.ai-image-details p {
    margin: 0 0 12px;
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}

.dark-mode .ai-image-details p {
    color: #ccc;
}

.ai-image-details p:last-child {
    margin-bottom: 0;
}

/* ===== ARTIFACTS PANEL ===== */
.ai-artifacts-panel {
    width: 400px;
    border-left: 1px solid #E5E5E5;
    display: flex;
    flex-direction: column;
    background: #FAFAFA;
}

.dark-mode .ai-artifacts-panel {
    background: #171717;
    border-left-color: #2a2a2a;
}

.artifacts-header {
    height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid #E5E5E5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.dark-mode .artifacts-header {
    border-bottom-color: #2a2a2a;
}

.artifacts-header button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: #666;
}

.artifacts-header button:hover {
    background: #E5E5E5;
}

.artifacts-header button i {
    width: 18px;
    height: 18px;
}

.artifacts-content {
    flex: 1;
    overflow: auto;
    padding: 16px;
}

.artifacts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #888;
    text-align: center;
}

.artifacts-empty i {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.artifacts-empty p {
    font-size: 14px;
    margin: 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .ai-chat-window {
        width: 100vw;
        min-width: 100vw;
        max-width: 100vw;
    }
    
    .ai-sidebar {
        position: absolute;
        z-index: 10;
        height: 100%;
    }
    
    .ai-sidebar:not(.expanded) {
        display: none;
    }
}

/* ===== IMAGE GENERATION ===== */
.ai-generating-image {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: #666;
}

.ai-generating-icon {
    font-size: 20px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

.ai-generated-image {
    max-width: 100%;
    border-radius: 12px;
    display: block;
    margin: 8px 0;
}

.dark-mode .ai-generating-image {
    color: #999;
}

/* ===== FLOATING SIDEBAR EXPAND BUTTON ===== */
.ai-sidebar-expand-btn {
    position: absolute;
    left: 12px;
    top: 12px;
    width: 40px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    background: #FFFFFF;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    cursor: pointer;
    color: #666;
    z-index: 10;
    transition: all 0.15s;
}

.ai-sidebar-expand-btn:hover {
    background: #F0F0F0;
    border-color: #ccc;
}

.dark-mode .ai-sidebar-expand-btn {
    background: #252525;
    border-color: #3a3a3a;
    color: #999;
}

.dark-mode .ai-sidebar-expand-btn:hover {
    background: #303030;
}

.ai-sidebar-expand-btn i {
    width: 18px;
    height: 18px;
}

/* Show expand button when sidebar is collapsed */
.ai-sidebar:not(.expanded) ~ .ai-chat-main .ai-sidebar-expand-btn,
.ai-chat-window:has(.ai-sidebar:not(.expanded)) .ai-sidebar-expand-btn {
    display: flex;
}

/* Simpler approach - JS will toggle this */
.ai-sidebar-expand-btn.visible {
    display: flex;
}

/* ===== FIX: Settings modal above AI chat ===== */
#aiSettingsOverlay {
    z-index: 10000 !important;
}

/* ===== AI PREFERENCES PANEL ===== */
.ai-pref-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid #E5E5E5;
}

.ai-pref-group:last-child {
    border-bottom: none;
}

.dark-mode .ai-pref-group {
    border-bottom-color: #333;
}

.ai-pref-label {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-pref-icon {
    font-size: 20px;
    width: 32px;
    text-align: center;
}

.ai-pref-title {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.dark-mode .ai-pref-title {
    color: #e5e5e5;
}

.ai-pref-desc {
    font-size: 12px;
    color: #888;
}

.ai-pref-select {
    padding: 8px 12px;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    background: #FFFFFF;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    min-width: 160px;
    outline: none;
    transition: border-color 0.15s;
}

.ai-pref-select:hover {
    border-color: #ccc;
}

.ai-pref-select:focus {
    border-color: var(--primary);
}

.dark-mode .ai-pref-select {
    background: #252525;
    border-color: #3a3a3a;
    color: #e5e5e5;
}

.dark-mode .ai-pref-select:hover {
    border-color: #555;
}

/* ===== SIMPLE NEW CHAT LINK ===== */
.ai-new-chat-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    cursor: pointer;
    transition: color 0.15s;
}

.ai-new-chat-link:hover {
    color: var(--primary);
}

.dark-mode .ai-new-chat-link {
    color: #e5e5e5;
}

.dark-mode .ai-new-chat-link:hover {
    color: var(--primary);
}

.ai-new-chat-link i {
    width: 18px;
    height: 18px;
}

/* Update sidebar header for simple layout */
.ai-sidebar-header {
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #E5E5E5;
}

.dark-mode .ai-sidebar-header {
    border-bottom-color: #2a2a2a;
}

/* ===== LIBRARY TABS ===== */
.ai-library-tabs {
    display: flex;
    gap: 4px;
    padding: 0 0 16px;
    border-bottom: 1px solid #E5E5E5;
    margin-bottom: 16px;
}

.dark-mode .ai-library-tabs {
    border-bottom-color: #333;
}

.ai-library-tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-library-tab:hover {
    background: #F0F0F0;
    color: #333;
}

.ai-library-tab.active {
    background: #1a1a1a;
    color: white;
}

.dark-mode .ai-library-tab {
    color: #888;
}

.dark-mode .ai-library-tab:hover {
    background: #2a2a2a;
    color: #ccc;
}

.dark-mode .ai-library-tab.active {
    background: var(--primary);
    color: white;
}

/* ===== ARTIFACTS LIST ===== */
.ai-artifacts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-artifact-item {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: #F7F7F7;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-artifact-item:hover {
    background: #EBEBEB;
}

.dark-mode .ai-artifact-item {
    background: #252525;
}

.dark-mode .ai-artifact-item:hover {
    background: #303030;
}

.ai-artifact-icon {
    width: 40px;
    height: 40px;
    background: #E5E5E5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    flex-shrink: 0;
}

.dark-mode .ai-artifact-icon {
    background: #333;
    color: #888;
}

.ai-artifact-icon i {
    width: 20px;
    height: 20px;
}

.ai-artifact-info {
    flex: 1;
    min-width: 0;
}

.ai-artifact-lang {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.ai-artifact-preview {
    font-size: 13px;
    color: #333;
    font-family: 'SF Mono', Monaco, monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.dark-mode .ai-artifact-preview {
    color: #ccc;
}

.ai-artifact-source {
    font-size: 11px;
    color: #888;
}

/* ===== ARTIFACT MODAL ===== */
.ai-artifact-modal-content {
    background: #1a1a1a;
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ai-artifact-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #252525;
    color: #e5e5e5;
    font-size: 13px;
    font-weight: 500;
}

.ai-artifact-modal-header div {
    display: flex;
    gap: 4px;
}

.ai-artifact-modal-header button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #888;
    cursor: pointer;
}

.ai-artifact-modal-header button:hover {
    background: #333;
    color: #e5e5e5;
}

.ai-artifact-modal-header button i {
    width: 16px;
    height: 16px;
}

.ai-artifact-modal-content pre {
    flex: 1;
    margin: 0;
    padding: 16px;
    overflow: auto;
    background: #1a1a1a;
}

.ai-artifact-modal-content code {
    font-size: 13px;
    line-height: 1.5;
}

.ai-artifact-modal-footer {
    padding: 10px 16px;
    background: #252525;
    font-size: 12px;
    color: #888;
}

/* Library tabs with icons */
.ai-library-tab {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-library-tab i {
    width: 16px;
    height: 16px;
}

/* ===== ATTACH BUTTON ===== */
.ai-attach-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #888;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.ai-attach-btn:hover {
    background: #E5E5E5;
    color: #333;
}

.dark-mode .ai-attach-btn:hover {
    background: #333;
    color: #e5e5e5;
}

.ai-attach-btn i {
    width: 18px;
    height: 18px;
}

/* Attached files list (stacks multiple attachments above the input) */
.ai-attached-files {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
    max-height: 30vh;
    overflow-y: auto;
}

/* Attached file preview */
.ai-attached-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #F0F0F0;
    border-radius: 8px;
    font-size: 13px;
}

.dark-mode .ai-attached-file {
    background: #333;
}

.ai-attached-file img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}

.ai-attached-file-info {
    flex: 1;
    min-width: 0;
}

.ai-attached-file-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-attached-file-size {
    font-size: 11px;
    color: #888;
}

.ai-attached-file-remove {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #888;
    cursor: pointer;
}

.ai-attached-file-remove:hover {
    background: #ddd;
    color: #333;
}
/* ===== AI KNOWLEDGE BASE — SOURCE LINKS ===== */
.ai-msg-sources {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.dark-mode .ai-msg-sources {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.ai-sources-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 2px;
}

.ai-source-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: #F0F9FF;
    border: 1px solid #BAE6FD;
    border-radius: 20px;
    font-size: 12px;
    color: #0369A1;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1;
}

.ai-source-chip:hover {
    background: #0369A1;
    border-color: #0369A1;
    color: white;
}

.ai-source-chip svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.dark-mode .ai-source-chip {
    background: rgba(14, 116, 144, 0.15);
    border-color: rgba(14, 116, 144, 0.4);
    color: #38BDF8;
}

.dark-mode .ai-source-chip:hover {
    background: #0369A1;
    border-color: #0369A1;
    color: white;
}

/* ===== GUTTER ASK AI BUTTON ===== */
.gutter-ask-ai-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.gutter-ask-ai-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-deep) 100%);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

.gutter-ask-ai-btn:active {
    transform: translateY(0);
}