:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    --success-color: #10b981;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(to right, #6366f1, #8b5cf6);
    background-clip: text;
    /* Standard property */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.1rem;
    color: #6b7280;
    margin-top: 0.5rem;
}

/* Upload Section */
.upload-area {
    background: var(--card-bg);
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: #eef2ff;
}

.upload-icon {
    font-size: 3rem;
    color: #9ca3af;
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.2rem;
    font-weight: 500;
    color: #4b5563;
}

#fileInput {
    display: none;
}

/* Workspace Section - Sidebar Layout */
.workspace {
    display: none;
    /* Hidden initially, flex when active */
    flex-direction: row;
    /* Horizontal Layout */
    align-items: flex-start;
    gap: 2rem;
    animation: fadeIn 0.5s ease;
}

.sidebar {
    width: 320px;
    flex-shrink: 0;
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    /* Sticky Sidebar */
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;

    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Cleanup old Toolbar style if not used, or keep for legacy components */
.toolbar {
    display: none;
}


.btn {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 1rem;
}

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

.btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #eff6ff;
    color: var(--primary-color);
}

.btn-secondary:hover {
    background-color: #dbeafe;
}

/* Canvas Area */
.canvas-container {
    flex-grow: 1;
    /* Take remaining space */
    position: relative;
    background: #374151;
    /* Dark background for contrast */
    padding: 2rem;
    border-radius: 1rem;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 80vh;
    /* Taller canvas */
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.2);
}

#previewContainer {
    position: relative;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    cursor: crosshair;
}

#pdfImage {
    display: block;
    max-width: 100%;
    height: auto;
    pointer-events: none;
    /* Let events pass to overlay */
}

#selectionOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: all;
}

/* Selection Box Style */
.selection-box {
    border: 2px solid #ef4444;
    /* Default Red for Target */
    background-color: rgba(239, 68, 68, 0.2);
    position: absolute;
}

.selection-box.patch {
    border: 2px solid #10b981;
    /* Green for Source */
    background-color: rgba(16, 185, 129, 0.2);
}

.mode-switch {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.mode-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Results */
.result-area {
    display: none;
    text-align: center;
    padding: 2rem;
}

.success-message {
    color: var(--success-color);
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.info-text {
    color: #e5e7eb;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.9rem;
}