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

:root {
    --primary-color: #2563EB;
    --primary-hover: #1D4ED8;
    --danger-color: #EF4444;
    --danger-hover: #DC2626;
    --secondary-color: #10B981;
    --secondary-hover: #059669;
    --bg-color: #F8FAFC;
    --card-bg: #FFFFFF;
    --border-color: #E2E8F0;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --accent-color: #0EA5E9;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    padding: 0;
    color: var(--text-primary);
}

.banner {
    background: linear-gradient(135deg, #2563EB 0%, #0EA5E9 100%);
    color: white;
    padding: 12px 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.banner p {
    margin: 0;
    font-size: 0.95rem;
}

.banner a {
    color: white;
    font-weight: 700;
    text-decoration: underline;
    transition: opacity 0.2s ease;
}

.banner a:hover {
    opacity: 0.8;
}

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

header {
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 40px;
    padding: 30px 0;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--text-primary);
}

.by-legal-flow {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.by-legal-flow strong {
    color: var(--primary-color);
    font-weight: 700;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
}

.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    background: var(--card-bg);
    border: 3px dashed var(--border-color);
    border-radius: 16px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #F3F4F6;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: #EEF2FF;
    border-style: solid;
}

/* Input file caché mais accessible pour le clic programmatique */
.hidden-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.upload-area svg {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.upload-area h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.upload-area p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.pages-info {
    background: var(--bg-color);
    padding: 12px 20px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.pages-count {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1rem;
}

.zoom-global-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-color);
    padding: 8px 15px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.btn-zoom-global {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-zoom-global:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.btn-zoom-global:active {
    transform: scale(0.95);
}

.zoom-global-label {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
    min-width: 90px;
    text-align: center;
}

#globalZoomLevel {
    color: var(--primary-color);
    font-weight: 700;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

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

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

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

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

.btn-danger {
    background: var(--danger-color);
    color: white;
}

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

.btn-scissors {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    color: white;
}

.btn-scissors:hover {
    background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
}

.btn-scissors.active {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    50% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
}

/* Scissors Mode */
.scissors-info {
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    border: 2px solid #8B5CF6;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: none;
    flex-direction: column;
    gap: 15px;
}

.scissors-instructions {
    text-align: center;
}

.scissors-instructions strong {
    display: block;
    font-size: 1.2rem;
    color: #7C3AED;
    margin-bottom: 8px;
}

.scissors-instructions p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.scissors-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.scissors-divider {
    position: absolute;
    right: -18px;
    top: 0;
    bottom: 0;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    transition: all 0.2s ease;
}

.scissors-active .scissors-divider {
    opacity: 0.4;
}

.scissors-active .scissors-divider:hover {
    opacity: 1;
    transform: scale(1.2);
}

.scissors-divider::before {
    content: '✂️';
    font-size: 2.5rem;
    filter: grayscale(100%);
    transition: all 0.2s ease;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.scissors-divider.active::before {
    filter: none;
    animation: snip 0.3s ease;
}

.scissors-divider.active {
    opacity: 1 !important;
}

.scissors-divider.active::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, transparent 0%, #EF4444 20%, #EF4444 80%, transparent 100%);
    border-radius: 2px;
}

@keyframes snip {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(20deg); }
}

/* Couleurs des sections en mode ciseaux */
.scissors-active .page-card {
    transition: all 0.3s ease;
}

.scissors-active .page-card[class*="section-"] {
    background: var(--section-bg) !important;
    border-color: var(--section-border) !important;
    border-width: 3px !important;
}

.scissors-active .page-card[class*="section-"]::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 12px;
    background: var(--section-bg);
    opacity: 0.3;
    z-index: -1;
    animation: sectionGlow 2s ease-in-out infinite;
}

@keyframes sectionGlow {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.02); }
}

.scissors-active .page-card[class*="section-"]:hover::before {
    opacity: 0.5;
}

.pages-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.page-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 15px;
    box-shadow: var(--shadow);
    cursor: move;
    transition: all 0.2s ease;
    position: relative;
    border: 2px solid var(--border-color);
}

.page-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.page-card.selected {
    border-color: var(--primary-color);
    background: #EEF2FF;
}

