/**
 * Document OCR v2 - Premium Light Theme
 * =====================================
 * Minimalistic, clean, and professional design
 */

/* =============================================================================
   CSS Variables
   ============================================================================= */

:root {
    /* Colors */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --error: #ef4444;
    --error-light: #fee2e2;
    
    /* Neutrals */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    /* Borders */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Transitions */
    --transition: all 0.2s ease;
}

/* =============================================================================
   Reset & Base
   ============================================================================= */

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

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

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--white) 100%);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* =============================================================================
   App Container
   ============================================================================= */

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
}

/* =============================================================================
   Header
   ============================================================================= */

.header {
    margin-bottom: 32px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo {
    font-size: 28px;
    font-weight: 800;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 32px;
}

.version-tag {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 999px;
    margin-left: 4px;
}

.preview-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--warning) 0%, #fb923c 100%);
    color: var(--white);
    border-radius: 999px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.subtitle {
    font-size: 15px;
    color: var(--gray-500);
    font-weight: 400;
}

/* =============================================================================
   Sections
   ============================================================================= */

.section {
    animation: fadeIn 0.3s ease;
}

.hidden {
    display: none !important;
}

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

/* =============================================================================
   Upload Section
   ============================================================================= */

.upload-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 48px;
    max-width: 600px;
    margin: 60px auto;
}

.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--gray-50);
}

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

.upload-icon {
    color: var(--gray-400);
    margin-bottom: 16px;
    transition: var(--transition);
}

.upload-zone:hover .upload-icon {
    color: var(--primary);
    transform: translateY(-4px);
}

.upload-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.upload-subtitle {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.upload-formats {
    font-size: 12px;
    color: var(--gray-400);
    margin-bottom: 20px;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    background: var(--primary);
    color: var(--white);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.upload-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* =============================================================================
   Processing Section
   ============================================================================= */

.processing-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 64px;
    max-width: 400px;
    margin: 80px auto;
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 24px;
}

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

.processing-card h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.processing-card p {
    font-size: 14px;
    color: var(--gray-500);
}

/* =============================================================================
   Stats Bar
   ============================================================================= */

.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.stats-left {
    display: flex;
    gap: 24px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

/* =============================================================================
   Toolbar
   ============================================================================= */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.toggle-group {
    display: flex;
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 4px;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.toggle-btn:hover {
    color: var(--gray-800);
}

.toggle-btn.active {
    background: var(--white);
    color: var(--gray-900);
    box-shadow: var(--shadow-sm);
}

.toolbar-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: var(--white);
    color: var(--gray-700);
}

.action-btn:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.action-btn.save-btn {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.action-btn.save-btn:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.action-btn.export-btn {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
}

.action-btn.export-btn:hover {
    background: #059669;
    border-color: #059669;
}

/* =============================================================================
   Editor Container
   ============================================================================= */

.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    height: calc(100vh - 280px);
    min-height: 500px;
}

.panel {
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.panel-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-content {
    flex: 1;
    overflow: auto;
    padding: 0;
}

/* Image Panel */
.image-panel .panel-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: var(--gray-100);
}

.image-panel img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Content Panel */
.content-panel textarea {
    width: 100%;
    height: 100%;
    padding: 20px;
    border: none;
    resize: none;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
    font-size: 13px;
    line-height: 1.7;
    color: var(--gray-800);
    background: var(--white);
}

.content-panel textarea:focus {
    outline: none;
}

.content-panel textarea::placeholder {
    color: var(--gray-400);
}

/* Markdown Preview */
.preview {
    padding: 24px;
    line-height: 1.7;
    color: var(--gray-800);
}

.preview h1, .preview h2, .preview h3, .preview h4, .preview h5, .preview h6 {
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--gray-900);
}

.preview h1 { font-size: 24px; }
.preview h2 { font-size: 20px; }
.preview h3 { font-size: 18px; }

.preview p {
    margin-bottom: 16px;
}

.preview img {
    max-width: 100%;
    border-radius: var(--radius);
}

.preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.preview th, .preview td {
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    text-align: left;
}

.preview th {
    background: var(--gray-50);
    font-weight: 600;
}

.preview code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SF Mono', monospace;
}

.preview pre {
    background: var(--gray-900);
    color: var(--gray-100);
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 16px 0;
}

.preview pre code {
    background: transparent;
    padding: 0;
}

/* =============================================================================
   Toast
   ============================================================================= */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

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

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

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

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 1024px) {
    .editor-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .panel {
        height: 400px;
    }
}

@media (max-width: 640px) {
    .app-container {
        padding: 16px;
    }
    
    .upload-card {
        padding: 24px;
        margin: 32px auto;
    }
    
    .toolbar {
        flex-direction: column;
        gap: 12px;
    }
    
    .stats-bar {
        flex-direction: column;
        gap: 12px;
    }
    
    .stats-left {
        flex-wrap: wrap;
        gap: 16px;
    }
}