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

body {
    font-family: 'Segoe UI', sans-serif;
    background: #0a0a14;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

/* layout */
.app-layout {
    display: flex;
    height: 100vh;
}

/* sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: #12121f;
    border-right: 1px solid #1e1e35;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    gap: 24px;
    overflow-y: auto;
}

.sidebar-header {
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 6px;
}

.logo-icon { font-size: 1.6rem; }

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: #a78bfa;
    letter-spacing: -0.5px;
}

.logo-sub {
    font-size: 0.78rem;
    color: #555580;
}

/* upload area */
.upload-area {
    background: #0f0f1e;
    border: 2px dashed #2d2d55;
    border-radius: 14px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-area.drag-over {
    border-color: #7c3aed;
    background: #1a1030;
}

.upload-icon { font-size: 2rem; margin-bottom: 8px; }

.upload-label {
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 4px;
}

.upload-or {
    font-size: 0.75rem;
    color: #555;
    margin-bottom: 10px;
}

.upload-btn {
    display: inline-block;
    background: #7c3aed;
    color: white;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.upload-btn:hover { background: #6d28d9; }

#uploadStatus {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #a78bfa;
    min-height: 18px;
}

/* document list */
.doc-list-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.section-label {
    font-size: 0.75rem;
    color: #555580;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

#docSelect {
    width: 100%;
    flex: 1;
    min-height: 120px;
    background: #0f0f1e;
    border: 1px solid #1e1e35;
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 0.85rem;
    padding: 8px;
    cursor: pointer;
    outline: none;
}

#docSelect option {
    padding: 8px;
    border-radius: 6px;
}

#docSelect option:checked {
    background: #7c3aed;
}

.clear-btn {
    background: transparent;
    border: 1px solid #2d2d55;
    color: #888;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: 0.2s;
    width: 100%;
}

.clear-btn:hover {
    background: #1e1e35;
    color: #e0e0e0;
}

/* chat area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 16px 28px;
    border-bottom: 1px solid #1e1e35;
    background: #0d0d1a;
}

.active-doc-name {
    font-size: 0.9rem;
    color: #7c6aad;
    font-style: italic;
}

/* chat box */
.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.welcome-msg {
    margin: auto;
    text-align: center;
    max-width: 360px;
    color: #555580;
}

.welcome-icon { font-size: 3rem; margin-bottom: 16px; }

.welcome-msg h2 {
    font-size: 1.3rem;
    color: #a78bfa;
    margin-bottom: 10px;
}

.welcome-msg p {
    font-size: 0.9rem;
    line-height: 1.6;
}

/* messages */
.message {
    padding: 13px 18px;
    border-radius: 14px;
    max-width: 72%;
    line-height: 1.6;
    font-size: 0.95rem;
    word-wrap: break-word;
    position: relative;
}

.user-message {
    background: #7c3aed;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-message {
    background: #1a1a30;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid #2a2a45;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: #555580;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: 0.2s;
    opacity: 0;
}

.ai-message:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: #2d2d55; color: #a78bfa; }

/* sources */
.sources {
    background: #0f0f20;
    border-left: 3px solid #7c3aed;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #8080a0;
    align-self: flex-start;
    max-width: 72%;
}

.sources strong {
    color: #a78bfa;
    display: block;
    margin-bottom: 6px;
}

.source-chunk {
    margin-top: 6px;
    padding: 6px 10px;
    background: #1a1a2e;
    border-radius: 6px;
    font-style: italic;
    line-height: 1.5;
}

/* loading spinner */
.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #a78bfa;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* input area */
.input-area {
    display: flex;
    gap: 10px;
    padding: 18px 28px;
    border-top: 1px solid #1e1e35;
    background: #0d0d1a;
}

#questionInput {
    flex: 1;
    padding: 13px 18px;
    border-radius: 10px;
    border: 1px solid #2d2d55;
    background: #12121f;
    color: #e0e0e0;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

#questionInput:focus {
    border-color: #7c3aed;
}

#askBtn {
    background: #7c3aed;
    color: white;
    border: none;
    padding: 13px 22px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

#askBtn:hover { background: #6d28d9; }

#askBtn:disabled {
    background: #3a2a5e;
    cursor: not-allowed;
}

/* scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2d2d55; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #7c3aed; }
