/* Variables de gestion des couleurs et thèmes */
:root {
    --primary-color: #2e5984;
    --primary-hover: #244669;
    --bg-main: #f4f7f6;
    --bg-card: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    --text-light: #777777;
    --border-color: #dddddd;
    --border-light: #eeeeee;
    --accent-digital: #a93226;
    --accent-digital-bg: #fffafa;
    --accent-physical: #5d6d7e;
    --accent-physical-bg: #f8f9fa;
    --success-color: #27ae60;
    --info-color: #2980b9;
    --warning-color: #f39c12;
    --danger-color: #c0392b;
    --gray-muted: #6c757d;
    --shadow: 0 2px 4px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }

/* Base & Typography */
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; padding: 20px; background-color: var(--bg-main); color: var(--text-main); line-height: 1.4; }
nav { margin-bottom: 20px; background: var(--bg-card); padding: 10px; border-radius: 8px; box-shadow: var(--shadow); }
a { color: var(--primary-color); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; }

h1, h2, h3, h4 { margin-top: 0; margin-bottom: 10px; }
h2 { font-size: 1.4em; }
h4 { font-size: 0.9em; text-transform: uppercase; color: var(--text-muted); margin: 0; }

.facet-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
    gap: 5px;
    margin-bottom: 8px;
    margin-top: 15px;
}

