/* ========================================
   📄 DINOv2 Document Recognizer Styles
   ======================================== */

/* Modal principal */
.dinov2-modal {
    z-index: 10000;
}

.dinov2-modal-content {
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.dinov2-header {
    background: #293F50;
    color: white;
    padding: 20px 30px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dinov2-header h2 {
    margin: 0;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.dinov2-header .modal-close {
    font-size: 32px;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
}

.dinov2-header .modal-close:hover {
    transform: scale(1.2);
}

.dinov2-body {
    padding: 30px;
    background: #f8f9fa;
}

/* Navigation par onglets */
.dinov2-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.dinov2-tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #666;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.dinov2-tab:hover {
    color: #3498db;
    background: rgba(102, 161, 234, 0.05);
}

.dinov2-tab.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: rgba(102, 179, 234, 0.1);
}

/* Contenu des onglets */
.dinov2-tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

.dinov2-tab-content.active {
    display: block;
}

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

.dinov2-tab-content h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dinov2-description {
    color: #666;
    margin-bottom: 25px;
    font-size: 0.95rem;
}

/* Zone d'upload */
.dinov2-upload-zone {
    border: 3px dashed #ccc;
    border-radius: 12px;
    padding: 50px 30px;
    text-align: center;
    background: white;
    transition: all 0.3s;
    cursor: pointer;
    margin-bottom: 25px;
}

.dinov2-upload-zone:hover {
    border-color: #3498db;
    background: rgba(102, 201, 234, 0.05);
}

.dinov2-upload-zone.drag-over {
    border-color: #3498db;
    background: rgba(102, 181, 234, 0.1);
    transform: scale(1.02);
}

.dinov2-upload-zone i {
    font-size: 48px;
    color: #999;
    display: block;
    margin-bottom: 15px;
}

.dinov2-upload-zone p {
    color: #666;
    margin: 15px 0;
    font-size: 1.05rem;
}

/* Preview d'image */
.dinov2-preview {
    text-align: center;
    margin: 25px 0;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dinov2-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Liste des fichiers (batch upload) */
.dinov2-files-list {
    width: 100%;
}

.dinov2-files-list-header {
    margin-bottom: 15px;
}

.dinov2-files-list-header h4 {
    margin: 0;
    color: #293F50;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dinov2-files-grid {
    display: grid;
    gap: 10px;
}

.dinov2-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s;
}

.dinov2-file-item:hover {
    background: #e9ecef;
    border-color: #3498db;
}

.dinov2-file-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #293F50;
    border-radius: 8px;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

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

.dinov2-file-name {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.dinov2-file-size {
    font-size: 0.85rem;
    color: #999;
}

.dinov2-file-remove {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: #ED7470;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.dinov2-file-remove:hover {
    background: #dc3545;
    transform: scale(1.1);
}

/* Formulaires */
.dinov2-form-group {
    margin: 25px 0;
}

.dinov2-form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dinov2-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
}

.dinov2-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.dinov2-form-group small {
    display: block;
    margin-top: 5px;
    color: #999;
    font-size: 0.85rem;
}

/* Boutons */
.dinov2-btn-full {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

/* Résultats de détection */
.dinov2-results {
    margin-top: 30px;
    padding: 25px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dinov2-results h4 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dinov2-result-item {
    padding: 15px;
    margin-bottom: 15px;
    background: #f8f9fa;
    border-left: 4px solid #3498db;
    border-radius: 8px;
}

.dinov2-result-primary {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-left-color: #293F50;
    border-left-width: 6px;
    font-weight: 600;
}

.dinov2-result-category {
    font-size: 1.2rem;
    color: #293F50;
    font-weight: 700;
    margin-bottom: 8px;
}

.dinov2-result-confidence {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.dinov2-confidence-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.dinov2-confidence-fill {
    height: 100%;
    background: #3498db;
    transition: width 0.5s ease;
}

.dinov2-confidence-text {
    font-weight: 600;
    color: #293F50;
    min-width: 50px;
}

.dinov2-extracted-text {
    margin-top: 20px;
    padding: 20px;
    background: #f1f3f5;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.dinov2-extracted-text h5 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dinov2-extracted-text pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #555;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Statistiques */
.dinov2-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dinov2-stat-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.dinov2-stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.dinov2-stat-card i {
    font-size: 36px;
    color: #293F50;
    margin-bottom: 15px;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin: 10px 0;
}

.stat-label {
    color: #666;
    font-size: 0.95rem;
    font-weight: 500;
}

/* Liste des catégories */
.dinov2-categories-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin: 25px 0;
}

.dinov2-category-badge {
    padding: 12px 18px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border: 2px solid #293F50;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    color: #293F50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: all 0.3s;
}

.dinov2-category-badge:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(102, 197, 234, 0.3);
}

.dinov2-category-count {
    background: #293F50;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
}

/* Liste des références */
.dinov2-references-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin: 25px 0;
}

.dinov2-reference-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.dinov2-reference-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.dinov2-reference-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #f1f3f5;
}

.dinov2-reference-info {
    padding: 15px;
}

.dinov2-reference-category {
    font-weight: 700;
    color: #293F50;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dinov2-reference-date {
    font-size: 0.85rem;
    color: #999;
}

.dinov2-reference-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.dinov2-reference-actions button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.btn-view {
    background: #3498db;
    color: white;
}

.btn-view:hover {
    background: #3498db;
}

.btn-delete {
    background: #ED7470;
    color: white;
}

.btn-delete:hover {
    background: #ED7470;
}

/* Actions de gestion */
.dinov2-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    justify-content: center;
}

