/* ═══════════════════════════════════════════════════════════════
   DocuMind — Light Professional Theme
   Clean, beautiful, construction-industry appropriate
   ═══════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ──────────────────────────────────────────── */
:root {
    /* Colors */
    --color-primary:       #2563EB;
    --color-primary-hover: #1D4ED8;
    --color-primary-light: #EFF6FF;
    --color-primary-50:    #DBEAFE;

    --color-bg:            #F8FAFC;
    --color-surface:       #FFFFFF;
    --color-sidebar:       #FFFFFF;
    --color-border:        #E2E8F0;
    --color-border-light:  #F1F5F9;

    --color-text:          #1E293B;
    --color-text-secondary:#64748B;
    --color-text-muted:    #94A3B8;

    --color-success:       #10B981;
    --color-success-bg:    #ECFDF5;
    --color-warning:       #F59E0B;
    --color-error:         #EF4444;
    --color-error-bg:      #FEF2F2;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs:   0.75rem;
    --font-size-sm:   0.8125rem;
    --font-size-base: 0.875rem;
    --font-size-md:   1rem;
    --font-size-lg:   1.125rem;
    --font-size-xl:   1.25rem;
    --font-size-2xl:  1.5rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;

    /* Layout */
    --sidebar-width: 320px;
    --header-height: 56px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* ─── App Layout ─────────────────────────────────────────────── */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 20;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: var(--space-5) var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--color-border-light);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--color-primary), #7C3AED);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.logo-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.logo-subtitle {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: 400;
    margin-top: -2px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-5);
}

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}
.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

/* ─── Section Titles ─────────────────────────────────────────── */
.section-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.doc-count {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-size: 0.6875rem;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
    margin-left: auto;
}

/* ─── Upload Dropzone ────────────────────────────────────────── */
.upload-section {
    margin-bottom: var(--space-6);
}

.upload-dropzone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-6) var(--space-4);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: var(--color-bg);
}

.upload-dropzone:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.upload-dropzone.dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-50);
    border-style: solid;
    transform: scale(1.01);
}

.dropzone-content {
    pointer-events: none;
}

.dropzone-icon {
    color: var(--color-text-muted);
    margin-bottom: var(--space-2);
    transition: color var(--transition-normal);
}

.upload-dropzone:hover .dropzone-icon {
    color: var(--color-primary);
}

.dropzone-text {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
}

.dropzone-subtext {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-bottom: var(--space-2);
}

.dropzone-formats {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    background: var(--color-surface);
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    border: 1px solid var(--color-border);
}

/* ─── Upload Progress ────────────────────────────────────────── */
.upload-progress {
    margin-top: var(--space-3);
}

.progress-bar {
    height: 4px;
    background: var(--color-border-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #7C3AED);
    border-radius: 4px;
    width: 0%;
    transition: width var(--transition-normal);
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.progress-text {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin-top: var(--space-2);
    text-align: center;
}

/* ─── Documents List ─────────────────────────────────────────── */
.documents-section {
    margin-top: var(--space-2);
}

.documents-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.empty-docs {
    text-align: center;
    padding: var(--space-6) var(--space-4);
    color: var(--color-text-muted);
}

.empty-docs p {
    font-size: var(--font-size-sm);
    margin-top: var(--space-2);
}

.empty-hint {
    font-size: var(--font-size-xs) !important;
    margin-top: var(--space-1) !important;
}

.doc-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-light);
    background: var(--color-bg);
    transition: all var(--transition-fast);
    animation: slideIn var(--transition-normal) ease-out;
}

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

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

.doc-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.doc-icon.pdf  { background: #FEE2E2; color: #DC2626; }
.doc-icon.docx { background: #DBEAFE; color: #2563EB; }
.doc-icon.txt  { background: #E2E8F0; color: #475569; }

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

.doc-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.doc-delete {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    opacity: 0;
}

.doc-item:hover .doc-delete {
    opacity: 1;
}

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

/* ─── Sidebar Footer ─────────────────────────────────────────── */
.sidebar-footer {
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--color-border-light);
}

.stats {
    display: flex;
    gap: var(--space-4);
}

.stat-item {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

/* ─── Mobile Toggle ──────────────────────────────────────────── */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 30;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

/* ─── Chat Area ──────────────────────────────────────────────── */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.chat-header {
    height: var(--header-height);
    padding: 0 var(--space-6);
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    background: var(--color-surface);
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.chat-header-info h2 {
    font-size: var(--font-size-md);
    font-weight: 600;
}

.chat-status {
    font-size: var(--font-size-xs);
    color: var(--color-success);
    background: var(--color-success-bg);
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 500;
}

.new-chat-btn {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--color-primary-light);
    color: var(--color-primary);
    border: 1px solid var(--color-primary-50);
    border-radius: 8px;
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.new-chat-btn:hover {
    background: var(--color-primary-50);
    border-color: var(--color-primary);
}

.chat-status.thinking {
    color: var(--color-warning);
    background: #FEF3C7;
    animation: statusPulse 1.5s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ─── Messages ───────────────────────────────────────────────── */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}
.messages-container::-webkit-scrollbar-track {
    background: transparent;
}
.messages-container::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 6px;
}

/* ─── Welcome Screen ─────────────────────────────────────────── */
.welcome-message {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    max-width: 480px;
    margin: auto;
    animation: fadeInUp 0.5s ease-out;
}

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

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary-50));
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-5);
    color: var(--color-primary);
}

