/* ============================================== */
/* CSS VARIABLES - Easy to customize             */
/* ============================================== */

:root {
    /* Colors - Background */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #0d0d14;
    
    /* Colors - Text */
    --text-primary: #e8e8ed;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --text-hint: rgba(255, 255, 255, 0.25);
    
    /* Colors - Borders */
    --border-light: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.15);
    
    /* Colors - Accent */
    --accent-blue: #63b3ed;
    --accent-blue-dark: #4299e1;
    --accent-purple: #667eea;
    --accent-purple-dark: #764ba2;
    --accent-green: #48bb78;
    --accent-orange: #f6ad55;
    --accent-orange-dark: #ed8936;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-blue: linear-gradient(135deg, #63b3ed, #4299e1);
    --gradient-orange: linear-gradient(135deg, #f6ad55, #ed8936);
    
    /* Spacing */
    --sidebar-width: 280px;
    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;
    
    /* Typography */
    --font-primary: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: "JetBrains Mono", monospace;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}


/* ============================================== */
/* RESET & BASE STYLES                           */
/* ============================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background: linear-gradient(145deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input,
textarea {
    font-family: inherit;
}


/* ============================================== */
/* SCROLLBAR STYLES                              */
/* ============================================== */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}


/* ============================================== */
/* ANIMATIONS                                    */
/* ============================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}


/* ============================================== */
/* LAYOUT - Main Container                       */
/* ============================================== */

.app-container {
    display: flex;
    min-height: 100vh;
}


/* ============================================== */
/* SIDEBAR - Shared Styles                       */
/* ============================================== */

.sidebar {
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
}

.sidebar-left {
    border-right: 1px solid var(--border-light);
}

.sidebar-right {
    border-left: 1px solid var(--border-light);
}


/* ============================================== */
/* SIDEBAR - Section Styles                      */
/* ============================================== */

.sidebar-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-header {
    padding: 20px 20px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-indicator {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
}

.indicator-blue {
    border-radius: 50%;
    background: var(--gradient-blue);
    box-shadow: 0 0 12px rgba(99, 179, 237, 0.5);
}

.indicator-gray {
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.3);
}

.indicator-orange {
    border-radius: 2px;
    background: var(--gradient-orange);
}

.indicator-green {
    border-radius: 50%;
    background: rgba(72, 187, 120, 0.8);
}

.indicator-purple {
    border-radius: 2px;
    background: var(--gradient-primary);
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.section-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
}


/* ============================================== */
/* LEFT SIDEBAR - Relevant Chats                 */
/* ============================================== */

.relevant-chats-section {
    flex: 0 0 45%;
    border-bottom: 1px solid var(--border-light);
}

.relevant-chat-item {
    padding: 14px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 8px;
    cursor: pointer;
    border: 1px solid rgba(99, 179, 237, 0.15);
    background: rgba(99, 179, 237, 0.03);
    transition: all var(--transition-normal);
    animation: fadeIn 0.4s ease both;
}

.relevant-chat-item:hover {
    border-color: rgba(99, 179, 237, 0.4);
    background: rgba(99, 179, 237, 0.05);
}

.relevant-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.relevant-chat-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.similarity-badge {
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--accent-blue);
    background: rgba(99, 179, 237, 0.15);
    padding: 3px 7px;
    border-radius: var(--border-radius-sm);
}

.relevant-chat-preview {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}


/* ============================================== */
/* LEFT SIDEBAR - Recent Chats                   */
/* ============================================== */

.recent-chats-section {
    flex: 1;
}

.recent-chats-section .section-header {
    justify-content: flex-start;
}

.btn-new-chat {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-muted);
    transition: all var(--transition-normal);
}

.btn-new-chat:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
}

.recent-chats-section .section-content {
    padding: 0 8px 12px;
}

.recent-chat-item {
    padding: 12px 14px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeIn 0.3s ease both;
}

.recent-chat-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.unread-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-purple);
    flex-shrink: 0;
}

.recent-chat-title {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-chat-item.unread .recent-chat-title {
    font-weight: 500;
    color: var(--text-primary);
}

.recent-chat-date {
    font-size: 11px;
    color: var(--text-hint);
    flex-shrink: 0;
}


/* ============================================== */
/* MAIN CHAT AREA                                */
/* ============================================== */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.ambient-glow {
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.08) 0%, transparent 70%);
    pointer-events: none;
}


/* ============================================== */
/* CHAT HEADER                                   */
/* ============================================== */

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 10;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.assistant-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.assistant-name {
    font-size: 15px;
    font-weight: 600;
}

.assistant-status {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    align-items: center;
}

.status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
    margin-right: 6px;
    animation: pulse 2s ease infinite;
}

