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

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #1e3a8a;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.header {
    background: rgba(30, 41, 59, 0.95);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    background: var(--primary-light);
    border-radius: 20px;
}

/* Modal */
.modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2.5rem;
    width: 90%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease-out;
}

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

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.tab-btn {
    flex: 1;
    padding: 0.875rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    position: relative;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.auth-tab {
    display: none;
}

.auth-tab.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.auth-tab h2 {
    margin-bottom: 1.75rem;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.625rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s;
    background: var(--bg-color);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--card-bg);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.form-group input:hover {
    border-color: #cbd5e1;
}

/* Buttons */
.btn {
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #2563eb 100%);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
}

.btn-secondary:hover {
    background: #475569;
    box-shadow: var(--shadow);
}

/* Sections */
.section {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2.5rem;
    margin: 2rem 0;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.3s;
}

.section:hover {
    box-shadow: var(--shadow-md);
}

.section h2 {
    margin-bottom: 1.75rem;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
}

.section-header h2 {
    margin-bottom: 0;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-color);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(59, 130, 246, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.upload-area:hover::before {
    opacity: 1;
}

.upload-area:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: scale(1.02);
}

.upload-content {
    position: relative;
    z-index: 1;
}

.upload-content svg {
    color: var(--primary-color);
    margin-bottom: 1.25rem;
    filter: drop-shadow(0 2px 4px rgba(37, 99, 235, 0.2));
}

.upload-content p {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Status Messages */
.status-message {
    margin-top: 1.25rem;
    padding: 1rem 1.25rem;
    border-radius: 10px;
    display: none;
    font-weight: 500;
    animation: slideDown 0.3s ease-out;
}

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

.status-message.success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
    display: block;
}

.status-message.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.1) 100%);
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
    display: block;
}

.error-message {
    margin-top: 1.25rem;
    padding: 1rem 1.25rem;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    border-radius: 10px;
    display: none;
    font-weight: 500;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.error-message.show {
    display: block;
    animation: slideDown 0.3s ease-out;
}

/* Documents Grid */
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.document-card {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.75rem;
    transition: all 0.3s;
    cursor: pointer;
}

.document-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
    border-color: var(--primary-color);
    background: var(--card-bg);
}

.document-card h3 {
    font-size: 1.0625rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    word-break: break-word;
    font-weight: 600;
    line-height: 1.4;
}

.document-card .meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.document-summary {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 0.75rem 0;
    line-height: 1.5;
    font-style: italic;
}

.document-card .file-type {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--primary-light);
    border-radius: 4px;
    color: var(--primary-color);
    font-weight: 500;
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 600px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-color);
    scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-color);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.message {
    margin-bottom: 1.25rem;
    padding: 1.125rem 1.25rem;
    border-radius: 12px;
    max-width: 75%;
    animation: fadeIn 0.3s ease-out;
    word-wrap: break-word;
    line-height: 1.6;
}

.message.message.user {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2563eb 100%);
    color: white;
    margin-left: auto;
    text-align: right;
    box-shadow: var(--shadow-sm);
}

.message.assistant {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.message-header {
    font-weight: 600;
    margin-bottom: 0.625rem;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.chat-input-container {
    display: flex;
    gap: 0.75rem;
    padding: 1.25rem;
    background: var(--card-bg);
    border-top: 2px solid var(--border-color);
}

.chat-input {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.2s;
    background: var(--bg-color);
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--card-bg);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

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

/* Loading */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(37, 99, 235, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}

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

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .section {
        padding: 1.75rem;
        margin: 1.5rem 0;
    }
    
    .documents-grid {
        grid-template-columns: 1fr;
    }
    
    .message {
        max-width: 85%;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .upload-area {
        padding: 3rem 1.5rem;
    }
    
    .chat-container {
        height: 500px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 2rem 1.5rem;
    }
    
    .section {
        padding: 1.5rem;
    }
}
