/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
    transition: all 0.3s ease;
}

/* Dark Mode */
body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e5e7eb;
}

body.dark-mode .header {
    background: rgba(31, 41, 55, 0.95);
    border-bottom: 1px solid rgba(75, 85, 99, 0.3);
}

body.dark-mode .upload-area,
body.dark-mode .viewer-panel,
body.dark-mode .action-bar,
body.dark-mode .toggle-container {
    background: rgba(31, 41, 55, 0.95);
    border-color: rgba(75, 85, 99, 0.3);
}

body.dark-mode .upload-area:hover {
    background: rgba(31, 41, 55, 1);
}

body.dark-mode .panel-header {
    background: linear-gradient(135deg, #374151, #4b5563);
}

body.dark-mode .app-title {
    color: #60a5fa;
}

body.dark-mode .app-subtitle,
body.dark-mode .upload-area p,
body.dark-mode .file-name {
    color: #9ca3af;
}

body.dark-mode .upload-area h3,
body.dark-mode .panel-header h3 {
    color: #f9fafb;
}

body.dark-mode .markdown-content h1,
body.dark-mode .markdown-content h2,
body.dark-mode .markdown-content h3,
body.dark-mode .markdown-content h4,
body.dark-mode .markdown-content h5,
body.dark-mode .markdown-content h6 {
    color: #f9fafb;
}

body.dark-mode .markdown-content p {
    color: #d1d5db;
}

body.dark-mode .markdown-content pre,
body.dark-mode .markdown-content code {
    background: #374151;
}

body.dark-mode .status-bar {
    background: rgba(31, 41, 55, 0.95);
    border-top: 1px solid rgba(75, 85, 99, 0.3);
}

body.dark-mode .status-text {
    color: #d1d5db;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left,
.header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.header-center {
    flex: 1;
    text-align: center;
}

.sidebar-toggle,
.theme-toggle {
    background: transparent;
    border: 2px solid rgba(79, 70, 229, 0.2);
    color: #4f46e5;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.sidebar-toggle:hover,
.theme-toggle:hover {
    background: rgba(79, 70, 229, 0.1);
    border-color: rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

.app-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #4f46e5;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.app-title i {
    font-size: 2.2rem;
}

.app-subtitle {
    font-size: 1.1rem;
    color: #6b7280;
    font-weight: 400;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 350px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
}

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

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
}

.sidebar-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-close {
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sidebar-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #374151;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

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

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.empty-history {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.empty-history i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.history-item {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.history-item:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.history-item.active {
    border-color: #4f46e5;
    background: rgba(79, 70, 229, 0.05);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.history-item-name {
    font-weight: 500;
    color: #1f2937;
    font-size: 0.9rem;
    flex: 1;
    margin-right: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-item-status.processing {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.history-item-status.completed {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.history-item-status.failed {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.history-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #6b7280;
}

.history-item-time {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.history-item-actions {
    display: flex;
    gap: 0.5rem;
}

.history-action-btn {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #6b7280;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #374151;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Dark mode sidebar */
body.dark-mode .sidebar {
    background: rgba(31, 41, 55, 0.98);
    border-right: 1px solid rgba(75, 85, 99, 0.3);
}

body.dark-mode .sidebar-header {
    background: linear-gradient(135deg, #374151, #4b5563);
    border-bottom: 1px solid rgba(75, 85, 99, 0.3);
}

body.dark-mode .sidebar-header h3 {
    color: #f9fafb;
}

body.dark-mode .sidebar-close {
    color: #9ca3af;
}

body.dark-mode .sidebar-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f3f4f6;
}

body.dark-mode .sidebar-footer {
    border-top: 1px solid rgba(75, 85, 99, 0.3);
}

body.dark-mode .history-item {
    background: rgba(55, 65, 81, 0.8);
    border: 1px solid rgba(75, 85, 99, 0.3);
}

body.dark-mode .history-item:hover {
    background: rgba(55, 65, 81, 1);
}

body.dark-mode .history-item.active {
    border-color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
}

body.dark-mode .history-item-name {
    color: #f9fafb;
}

body.dark-mode .history-item-meta {
    color: #9ca3af;
}

body.dark-mode .history-action-btn {
    border-color: rgba(75, 85, 99, 0.5);
    color: #9ca3af;
}

body.dark-mode .history-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f3f4f6;
}

body.dark-mode .theme-toggle,
body.dark-mode .sidebar-toggle {
    border-color: rgba(96, 165, 250, 0.3);
    color: #60a5fa;
}

body.dark-mode .theme-toggle:hover,
body.dark-mode .sidebar-toggle:hover {
    background: rgba(96, 165, 250, 0.1);
    border-color: rgba(96, 165, 250, 0.5);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Upload Section */
.upload-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    gap: 1.5rem;
}

/* Toggle Container */
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: fit-content;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.toggle-label {
    font-size: 0.9rem;
    color: #4b5563;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.toggle-option label {
    font-size: 0.9rem;
    color: #4b5563;
    font-weight: 500;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e5e7eb;
    transition: .4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #4f46e5;
}

input:focus + .toggle-slider {
    box-shadow: 0 0 1px #4f46e5;
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Dark mode toggle styles */
body.dark-mode .toggle-option label,
body.dark-mode .toggle-label {
    color: #9ca3af;
}

body.dark-mode .toggle-slider {
    background-color: #4b5563;
}

body.dark-mode input:checked + .toggle-slider {
    background-color: #60a5fa;
}

.upload-area {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px dashed #d1d5db;
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    min-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.upload-area:hover {
    border-color: #4f46e5;
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.15);
}

.upload-area.dragover {
    border-color: #4f46e5;
    background: rgba(79, 70, 229, 0.05);
}

.upload-icon {
    font-size: 4rem;
    color: #4f46e5;
    margin-bottom: 1rem;
}

.upload-area h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.upload-area p {
    color: #6b7280;
    margin-bottom: 2rem;
    font-size: 1rem;
}

.upload-btn {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

/* Processing Section */
.processing-section {
    animation: fadeIn 0.5s ease-in-out;
}

.document-viewer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    height: 70vh;
}

.viewer-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.panel-header {
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.file-name {
    font-size: 0.875rem;
    color: #6b7280;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* PDF Viewer */
.pdf-viewer {
    height: 100%;
    overflow-y: auto;
    padding: 1rem;
}

.pdf-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
}

.pdf-placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Markdown Viewer */
.markdown-viewer {
    height: 100%;
    position: relative;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    border-radius: 2px;
    animation: progress 2s ease-in-out infinite;
}

.markdown-content {
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #1f2937;
}

.markdown-content h1 { font-size: 1.875rem; }
.markdown-content h2 { font-size: 1.5rem; }
.markdown-content h3 { font-size: 1.25rem; }

.markdown-content p {
    margin-bottom: 1rem;
    color: #374151;
}

.markdown-content pre {
    background: #f3f4f6;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}

.markdown-content code {
    background: #f3f4f6;
    padding: 0.125rem 0.25rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

.download-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

/* Terminal */
.terminal-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 300px;
    background: #1f2937;
    border-top: 1px solid #374151;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.terminal-container.open {
    transform: translateY(0);
}

.terminal-header {
    background: #111827;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #374151;
}

.terminal-title {
    color: #f9fafb;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.terminal-controls {
    display: flex;
    gap: 0.5rem;
}

.terminal-btn {
    background: transparent;
    border: 1px solid #374151;
    color: #9ca3af;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.terminal-btn:hover {
    background: #374151;
    color: #f9fafb;
}

.terminal-content {
    height: calc(100% - 60px);
    overflow-y: auto;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

.log-entry {
    margin-bottom: 0.5rem;
    color: #d1d5db;
}

.timestamp {
    color: #6b7280;
    margin-right: 0.5rem;
}

.log-message {
    color: #f9fafb;
}

.log-entry.error .log-message {
    color: #ef4444;
}

.log-entry.success .log-message {
    color: #10b981;
}

.log-entry.warning .log-message {
    color: #f59e0b;
}

/* Status Bar */
.status-bar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0.75rem 2rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.status-bar.hidden {
    transform: translateY(100%);
}

.status-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-text {
    font-size: 0.875rem;
    color: #374151;
    font-weight: 500;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
}

.status-indicator.processing {
    background: #f59e0b;
}

.status-indicator.error {
    background: #ef4444;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes progress {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0%); }
    100% { transform: translateX(100%); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .document-viewer {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .viewer-panel {
        height: 50vh;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .header {
        padding: 1rem;
    }
    
    .app-title {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    .upload-area {
        min-width: 300px;
        padding: 2rem;
    }
    
    .action-bar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .terminal-container {
        height: 250px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