.btn-settings {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-muted);
}


/* ============================================== */
/* MESSAGES                                      */
/* ============================================== */

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    animation: fadeIn 0.3s ease both;
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 16px 20px;
    line-height: 1.6;
}

.message.user .message-bubble {
    border-radius: 20px 20px 6px 20px;
    background: var(--gradient-primary);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.25);
    color: #fff;
}

.message.assistant .message-bubble {
    border-radius: 20px 20px 20px 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    color: rgba(255, 255, 255, 0.85);
}

.message-text {
    font-size: 14px;
}

.message-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.sources-label {
    font-size: 10px;
    color: var(--text-muted);
    margin-right: 4px;
}

.source-tag {
    font-size: 10px;
    background: rgba(99, 179, 237, 0.15);
    color: var(--accent-blue);
    padding: 4px 10px;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-mono);
}


/* ============================================== */
/* INPUT AREA                                    */
/* ============================================== */

.input-area {
    padding: 20px 24px 24px;
    background: linear-gradient(to top, rgba(10, 10, 15, 0.95) 0%, transparent 100%);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-medium);
    border-radius: var(--border-radius-xl);
    padding: 8px 8px 8px 20px;
    align-items: flex-end;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    transition: border-color var(--transition-normal);
}

.input-wrapper:focus-within {
    border-color: var(--border-hover);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    padding: 8px 0;
    max-height: 120px;
}

#message-input::placeholder {
    color: var(--text-muted);
}

.btn-send {
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--border-radius-lg);
    padding: 12px 20px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.02);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.send-arrow {
    font-size: 16px;
}

.input-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-hint);
    margin-top: 12px;
}


/* ============================================== */
/* RIGHT SIDEBAR - Files Section                 */
/* ============================================== */

.files-section {
    flex: 1 1 45%;
    border-bottom: 1px solid var(--border-light);
    min-height: 0;
}

.files-section .section-header {
    padding-bottom: 12px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 0 16px 12px;
}

.search-icon {
    font-size: 12px;
    opacity: 0.4;
}

#file-search {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 12px;
    color: var(--text-primary);
}

#file-search::placeholder {
    color: var(--text-muted);
}

.search-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    padding: 0;
}


/* ============================================== */
/* RIGHT SIDEBAR - File Tree                     */
/* ============================================== */

.file-tree {
    padding: 0 8px 12px;
}

.file-tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 12px;
}

.file-tree-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.file-tree-item.folder {
    color: rgba(255, 255, 255, 0.8);
}

.file-tree-item.file {
    color: var(--text-muted);
}

.folder-arrow {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform var(--transition-normal);
}

.folder-arrow.expanded {
    transform: rotate(90deg);
}

.file-tree-icon {
    flex-shrink: 0;
}

.file-tree-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-count {
    font-size: 10px;
    color: var(--text-hint);
    font-family: var(--font-mono);
}

.folder-children {
    display: none;
}

.folder-children.expanded {
    display: block;
}


/* ============================================== */
/* RIGHT SIDEBAR - Recent Files                  */
/* ============================================== */

.recent-files-section {
    flex: 0 0 30%;
    border-bottom: 1px solid var(--border-light);
}

.recent-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    margin-bottom: 4px;
    animation: fadeIn 0.3s ease both;
}

.recent-file-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-hover);
}

.recent-file-icon {
    font-size: 14px;
}

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

.recent-file-name {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-file-time {
    font-size: 10px;
    color: var(--text-hint);
    margin-top: 2px;
}


/* ============================================== */
/* RIGHT SIDEBAR - Upload Section                */
/* ============================================== */

.upload-section {
    flex: 0 0 25%;
    padding: 16px;
    min-height: 120px;
}

.upload-section .section-header {
    padding: 0 0 12px 0;
}

.drop-zone {
    flex: 1;
    border: 2px dashed var(--border-medium);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: all var(--transition-normal);
    cursor: pointer;
    min-height: 100px;
}

.drop-zone:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.03);
}

.drop-zone.drag-over {
    border-color: rgba(102, 126, 234, 0.6);
    background: rgba(102, 126, 234, 0.1);
}

.drop-zone-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-normal);
}

.drop-zone.drag-over .drop-zone-icon {
    background: var(--gradient-primary);
    transform: scale(1.1);
}

.drop-zone-text {
    font-size: 12px;
    color: var(--text-muted);
    transition: color var(--transition-normal);
}

.drop-zone.drag-over .drop-zone-text {
    color: rgba(102, 126, 234, 0.9);
}

.drop-zone-hint {
    font-size: 10px;
    color: var(--text-hint);
}

.browse-link {
    color: var(--accent-purple);
    cursor: pointer;
    text-decoration: underline;
}