/* Barre de progression */
.dinov2-progress {
    margin-top: 30px;
    padding: 25px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.progress-bar {
    height: 100%;
    background: #61C276;
    width: 0%;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

#dinov2ProgressText {
    text-align: center;
    color: #666;
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .dinov2-modal-content {
        max-width: 95%;
        margin: 20px auto;
    }

    .dinov2-tabs {
        flex-direction: column;
    }

    .dinov2-stats {
        grid-template-columns: 1fr;
    }

    .dinov2-categories-list,
    .dinov2-references-list {
        grid-template-columns: 1fr;
    }

    .dinov2-actions {
        flex-direction: column;
    }
}

/* États de chargement */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #293F50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Messages d'information */
.dinov2-info-message {
    padding: 15px 20px;
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    border-left: 4px solid #17a2b8;
    border-radius: 8px;
    color: #0c5460;
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.dinov2-success-message {
    background: #d4edda;
    border-color: #c3e6cb;
    border-left-color: #28a745;
    color: #155724;
}

.dinov2-error-message {
    background: #f8d7da;
    border-color: #f5c6cb;
    border-left-color: #ED7470;
    color: #721c24;
}

.dinov2-warning-message {
    background: #fff3cd;
    border-color: #ffeaa7;
    border-left-color: #ffc107;
    color: #856404;
}

/* ========================================
   Champs extraits
   ======================================== */

.dinov2-extracted-fields {
    margin-top: 25px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-radius: 12px;
    border: 2px solid #293F50;
}

.dinov2-extracted-fields h5 {
    margin: 0 0 20px 0;
    color: #293F50;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dinov2-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.dinov2-field-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    transition: all 0.3s;
}

.dinov2-field-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dinov2-field-name {
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
    text-transform: capitalize;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dinov2-field-value {
    font-size: 1rem;
    color: #333;
    font-weight: 500;
    word-break: break-word;
}

.dinov2-field-value.field-value-found {
    color: #28a745;
    font-weight: 600;
}

.dinov2-field-value.field-value-missing {
    color: #999;
    font-style: italic;
}

.dinov2-extraction-confidence {
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    text-align: center;
    font-size: 0.95rem;
    color: #666;
}

.dinov2-extraction-confidence strong {
    color: #293F50;
    font-size: 1.1rem;
}

/* ========================================
   Templates - Grille
   ======================================== */

.dinov2-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
    margin: 10px;
}

.dinov2-template-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
    border: 2px solid #e0e0e0;
}

.dinov2-template-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.dinov2-template-header {
    background: linear-gradient(135deg, #293F50 0%, #3d5a73 100%);
    padding: 20px;
    color: white;
}

.dinov2-template-header h4 {
    margin: 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dinov2-template-body {
    padding: 20px;
}

.dinov2-template-info {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dinov2-template-fields-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dinov2-field-tag {
    display: inline-block;
    background: #e9ecef;
    color: #495057;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.dinov2-more-fields {
    display: inline-block;
    background: #3498db;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.dinov2-template-actions {
    padding: 15px;
    background: #f8f9fa;
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.dinov2-template-actions .btn-sm {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.85rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.dinov2-template-actions .btn-sm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ========================================
   Templates - Formulaire d'édition
   ======================================== */

.dinov2-template-form {
    margin-top: 30px;
    padding: 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    border: 2px solid #3498db;
}

.dinov2-template-form h4 {
    margin: 0 0 25px 0;
    color: #293F50;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.dinov2-fields-list {
    margin: 20px 0;
}

.dinov2-field-editor {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s;
}

.dinov2-field-editor:hover {
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
}

.dinov2-field-editor-row {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.dinov2-field-editor-row:last-child {
    margin-bottom: 0;
}

.dinov2-field-editor-col {
    flex: 1;
    min-width: 0;
}

.dinov2-field-editor-col-full {
    flex: 1;
}

.dinov2-field-editor-col-small {
    flex: 0 0 auto;
    min-width: 100px;
    display: flex;
    align-items: flex-end;
}

.dinov2-field-editor label {
    display: block;
    margin-bottom: 5px;
    color: #495057;
    font-weight: 600;
    font-size: 0.9rem;
}

.dinov2-field-editor input[type="text"],
.dinov2-field-editor select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.dinov2-field-editor input[type="text"]:focus,
.dinov2-field-editor select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.dinov2-field-editor input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.dinov2-form-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
    justify-content: center;
}

.dinov2-form-actions .btn {
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dinov2-form-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ========================================
   Responsive - Templates
   ======================================== */

@media (max-width: 768px) {
    .dinov2-templates-grid {
        grid-template-columns: 1fr;
    }

    .dinov2-fields-grid {
        grid-template-columns: 1fr;
    }

    .dinov2-field-editor-row {
        flex-direction: column;
    }

    .dinov2-field-editor-col-small {
        min-width: 100%;
    }

    .dinov2-form-actions {
        flex-direction: column;
    }

    .dinov2-template-actions {
        flex-direction: column;
    }
}
