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

:root {
    --bg-light: #f5f5f5;
    --bg-dark: #1a1a1a;
    --text-light: #333;
    --text-dark: #eee;
    --primary: #3498db;
    --primary-dark: #2980b9;
    --success: #2ecc71;
    --error: #e74c3c;
    --warning: #f39c12;
    --border-radius: 8px;
    --box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-light);
    background-color: var(--bg-light);
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

header h1 {
    color: var(--primary);
}

.theme-toggle {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.theme-toggle:hover {
    background: var(--primary-dark);
}

.main-content {
    display: grid;
    gap: 25px;
}

.upload-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.upload-zone {
    border: 2px dashed var(--primary);
    border-radius: var(--border-radius);
    padding: 30px;
    text-align: center;
    background-color: rgba(52, 152, 219, 0.05);
    transition: all 0.3s;
}

.upload-zone.dragover {
    border-color: var(--success);
    background-color: rgba(46, 204, 113, 0.1);
}

.upload-zone p {
    margin-bottom: 15px;
    color: var(--text-light);
}

.browse-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}

.browse-btn:hover {
    background: var(--primary-dark);
}

.image-preview {
    text-align: center;
}

#previewImg {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.ocr-section, .editor-section, .preview-section, .action-section {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

body.dark-mode .ocr-section,
body.dark-mode .editor-section,
body.dark-mode .preview-section,
body.dark-mode .action-section {
    background: #2d2d2d;
}

.status-bar {
    padding: 12px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    font-weight: 500;
    transition: background 0.3s, color 0.3s;
}

.status-bar.info {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.status-bar.processing {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}
.status-bar.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.status-bar.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.editor-section label,
.preview-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

#ocrTextarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    background: #fafafa;
}

body.dark-mode #ocrTextarea {
    background: #3a3a3a;
    border-color: #555;
    color: #eee;
}

.preview-section {
    overflow-x: auto;
}

#previewTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: white;
}

body.dark-mode #previewTable {
    background: #2d2d2d;
}

#previewTable th,
#previewTable td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
    font-size: 13px;
}

body.dark-mode #previewTable th,
body.dark-mode #previewTable td {
    border-color: #555;
}

#previewTable th {
    background: #f8f9fa;
    font-weight: 600;
    text-transform: capitalize;
    position: sticky;
    top: 0;
    z-index: 10;
}

body.dark-mode #previewTable th {
    background: #3a3a3a;
}

#previewTable tr:nth-child(even) {
    background: #f2f2f2;
}

body.dark-mode #previewTable tr:nth-child(even) {
    background: #343434;
}

.preview-table-cell.edited {
    background: #fff3cd !important;
}

.preview-table-cell.empty {
    background: #f8d7da !important;
}

.action-section {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

body.dark-mode .action-section {
    border-top-color: #444;
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    margin: 0 10px;
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.primary-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background 0.3s;
}

.secondary-btn:hover {
    background: #7f8c8d;
}

/* Responsive design */
@media (max-width: 768px) {
    .upload-section {
        grid-template-columns: 1fr;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    #previewTable th,
    #previewTable td {
        padding: 6px 8px;
        font-size: 11px;
    }

    .primary-btn {
        width: 100%;
        margin: 10px 0;
    }

    .action-section {
        flex-direction: column;
    }
}