.welcome-message h2 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-2);
    letter-spacing: -0.02em;
}

.welcome-message > p {
    font-size: var(--font-size-base);
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: var(--space-6);
}

.welcome-steps {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    text-align: left;
}

.step {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

.step:hover {
    border-color: var(--color-border);
    box-shadow: var(--shadow-xs);
}

.step-number {
    width: 24px;
    height: 24px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ─── Message Bubbles ────────────────────────────────────────── */
.message {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    animation: messageIn 0.3s ease-out;
    max-width: 800px;
}

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

.message.user {
    flex-direction: row-reverse;
    margin-left: auto;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.message.user .message-avatar {
    background: var(--color-primary);
    color: white;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary-50));
    color: var(--color-primary);
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-bubble {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    line-height: 1.7;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--color-primary);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.message.assistant .message-bubble {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-bottom-left-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
}

.message-bubble p {
    margin-bottom: var(--space-2);
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul,
.message-bubble ol {
    margin: var(--space-2) 0;
    padding-left: var(--space-5);
}

.message-bubble li {
    margin-bottom: var(--space-1);
}

.message-bubble strong {
    font-weight: 600;
}

.message-bubble code {
    background: var(--color-bg);
    padding: 2px 6px;
    margin: 0 2px;
    border-radius: 3px;
    font-size: 0.8125rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ─── Source Citations ───────────────────────────────────────── */
.message-sources {
    margin-top: var(--space-3);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.source-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 3px 10px;
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    border: 1px solid var(--color-primary-50);
    transition: all var(--transition-fast);
}

.source-tag:hover {
    background: var(--color-primary-50);
}

.source-tag svg {
    flex-shrink: 0;
}

.source-relevance {
    color: var(--color-text-muted);
    font-weight: 400;
    margin-left: 2px;
}

/* ─── Thinking Indicator ─────────────────────────────────────── */
.thinking-indicator {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    animation: messageIn 0.3s ease-out;
}

.thinking-dots {
    display: flex;
    gap: 4px;
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-sm);
}

.thinking-dot {
    width: 6px;
    height: 6px;
    background: var(--color-text-muted);
    border-radius: 50%;
    animation: thinkingBounce 1.4s ease-in-out infinite;
}

.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ─── Chat Input ─────────────────────────────────────────────── */
.chat-input-area {
    padding: var(--space-4) var(--space-6) var(--space-5);
    background: var(--color-bg);
    border-top: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.chat-form {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.input-wrapper:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), var(--shadow-sm);
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background: transparent;
    line-height: 1.6;
    max-height: 120px;
    padding: var(--space-2) 0;
}

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

.send-button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.send-button:hover:not(:disabled) {
    background: var(--color-primary-hover);
    transform: scale(1.05);
}

.send-button:disabled {
    background: var(--color-border);
    cursor: not-allowed;
}

.input-hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-align: center;
    margin-top: var(--space-2);
}

/* ─── Toast Notifications ────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease-out;
    max-width: 380px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.toast.success {
    background: var(--color-success);
    color: white;
}

.toast.error {
    background: var(--color-error);
    color: white;
}

.toast.info {
    background: var(--color-primary);
    color: white;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(24px);
    }
}

/* ─── Error Message ──────────────────────────────────────────── */
.message-error {
    color: var(--color-error);
    background: var(--color-error-bg);
    border-color: #FECACA;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .chat-header {
        padding-left: 56px;
    }

    .chat-input-area {
        padding: var(--space-3) var(--space-4);
    }

    .messages-container {
        padding: var(--space-4);
    }
}

@media (max-width: 480px) {
    :root {
        --sidebar-width: 100vw;
    }

    .welcome-message {
        padding: var(--space-6) var(--space-2);
    }
}