.page-checkbox {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

.page-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.page-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.page-card.drag-over {
    border: 2px solid var(--primary-color);
}

.page-preview {
    width: 100%;
    aspect-ratio: 1/1.414;
    background: #F3F4F6;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-preview canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.page-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.page-number {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.page-source {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-color);
    padding: 2px 8px;
    border-radius: 4px;
}

.page-reorder {
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    background: var(--bg-color);
    padding: 8px;
    border-radius: 6px;
}

.btn-reorder {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-reorder:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.btn-reorder:active {
    transform: scale(0.95);
}

.page-number-input {
    width: 50px;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    background: white;
}

.page-number-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Masquer les flèches du input number sur Chrome/Safari */
.page-number-input::-webkit-inner-spin-button,
.page-number-input::-webkit-outer-spin-button {
    opacity: 1;
}

.page-actions {
    display: flex;
    gap: 5px;
}

.page-actions button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.btn-rotate {
    background: #8B5CF6;
    color: white;
}

.btn-rotate:hover {
    background: #7C3AED;
    transform: scale(1.05);
}

.btn-zoom {
    background: var(--secondary-color);
    color: white;
}

.btn-zoom:hover {
    background: var(--secondary-hover);
    transform: scale(1.05);
}

.btn-delete {
    background: var(--danger-color);
    color: white;
}

.btn-delete:hover {
    background: var(--danger-hover);
    transform: scale(1.05);
}

.btn-rotate-selection {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    color: white;
}

.btn-rotate-selection:hover {
    background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

#loadingText {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Skeleton loader pour lazy loading */
.skeleton-loader {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Spinner petit pour preview popup */
.spinner-small {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 100px auto;
}

/* Preview popup au survol */
.page-preview-popup {
    position: fixed;
    z-index: 2000;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 3px solid var(--primary-color);
    overflow: hidden;
    display: none;
    transition: opacity 0.15s ease;
    max-width: 450px;
    width: 450px;
    pointer-events: none; /* Pas d'interaction - le zoom disparaît quand on quitte la carte */
}

.preview-header {
    background: var(--primary-color);
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-direction: column;
    gap: 8px;
}

.preview-header > div {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.preview-section-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 700;
    white-space: nowrap;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.preview-filename {
    font-size: 0.75rem;
    opacity: 0.9;
    font-weight: 400;
}

.preview-content {
    padding: 15px;
    background: #f9fafb;
    min-height: 450px;
    max-height: 550px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.preview-content canvas {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    box-shadow: var(--shadow);
}

/* Zoom Modal */
.zoom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
}

.zoom-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.zoom-content {
    position: relative;
    z-index: 3001;
    background: white;
    border-radius: 12px;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.zoom-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.zoom-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.zoom-page-number {
    font-size: 1.1rem;
    font-weight: 700;
}

.zoom-filename {
    font-size: 0.85rem;
    opacity: 0.9;
}

.zoom-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.zoom-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
    transform: scale(1.1);
}

.zoom-btn:active {
    transform: scale(0.95);
}

.zoom-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.zoom-nav {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.5);
}

.zoom-nav:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.4);
    border-color: rgba(16, 185, 129, 1);
}

.zoom-close {
    background: rgba(239, 68, 68, 0.8);
    border-color: rgba(239, 68, 68, 1);
}

.zoom-close:hover {
    background: rgba(239, 68, 68, 1);
}

.zoom-level {
    font-weight: 700;
    font-size: 1rem;
    min-width: 50px;
    text-align: center;
}

.zoom-canvas-container {
    flex: 1;
    overflow: auto;
    padding: 20px;
    background: #f9fafb;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    max-height: calc(95vh - 100px);
}

.zoom-canvas-container canvas {
    display: block;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

/* Position Modal */
.position-modal-content {
    background: white;
    padding: 35px 40px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 500px;
    animation: modalSlideIn 0.3s ease;
}

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

.position-modal-content h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.position-modal-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 30px;
}

.position-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.btn-position {
    flex: 1;
    background: white;
    border: 3px solid var(--border-color);
    border-radius: 12px;
    padding: 25px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.btn-position:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.btn-position-start {
    border-color: var(--secondary-color);
}

.btn-position-start:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(16, 185, 129, 0.1) 100%);
    border-color: var(--secondary-color);
}

.btn-position-end {
    border-color: var(--primary-color);
}

.btn-position-end:hover {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(37, 99, 235, 0.1) 100%);
    border-color: var(--primary-color);
}

.position-icon {
    font-size: 2.5rem;
}

