/* ========================================
   RAG Docs - Professional Light Theme
   Inspired by modern SaaS dashboards
   ======================================== */

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

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-50: rgba(79, 70, 229, 0.08);

    --bg-body: #f0f2f5;
    --bg-white: #ffffff;
    --bg-sidebar: #f8f9fb;
    --bg-hover: #f3f4f6;

    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --text-white: #ffffff;

    --border: #e5e7eb;
    --border-light: #f3f4f6;

    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --error: #ef4444;
    --error-bg: #fef2f2;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Top Navigation
   ======================================== */

.top-nav {
    height: 60px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    position: relative;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.nav-brand h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.nav-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.01em;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-body);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 500;
}

.nav-stat svg {
    color: var(--primary);
}

/* ========================================
   Layout
   ======================================== */

.layout {
    display: flex;
    height: calc(100vh - 60px);
}

/* ========================================
   Sidebar
   ======================================== */

.sidebar {
    width: 340px;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.sidebar-header h2 svg {
    color: var(--text-muted);
}

/* Drop Zone */
.drop-zone {
    margin: 16px 20px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background: var(--bg-body);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.drop-zone-icon {
    color: var(--text-muted);
    margin-bottom: 8px;
    transition: color 0.25s;
}

.drop-zone:hover .drop-zone-icon,
.drop-zone.dragover .drop-zone-icon {
    color: var(--primary);
}

.drop-zone-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.drop-zone-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.drop-zone .link {
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
}

.drop-zone .link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Document List */
.document-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.doc-item {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    position: relative;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.doc-item:hover {
    border-color: #d1d5db;
    box-shadow: var(--shadow-md);
}

.doc-item .doc-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    color: var(--primary);
    margin-bottom: 8px;
}

.doc-item .doc-name {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    word-break: break-all;
    padding-right: 24px;
    line-height: 1.4;
}

.doc-item .doc-status {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.doc-item .doc-status .badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.6rem;
    letter-spacing: 0.05em;
}

.badge.processing {
    background: var(--warning-bg);
    color: #b45309;
}

.badge.ready {
    background: var(--success-bg);
    color: #047857;
}

.badge.error {
    background: var(--error-bg);
    color: #b91c1c;
}

.doc-item .doc-pages {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.doc-item .progress-bar {
    height: 4px;
    background: var(--border-light);
    border-radius: 4px;
    margin-top: 10px;
    overflow: hidden;
}

.doc-item .progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.doc-item .delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: all 0.2s;
}

.doc-item .delete-btn:hover {
    color: var(--error);
    background: var(--error-bg);
}

/* ========================================
   Chat Panel
   ======================================== */

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
}

.chat-header {
    padding: 14px 24px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

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

.chat-header-left svg {
    color: var(--primary);
}

.chat-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.chat-header select {
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.chat-header select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 60px 40px;
    max-width: 420px;
    margin: auto;
}

.welcome-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: var(--primary-light);
    border-radius: 50%;
    color: var(--primary);
    margin-bottom: 20px;
}

.welcome-message h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

.welcome-message p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.7;
}

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

.message {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 0.87rem;
    line-height: 1.7;
    white-space: pre-wrap;
    box-shadow: var(--shadow-sm);
}

.message.system {
    background: var(--bg-white);
    color: var(--text-muted);
    align-self: center;
    text-align: center;
    font-size: 0.82rem;
    border: 1px solid var(--border);
    box-shadow: none;
    border-radius: 20px;
    padding: 10px 20px;
}

.message.user {
    background: var(--primary);
    color: var(--text-white);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.message.assistant {
    background: var(--bg-white);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-light);
}

.message .sources {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message .sources strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.message .sources .source-item {
    margin-top: 6px;
    padding: 5px 10px;
    background: var(--bg-body);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    display: inline-block;
    margin-right: 6px;
    margin-bottom: 4px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.message .sources .source-item:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.message.loading {
    background: var(--bg-white);
    color: var(--text-muted);
    align-self: flex-start;
    border: 1px solid var(--border-light);
}

.message.loading::after {
    content: "...";
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60% { content: "..."; }
    80%, 100% { content: ""; }
}

/* ========================================
   Chat Input
   ======================================== */

.chat-input {
    padding: 16px 24px 20px;
    background: var(--bg-body);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px;
    box-shadow: var(--shadow-md);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: var(--shadow-md), 0 0 0 3px var(--primary-50);
}

.chat-input input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
}

.chat-input input::placeholder {
    color: var(--text-muted);
}

.chat-input button {
    background: var(--primary);
    color: var(--text-white);
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.chat-input button:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.chat-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* ========================================
   Scrollbar Styling
   ======================================== */

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

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

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ========================================
   Empty State
   ======================================== */

.empty-docs {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.empty-docs svg {
    margin-bottom: 8px;
    opacity: 0.4;
}
