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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 2rem;
    color: #333;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3rem 2rem;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

main {
    padding: 2rem;
}

.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
    position: relative;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-area:hover {
    border-color: #764ba2;
    background: #f0f2ff;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #11998e;
    border-width: 4px;
    background: linear-gradient(135deg, rgba(17, 153, 142, 0.1) 0%, rgba(56, 239, 125, 0.1) 100%);
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(17, 153, 142, 0.3);
}

.upload-area.dragover::before {
    content: '📁 Déposez vos images ici';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: #11998e;
    pointer-events: none;
    z-index: 10;
}

.upload-icon {
    color: #667eea;
    margin-bottom: 1rem;
    pointer-events: none; /* Ne pas bloquer les événements drag & drop */
}

.upload-text {
    font-size: 1.3rem;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 0.5rem;
    pointer-events: none; /* Ne pas bloquer les événements drag & drop */
}

.upload-subtext {
    color: #666;
    font-size: 0.95rem;
    pointer-events: none; /* Ne pas bloquer les événements drag & drop */
}

.settings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8f9ff;
    border-radius: 10px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-group label {
    font-weight: 600;
    color: #555;
    font-size: 0.95rem;
}

.setting-group input,
.setting-group select {
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.setting-group input:focus,
.setting-group select:focus {
    outline: none;
    border-color: #667eea;
}

.preview-section {
    margin-top: 2rem;
}

.preview-section h2 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    background: #f8f9ff;
    border-radius: 10px;
    /* Optimisation pour grand nombre d'éléments */
    will-change: scroll-position;
    scroll-behavior: smooth;
}

/* Scrollbar personnalisée */
.preview-grid::-webkit-scrollbar {
    width: 10px;
}

.preview-grid::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 5px;
}

.preview-grid::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 5px;
}

.preview-grid::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
    /* Optimisation pour lazy loading */
    contain: layout style paint;
}

.preview-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    z-index: 1;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Optimisation du rendu */
    image-rendering: -webkit-optimize-contrast;
}

.preview-item .index {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    z-index: 2;
}

.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(56, 239, 125, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.progress-section {
    margin-top: 2rem;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #f0f0f0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.progress-text {
    color: #666;
    font-size: 1.1rem;
}

.result-section {
    margin-top: 2rem;
    text-align: center;
}

.result-section h2 {
    color: #11998e;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.result-section video {
    width: 100%;
    max-width: 800px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 1.5rem;
}

.result-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

footer {
    background: #f8f9ff;
    padding: 1.5rem;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    main {
        padding: 1rem;
    }

    .settings {
        grid-template-columns: 1fr;
    }

    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

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