.position-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.position-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-cancel {
    background: var(--bg-color);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 30px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-cancel:hover {
    background: #e5e7eb;
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* =================================
   Navigation par onglets
   ================================= */
.tabs-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: white;
    padding: 10px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    justify-content: center;
    flex-wrap: wrap;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: #EEF2FF;
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0EA5E9 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.tab-icon {
    font-size: 1.3rem;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* =================================
   OCR Section
   ================================= */
.ocr-section {
    max-width: 900px;
    margin: 0 auto;
}

.ocr-language-select {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    padding: 15px 20px;
    background: white;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.ocr-language-select label {
    font-weight: 600;
    color: var(--text-primary);
}

.ocr-language-select select {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    min-width: 180px;
}

.ocr-language-select select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.ocr-preview {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin: 20px 0;
    overflow: hidden;
}

.ocr-preview-header {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.ocr-preview-header h3 {
    font-size: 1.1rem;
}

.ocr-progress {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    max-width: 400px;
}

.ocr-progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.ocr-progress-fill {
    height: 100%;
    background: white;
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.ocr-progress-text {
    font-size: 0.85rem;
    white-space: nowrap;
}

.ocr-preview-content {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.ocr-image-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.ocr-image-container img,
.ocr-image-container canvas {
    width: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 2px solid var(--border-color);
}

.ocr-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 20px 0;
}

.ocr-result {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin: 20px 0;
    overflow: hidden;
}

.ocr-result-header {
    background: var(--secondary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.ocr-result-header h3 {
    font-size: 1.1rem;
}

.ocr-result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ocr-result-actions .btn {
    padding: 8px 16px;
    font-size: 0.9rem;
}

#ocrTextOutput {
    width: 100%;
    min-height: 300px;
    padding: 20px;
    border: none;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    background: #FAFAFA;
}

#ocrTextOutput:focus {
    outline: none;
}

/* =================================
   Merge Section
   ================================= */
.merge-section {
    max-width: 900px;
    margin: 0 auto;
}

.upload-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 10px;
    font-style: italic;
}

.merge-files-list {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin: 20px 0;
    overflow: hidden;
}

.merge-files-header {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.merge-files-header h3 {
    font-size: 1.1rem;
}

.merge-files-actions {
    display: flex;
    gap: 10px;
}

.merge-files-container {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.merge-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: var(--bg-color);
    border-radius: 8px;
    margin-bottom: 10px;
    border: 2px solid var(--border-color);
    cursor: grab;
    transition: all 0.2s ease;
    user-select: none;
}

.merge-drag-handle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: grab;
    padding: 5px;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.merge-file-item:hover .merge-drag-handle {
    opacity: 1;
}

.merge-file-item:active {
    cursor: grabbing;
}

.merge-file-item:active .merge-drag-handle {
    cursor: grabbing;
}

.merge-file-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.merge-file-item.dragging {
    opacity: 0.4;
    transform: scale(0.95);
    border-style: dashed;
    cursor: grabbing;
}

.merge-file-item.drag-over {
    border-color: var(--secondary-color);
    border-width: 3px;
    background: #ECFDF5;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.merge-file-icon {
    font-size: 2rem;
    min-width: 40px;
    text-align: center;
}

.merge-file-info {
    flex: 1;
    min-width: 0;
}

.merge-file-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.merge-file-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    gap: 15px;
    margin-top: 4px;
}

.merge-file-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.merge-file-status .status-icon {
    font-size: 1.2rem;
}

.merge-file-status .status-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.merge-file-status.ready .status-icon { color: var(--secondary-color); }
.merge-file-status.converting .status-icon { animation: spin 1s linear infinite; }
.merge-file-status.error .status-icon { color: var(--danger-color); }

.merge-file-actions button {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.merge-file-actions button:hover {
    background: var(--danger-hover);
    transform: scale(1.1);
}

.merge-conversion-status {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.conversion-progress {
    display: flex;
    align-items: center;
    gap: 15px;
}

.conversion-progress-bar {
    flex: 1;
    height: 10px;
    background: var(--bg-color);
    border-radius: 5px;
    overflow: hidden;
}

.conversion-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 5px;
    transition: width 0.3s ease;
    width: 0%;
}

.conversion-progress-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.merge-export-actions {
    padding: 20px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.btn-large {
    padding: 16px 40px;
    font-size: 1.1rem;
}

/* File type badges */
.file-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.file-type-badge.pdf { background: #FEE2E2; color: #DC2626; }
.file-type-badge.image { background: #DBEAFE; color: #2563EB; }
.file-type-badge.word { background: #DBEAFE; color: #1D4ED8; }
.file-type-badge.excel { background: #D1FAE5; color: #059669; }
.file-type-badge.pptx { background: #FEF3C7; color: #D97706; }

/* =================================
   Responsive pour les nouvelles sections
   ================================= */
@media (max-width: 768px) {
    .tabs-nav {
        padding: 8px;
        gap: 8px;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
        flex: 1;
        justify-content: center;
    }

    .tab-btn .tab-label {
        display: none;
    }

    .tab-icon {
        font-size: 1.5rem;
    }

    .ocr-language-select {
        flex-direction: column;
        align-items: stretch;
    }

    .ocr-language-select select {
        width: 100%;
    }

    .ocr-preview-header,
    .ocr-result-header,
    .merge-files-header {
        flex-direction: column;
        text-align: center;
    }

    .ocr-result-actions,
    .merge-files-actions {
        width: 100%;
        justify-content: center;
    }

    .merge-file-item {
        flex-wrap: wrap;
    }

    .merge-file-meta {
        flex-direction: column;
        gap: 5px;
    }

    header h1 {
        font-size: 2rem;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .pages-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    .actions {
        flex-direction: column;
    }

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

    /* Position modal responsive */
    .position-modal-content {
        padding: 25px 20px;
        margin: 0 15px;
    }

    .position-buttons {
        flex-direction: column;
        gap: 12px;
    }

    .btn-position {
        padding: 20px;
    }

    .position-icon {
        font-size: 2rem;
    }

    /* Zoom modal responsive */
    .zoom-header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .zoom-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .zoom-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}