.facet-sort { display: flex; gap: 4px; }
.facet-sort a { 
    font-size: 0.65em; 
    padding: 1px 4px; 
    background: #eee; 
    color: var(--text-light); 
    border-radius: 3px; 
    text-decoration: none; 
    font-weight: bold;
    line-height: 1.2;
}
.facet-sort a:hover { background: #ddd; color: #333; }
.facet-sort a.active { background: var(--primary-color); color: #fff; }

/* Buttons & Inputs */
.btn-primary { background: var(--primary-color); color: #fff; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-reset { color: var(--text-muted); font-size: 0.9em; margin-left: 10px; }
.sort-select { padding: 4px 8px; border-radius: 4px; border: 1px solid #ccc; background: var(--bg-card); font-size: 0.9em; }

/* Toolbar & Toggles */
.view-toggle { margin-bottom: 15px; display: flex; gap: 10px; }
.btn-toggle { padding: 5px 15px; border: 1px solid var(--primary-color); background: var(--bg-card); color: var(--primary-color); border-radius: 4px; cursor: pointer; }
.btn-toggle.active { background: var(--primary-color); color: #fff; }

/* General Layout */
.main-content-wrapper {
    display: flex;
    flex-direction: row; /* Force l'affichage côte à côte */
    align-items: flex-start;
    gap: 20px;
    width: 100%;
}

/* Facet Column */
.facet-column {
    flex: 0 0 250px;
    background: var(--bg-card);
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px); /* Limite la hauteur à la fenêtre moins marges */
    overflow-y: auto; /* Permet le défilement interne */
}

/* Style discret pour les barres de défilement des facettes */
.facet-column::-webkit-scrollbar,
.facet-list::-webkit-scrollbar {
    width: 4px;
}
.facet-column::-webkit-scrollbar-thumb,
.facet-list::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

.facet-list { list-style: none; padding: 0; margin-bottom: 20px; max-height: 180px; overflow-y: auto; font-size: 0.85em; }
.facet-list li { margin-bottom: 4px; display: flex; align-items: center; }
.facet-list input { margin-right: 6px; flex-shrink: 0; }
.facet-list label { flex: 1; display: flex; align-items: center; cursor: pointer; }

.facet-count {
    margin-left: auto;
    background: #e8e8e8;
    color: var(--text-muted);
    font-size: 0.85em;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 500;
}

.date-range { display: flex; align-items: center; gap: 5px; margin-bottom: 10px; }
.date-range input { width: 80px; padding: 3px; border: 1px solid #ccc; border-radius: 3px; }

/* Results Column */
.results-column { flex: 1; min-width: 0; }
.results-header { 
    margin-bottom: 15px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}
.results-title-wrapper { display: flex; align-items: center; gap: 15px; }
.results-title-wrapper h2 { margin: 0; }

/* Result Item & Actions */
.result-item { position: relative; }
.result-selector { margin-right: 10px; align-self: center; }
.result-actions { margin-top: 10px; border-top: 1px solid var(--border-light); padding-top: 10px; display: flex; gap: 10px; }

.merge-bar { 
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); 
    background: var(--text-main); color: #fff; padding: 15px 30px; border-radius: 50px; 
    display: none; box-shadow: 0 4px 15px rgba(0,0,0,0.3); z-index: 1000;
    align-items: center; gap: 20px;
}

/* Result Content */
.result-item {
    display: flex;
    background: var(--bg-card);
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    gap: 15px;
}
.result-content { flex: 1; }
.result-content h3 { font-size: 1.1em; margin-bottom: 4px; }
.edit-icon { font-size: 0.8em; margin-left: 8px; vertical-align: middle; text-decoration: none !important; cursor: pointer; }

/* Accentuation sobre par bordure latérale et fond teinté */
.result-item.is-numeric-numérique { 
    border-left: 6px solid var(--accent-digital); 
    background-color: var(--accent-digital-bg);
}
.result-item.is-numeric-physique { 
    border-left: 6px solid var(--accent-physical); 
    background-color: var(--accent-physical-bg);
}

.result-content h3 a { color: var(--primary-color); font-weight: 600; }

.result-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.75em; color: var(--text-light); margin-bottom: 6px; }
.result-meta span { background: rgba(0,0,0,0.04); padding: 2px 6px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.03); }
.result-description { font-size: 0.85em; color: var(--text-muted); margin: 0; word-break: break-word; }
.result-image img { 
    display: block;
    max-width: 80px !important; 
    max-height: 120px !important; 
    width: auto; /* Ensure aspect ratio is maintained */
    height: auto; /* Ensure aspect ratio is maintained */
    border-radius: 4px; border: 1px solid var(--border-light); }

/* Grille des notices liées (vue Œuvres) */
.linked-records-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 15px; padding: 10px; background: rgba(0,0,0,0.03); border-radius: 6px; }
.linked-record-item { width: 85px; font-size: 0.7em; line-height: 1.2; text-align: center; }
.linked-record-item img { 
    display: block; 
    max-width: 80px !important; 
    max-height: 120px !important; 
    width: auto;
    height: auto;
    margin: 0 auto 5px; 
    border: 1px solid #ddd; 
    border-radius: 3px; 
    background: var(--bg-card);
}
.linked-record-item a { color: #555; display: block; text-decoration: none; }
.linked-record-item a span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Pagination Styles */
.pagination-container { margin-top: 20px; text-align: center; }
.pagination { display: flex; justify-content: center; gap: 5px; }
.pagination-link { padding: 4px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 0.9em; }
.pagination-link.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }

/* Harvester Styles */
.harvester-message { padding: 10px; border-radius: 4px; margin-bottom: 10px; font-weight: bold; }
.harvester-message-error { color: var(--danger-color); }
.harvester-message-success { color: var(--success-color); }
.harvester-message-info { color: var(--info-color); }

.harvester-field-group { margin-bottom: 15px; }
.harvester-input-full { width: 100%; max-width: 600px; padding: 8px; margin-top: 5px; border: 1px solid #ccc; border-radius: 4px; }

.btn-harvest-full { background-color: var(--success-color) !important; }
.btn-harvest-inc { margin-left: 10px; background-color: var(--info-color) !important; }
.btn-harvest-clean { margin-left: 10px; background-color: var(--warning-color) !important; color: black !important; }
.btn-harvest-stop { background-color: var(--danger-color) !important; color: #fff !important; }

.progress-container { margin-top: 20px; }
.progress-track { width: 100%; background-color: #f3f3f3; border-radius: 5px; margin-bottom: 10px; }
.progress-bar-inner { width: 0%; height: 20px; background-color: var(--success-color); text-align: center; line-height: 20px; color: white; border-radius: 5px; transition: width 0.3s ease; }
.step-message { font-style: italic; color: var(--text-muted); }

/* Export UI */
.btn-export { background-color: var(--gray-muted) !important; padding: 4px 10px; font-size: 0.8em; text-decoration: none; color: #fff; border-radius: 4px; }

/* Edit Oeuvre View */
.edit-form { display: grid; gap: 15px; max-width: 800px; }
.edit-form-group label { display: block; font-weight: bold; margin-bottom: 5px; }
.edit-form-input { width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; }
.edit-form-textarea { width: 100%; height: 150px; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; }
.edit-form-separator { margin: 40px 0; border: 0; border-top: 1px solid var(--border-color); }
.linked-record-secondary { font-size: 0.9em; opacity: 0.8; }

/* Contrôles is_numeric */
.is-numeric-control { margin-top: 8px; display: flex; gap: 5px; align-items: center; }
.is-numeric-display { 
    display: inline-flex; 
    align-items: center; 
    font-size: 0.75em; 
    font-weight: bold; 
    padding: 2px 8px; 
    border-radius: 4px; 
    text-transform: capitalize;
}
.is-numeric-display.is-numeric-numérique { background: #ffebee; color: var(--accent-digital); border: 1px solid #ffcdd2; }
.is-numeric-display.is-numeric-physique { background: #f5f5f5; color: #333; border: 1px solid #e0e0e0; }

.clear-is-numeric { 
    background: none; 
    border: none; 
    color: inherit; 
    cursor: pointer; 
    margin-left: 5px; 
    font-size: 1.2em; 
    line-height: 1; 
    opacity: 0.5;
}
.clear-is-numeric:hover { opacity: 1; }

.set-is-numeric { 
    font-size: 0.7em; 
    padding: 2px 6px; 
    border: 1px solid #ddd; 
    background: #fff; 
    color: #888; 
    border-radius: 4px; 
    cursor: pointer;
}
.set-is-numeric:hover { background: #f0f0f0; border-color: #bbb; color: #333; }
.btn-numeric:hover { color: var(--accent-digital); border-color: var(--accent-digital); }
.btn-physique:hover { color: #000; border-color: #000; }
