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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

.privacy-banner {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    text-align: center;
    padding: 14px 20px;
    font-weight: 700;
    font-size: 0.95em;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    letter-spacing: 0.3px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

.main-header {
    background: var(--bg-primary);
    padding: 30px 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section h1 {
    font-size: 2em;
    margin-bottom: 5px;
    color: var(--primary);
}

.logo-section p {
    color: var(--text-secondary);
    font-size: 0.95em;
}

.stats {
    display: flex;
    gap: 30px;
}

.stat-item {
    text-align: right;
}

.stat-label {
    display: block;
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.stat-value {
    display: block;
    font-size: 1.5em;
    font-weight: 700;
    color: var(--primary);
}

.main-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: calc(100vh - 250px);
}

.tools-sidebar {
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    padding: 30px 20px;
}

.tools-sidebar h2 {
    font-size: 1.2em;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.tools-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1em;
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
}

.tool-btn:hover {
    background: white;
    border-color: var(--primary);
    transform: translateX(5px);
    box-shadow: var(--shadow);
}

.tool-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-lg);
    transform: translateX(5px);
}

.tool-icon {
    font-size: 1.5em;
    min-width: 24px;
    text-align: center;
}

.privacy-info {
    margin-top: 40px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.privacy-info h3 {
    font-size: 0.95em;
    margin-bottom: 12px;
    color: var(--success);
}

.privacy-info ul {
    list-style: none;
    font-size: 0.85em;
    color: var(--text-secondary);
}

.privacy-info li {
    padding: 4px 0;
}

.workspace {
    padding: 40px;
    background: var(--bg-secondary);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.tool-panel {
    display: none;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.tool-panel.active {
    display: block;
}

.tool-panel h2 {
    font-size: 1.8em;
    margin-bottom: 30px;
    color: var(--text-primary);
    text-align: center;
}

.upload-zone {
    background: linear-gradient(135deg, #f8fafc, #ffffff);
    border: 4px dashed var(--border);
    border-radius: 16px;
    padding: 80px 40px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    margin: 0 auto;
    max-width: 800px;
}

.upload-zone::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.05) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.upload-zone:hover::before,
.upload-zone.drag-over::before {
    opacity: 1;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--primary);
    background: linear-gradient(135deg, #eff6ff, #ffffff);
    box-shadow: 0 8px 30px rgba(37, 99, 235, 0.15);
    transform: scale(1.01);
}

.upload-icon {
    font-size: 5em;
    margin-bottom: 25px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.upload-title {
    font-size: 1.6em;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.upload-subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 1.05em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 16px 40px;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), #1e40af);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
}

.btn-action {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    border: none;
    padding: 18px 50px;
    border-radius: 12px;
    font-size: 1.15em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 30px auto 0;
    display: block;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

.btn-action:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
}

.btn-action:disabled {
    background: var(--secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-small {
    background: white;
    color: var(--text-primary);
    border: 2px solid var(--border);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: var(--bg-primary);
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.files-list {
    margin-top: 30px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.cache-controls {
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #fef2f2, #ffffff);
    border-radius: 12px;
    border: 2px solid #fee2e2;
    text-align: center;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.cache-controls p {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 0.95em;
    font-weight: 500;
}

#clear-cache-btn {
    background: linear-gradient(135deg, var(--danger), #dc2626) !important;
    color: white !important;
    border-color: var(--danger) !important;
}

#clear-cache-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4) !important;
}

.file-item {
    background: white;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.file-item:hover {
    border-color: var(--primary);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 18px;
}

.file-icon {
    font-size: 2.5em;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.file-details h3 {
    font-size: 1.15em;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
}

.file-meta {
    font-size: 0.9em;
    color: var(--text-secondary);
    font-weight: 500;
}

.file-actions {
    display: flex;
    gap: 12px;
}

.file-remove {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    transition: all 0.2s;
}

.file-remove:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.tool-content {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin: 0 auto;
    max-width: 100%;
}

.file-selector {
    margin-bottom: 30px;
}

.file-selector label {
    display: block;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-size: 1.05em;
}

.file-select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1.05em;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.file-select:hover {
    border-color: var(--primary);
}

.file-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.split-options,
.compress-options,
.ocr-options {
    margin: 25px auto;
    max-width: 700px;
}

.option-group {
    margin-bottom: 20px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    border: 2px solid var(--border);
    box-shadow: var(--shadow);
}

.option-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
}

.option-group input[type="number"],
.option-group input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95em;
    margin-top: 8px;
}

.option-group input:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.range-inputs input {
    flex: 1;
    margin-top: 0;
}

.merge-list {
    min-height: 350px;
    background: white;
    border: 3px dashed var(--border);
    border-radius: 12px;
    padding: 24px;
    margin: 25px auto;
    max-width: 800px;
}

.merge-item {
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    border: 2px solid var(--border);
    padding: 18px 22px;
    margin-bottom: 14px;
    border-radius: 10px;
    cursor: grab;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    font-weight: 500;
}

.merge-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
    transform: translateX(5px);
}

.merge-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.merge-item.drag-over {
    border-color: var(--success);
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 20px;
    font-size: 1.1em;
    font-weight: 500;
}

/* Tooltip-style enhancements */
button[title],
.toolbar-btn[title],
.tool-btn[title] {
    position: relative;
}

/* Loading states */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

.canvas-container {
    margin: 25px auto;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    border: 2px solid var(--border);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
    max-width: 1000px;
}

.canvas-container canvas {
    max-width: 100%;
    border: 3px solid var(--border);
    background: white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    cursor: crosshair;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.canvas-container canvas:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
}

.canvas-controls {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    padding: 15px;
    background: white;
    border-radius: 12px;
    border: 2px solid var(--border);
    box-shadow: var(--shadow);
}

.canvas-controls span {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1em;
}

.canvas-hint {
    color: var(--text-secondary);
    font-size: 0.95em;
    margin-top: 12px;
    text-align: center;
}

.tool-instructions {
    background: linear-gradient(135deg, #eff6ff, #f0f9ff);
    padding: 20px;
    border-radius: 12px;
    margin: 25px auto;
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow);
    max-width: 900px;
}

.tool-instructions p {
    color: var(--text-primary);
    font-size: 0.95em;
    margin-bottom: 8px;
    line-height: 1.6;
}

.tool-instructions p:last-child {
    margin-bottom: 0;
}

.tool-instructions strong {
    color: var(--primary);
    font-weight: 700;
}

.annotation-toolbar {
    display: flex;
    gap: 12px;
    margin: 0 auto 25px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    border: 2px solid var(--border);
    box-shadow: var(--shadow);
    max-width: 800px;
    justify-content: center;
    flex-wrap: wrap;
}

.toolbar-btn {
    padding: 12px 18px;
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.15em;
    transition: all 0.3s ease;
    font-weight: 500;
}

.toolbar-btn:hover {
    border-color: var(--primary);
    background: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.toolbar-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transform: translateY(-2px);
}

#annotation-color,
#edit-color {
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    width: 60px;
    height: 44px;
    transition: all 0.2s ease;
}

#annotation-color:hover,
#edit-color:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.edit-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 0 auto 25px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    border: 2px solid var(--border);
    flex-wrap: wrap;
    box-shadow: var(--shadow);
    max-width: 900px;
    justify-content: center;
}

.edit-toolbar .toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    min-width: 70px;
}

.edit-toolbar .toolbar-btn span:first-child {
    font-size: 1.4em;
}

.edit-toolbar .toolbar-btn span:last-child {
    font-size: 0.8em;
    font-weight: 600;
}

.toolbar-separator {
    width: 2px;
    height: 44px;
    background: var(--border);
    margin: 0 8px;
    border-radius: 2px;
}

.toolbar-label {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.toolbar-input {
    width: 80px;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95em;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
}

.toolbar-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.edit-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.selected-element-box {
    position: absolute;
    border: 2px dashed var(--primary);
    background: rgba(37, 99, 235, 0.1);
    pointer-events: none;
}

.element-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border: 1px solid white;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
}

.element-handle.nw { top: -4px; left: -4px; cursor: nw-resize; }
.element-handle.ne { top: -4px; right: -4px; cursor: ne-resize; }
.element-handle.sw { bottom: -4px; left: -4px; cursor: sw-resize; }
.element-handle.se { bottom: -4px; right: -4px; cursor: se-resize; }

.selected-element-info {
    margin: 25px auto 0;
    padding: 25px;
    background: white;
    border-radius: 12px;
    border: 2px solid var(--border);
    box-shadow: var(--shadow);
    max-width: 800px;
}

.selected-element-info h3 {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: var(--primary);
}

.element-properties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.element-properties label {
    display: flex;
    flex-direction: column;
    font-size: 0.9em;
    font-weight: 600;
}

.element-properties input {
    margin-top: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95em;
}

.element-properties button {
    grid-column: span 1;
    margin-top: 10px;
}

.signature-creator {
    margin: 25px 0;
}

.signature-creator h3 {
    font-size: 1.1em;
    margin-bottom: 15px;
}

.signature-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px 20px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

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

.signature-panel {
    display: none;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.signature-panel.active {
    display: block;
}

#signature-canvas {
    border: 2px solid var(--border);
    background: white;
    border-radius: 6px;
    cursor: crosshair;
    display: block;
    margin: 0 auto 15px;
}

#signature-text {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1.1em;
    margin-bottom: 10px;
}

#signature-font {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.ocr-progress {
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: var(--bg-tertiary);
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    width: 0%;
    transition: width 0.3s;
}

#ocr-status {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.ocr-result {
    margin-top: 25px;
}

.ocr-result h3 {
    font-size: 1.1em;
    margin-bottom: 15px;
}

#ocr-text {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    resize: vertical;
    background: var(--bg-secondary);
}

.compress-info {
    margin: 25px 0;
}

.size-comparison {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 30px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.size-item {
    text-align: center;
}

.size-item p:first-child {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.size-value {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--primary);
}

.size-arrow {
    font-size: 2em;
    color: var(--text-secondary);
}

.main-footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    padding: 25px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.tool-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Drag and drop styles */
.dragging {
    opacity: 0.5;
}

.drag-over {
    border-color: var(--primary) !important;
    background: var(--bg-tertiary) !important;
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .tools-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .tools-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .tool-btn {
        flex: 1 1 calc(33.333% - 6px);
        min-width: 140px;
    }
}

@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }

    .stats {
        width: 100%;
        justify-content: center;
    }

    .workspace {
        padding: 20px;
    }

    .tool-content {
        padding: 20px;
    }

    .size-comparison {
        flex-direction: column;
        gap: 15px;
    }

    .size-arrow {
        transform: rotate(90deg);
    }
}
