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

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --accent: #f093fb;
    --bg-main: #f7f9fc;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1f36;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-light: #a0aec0;
    --border: #e2e8f0;
    --success: #48bb78;
    --danger: #f56565;
    --warning: #ed8936;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

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

/* ===== SIDEBAR ===== */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.logo-section {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-icon {
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    font-weight: 500;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.nav-icon {
    font-size: 1.5rem;
}

.sidebar-footer {
    padding: 1.5rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.stat-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.1); }
}

.btn-reset {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(245, 101, 101, 0.1);
    border: 1px solid rgba(245, 101, 101, 0.3);
    border-radius: 10px;
    color: #fc8181;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-reset:hover {
    background: rgba(245, 101, 101, 0.2);
    border-color: rgba(245, 101, 101, 0.5);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: 280px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: white;
    padding: 1.5rem 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.breadcrumb-item {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-main);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

/* ===== VIEW CONTAINERS ===== */
.view-container {
    display: none;
    padding: 2.5rem;
    flex: 1;
}

.view-container.active {
    display: block;
}

.view-header {
    margin-bottom: 2rem;
}

.view-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.view-description {
    font-size: 1.05rem;
    color: var(--text-secondary);
}

.content-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
}

/* ===== UPLOAD AREA ===== */
.upload-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.drop-zone {
    border: 3px dashed var(--border);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-main);
}

.drop-zone:hover {
    border-color: var(--primary);
    background: #f7faff;
}

.drop-zone-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.drop-zone-title {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.drop-zone-desc {
    color: var(--text-secondary);
    font-size: 1rem;
}

.file-info {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.file-icon {
    font-size: 2rem;
}

.file-name-display {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
}

.file-size {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-large {
    padding: 1.25rem 2rem;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.btn-arrow {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.btn-primary:hover .btn-arrow {
    transform: translateX(4px);
}

/* ===== WEB FORM ===== */
.web-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
}

.input-field {
    width: 100%;
    padding: 1.25rem 1.25rem 1.25rem 3.5rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

/* ===== CHAT CONTAINER ===== */
.chat-container {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    height: 600px;
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-align: center;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.message {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    animation: slideIn 0.3s ease;
}

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

.message-bubble {
    max-width: 70%;
    padding: 1.25rem 1.5rem;
    border-radius: 16px;
    line-height: 1.6;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: var(--bg-main);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-sources {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.875rem;
}

.source-item {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 0.85rem;
}

.source-item strong {
    display: block;
    margin-bottom: 0.25rem;
}

.chat-input-area {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.chat-input-wrapper {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.btn-send {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* ===== SUMMARY FORM ===== */
.summary-form {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-label {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.range-slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    outline: none;
    -webkit-appearance: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.range-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    border: none;
}

.slider-value {
    min-width: 100px;
    padding: 0.75rem 1.25rem;
    background: var(--bg-main);
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    color: var(--primary);
}

/* ===== RESULT MESSAGES ===== */
.result-message {
    margin-top: 1.5rem;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    display: none;
    animation: slideIn 0.3s ease;
}

.result-message.show {
    display: block;
}

.result-message.success {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    color: #22543d;
}

.result-message.error {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    color: #742a2a;
}

.result-message.info {
    background: #ebf8ff;
    border: 1px solid #90cdf4;
    color: #2c5282;
}

.summary-output h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.summary-output p {
    line-height: 1.8;
    margin-bottom: 1rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }

    .main-content {
        margin-left: 240px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    .main-content {
        margin-left: 0;
    }

    .topbar {
        padding: 1rem 1.5rem;
    }

    .view-container {
        padding: 1.5rem;
    }

    .content-card {
        padding: 1.5rem;
    }

    .message-bubble {
        max-width: 85%;
    }
}

/* ===== LOADING STATE ===== */
.loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
}

/* ===== Toasts ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 9999;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    min-width: 240px;
    max-width: 360px;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    color: white;
    font-size: 0.9rem;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--primary); }

/* ===== Drag highlight ===== */
.drop-zone.dragging {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.06);
}

/* ===== Markdown ===== */
.markdown-body { line-height: 1.6; }
.markdown-body p { margin: 0 0 0.6em 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin: 0.8em 0 0.4em;
    font-weight: 600;
}
.markdown-body ul, .markdown-body ol { margin: 0 0 0.6em 1.4em; }
.markdown-body code {
    background: rgba(0,0,0,0.06);
    padding: 0.1em 0.35em;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
}
.markdown-body pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.9em 1em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0 0 0.8em;
}
.markdown-body pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}
.markdown-body blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 0.8em;
    color: var(--text-secondary);
    margin: 0 0 0.6em;
}
.summary-sources {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-secondary);
}
