body, html { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
#app-container { display: flex; height: 100%; }
#map { flex-grow: 1; height: 100%; background: #eee; }

.resize-handle {
    width: 6px;
    background: #ddd;
    cursor: col-resize;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    transition: background-color 0.2s;
}

.resize-handle:hover {
    background: #007bff;
}

#control-panel, #analysis-panel {
    width: 400px;
    min-width: 250px;
    padding: 20px;
    box-sizing: border-box;
    background: #f8f9fa;
    overflow-y: auto;
}
h1, h2 { color: #333; border-bottom: 2px solid #007bff; padding-bottom: 10px; margin-top: 0;}
.slider-group, .control-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 5px; font-weight: bold; color: #555; }
input[type="range"] { width: 100%; }
select, button { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; background: white; font-size: 16px; }
button { background: #007bff; color: white; cursor: pointer; border: none; margin-top: 10px; }
button:hover { background: #0056b3; }
button:disabled {
    background: #6c757d !important;
    cursor: not-allowed;
    opacity: 0.6;
}
.button-group { display: flex; gap: 10px; margin-top: 20px; }
.button-group button { width: auto; flex: 1; margin-top: 0; }
#reset-weights { background: #6c757d; }
#reset-weights:hover { background: #545b62; }
.hidden { display: none; }
.loader-container { text-align: center; padding: 50px 0; }
.loader { border: 8px solid #f3f3f3; border-radius: 50%; border-top: 8px solid #3498db; width: 50px; height: 50px; animation: spin 2s linear infinite; margin: 0 auto 15px auto;}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
#stats p { background: #e9ecef; padding: 8px; border-radius: 4px; }
#stats span { font-weight: bold; }

/* Styles pour les deux niveaux de pondération */
#controls h3 {
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 8px;
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 1.1em;
}

#controls h3:first-of-type {
    margin-top: 0;
}

.main-weight {
    background: linear-gradient(90deg, #007bff 0%, #0056b3 100%);
}

.sub-weight {
    background: linear-gradient(90deg, #28a745 0%, #1e7e34 100%);
}

/* Distinguer visuellement les sections */
.main-weight::-webkit-slider-thumb {
    background: #007bff;
}

.sub-weight::-webkit-slider-thumb {
    background: #28a745;
}

/* Amélioration de l'affichage des rasters - empêcher l'interpolation */
.leaflet-image-layer,
.leaflet-image-layer img {
    image-rendering: -moz-crisp-edges !important;
    image-rendering: -webkit-crisp-edges !important;
    image-rendering: pixelated !important;
    image-rendering: -webkit-optimize-contrast !important;
    image-rendering: crisp-edges !important;
    -ms-interpolation-mode: nearest-neighbor !important;
}

/* Forcer l'affichage net des canvas */
canvas {
    image-rendering: -moz-crisp-edges !important;
    image-rendering: -webkit-crisp-edges !important;
    image-rendering: pixelated !important;
    image-rendering: crisp-edges !important;
    -ms-interpolation-mode: nearest-neighbor !important;
}

/* Classe spécifique pour les overlays raster nets */
.raster-overlay-net,
.raster-overlay-net img {
    image-rendering: pixelated !important;
    image-rendering: -moz-crisp-edges !important;
    image-rendering: -webkit-crisp-edges !important;
    image-rendering: crisp-edges !important;
    -ms-interpolation-mode: nearest-neighbor !important;
}

/* Règle globale pour tous les éléments img dans la carte */
.leaflet-container img {
    image-rendering: pixelated !important;
    image-rendering: -moz-crisp-edges !important;
    image-rendering: -webkit-crisp-edges !important;
    image-rendering: crisp-edges !important;
    -ms-interpolation-mode: nearest-neighbor !important;
}

/* Export button styles */
#export-png { 
    background: #17a2b8; 
}
#export-png:hover { 
    background: #138496; 
}

#export-tiff { 
    background: #28a745; 
}
#export-tiff:hover { 
    background: #1e7e34; 
}

/* Styles pour le popup de valeur de pixel */
.pixel-value-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pixel-value-popup .leaflet-popup-content {
    margin: 12px 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.pixel-value-popup .leaflet-popup-tip {
    background: white;
}

/* Styles pour l'histogramme interactif */
#histogram {
    cursor: pointer;
}

#histogram:hover {
    opacity: 0.9;
}

/* Animation pour les pixels mis en évidence */
@keyframes highlight-pulse {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

.highlight-overlay {
    animation: highlight-pulse 3s ease-in-out infinite;
    pointer-events: none !important;
    image-rendering: pixelated !important;
    image-rendering: -moz-crisp-edges !important;
    image-rendering: -webkit-crisp-edges !important;
    image-rendering: crisp-edges !important;
    -ms-interpolation-mode: nearest-neighbor !important;
}

.raster-overlay-net.highlighted {
    animation: highlight-pulse 2s ease-in-out infinite;
}

/* Style pour indiquer que l'histogramme est cliquable */
.chart-container {
    position: relative;
}

.chart-container::after {
    content: "💡 Cliquez sur une barre pour superposer les pixels correspondants";
    position: absolute;
    bottom: -20px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 11px;
    color: #666;
    font-style: italic;
}

/* Styles pour les contrôles de seuil personnalisé */
.control-group input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 5px;
}

.control-group input[type="number"]:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

#apply-threshold {
    background: #28a745;
}

#apply-threshold:hover {
    background: #1e7e34;
}

.threshold-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
    padding: 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-top: 10px;
}

/* Styles pour les en-têtes des curseurs avec boutons de verrouillage */
.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.lock-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background-color 0.2s;
    width: auto !important;
    margin-top: 0 !important;
    min-width: 32px;
    height: 28px;
}

.lock-button:hover {
    background: rgba(0, 123, 255, 0.1);
}

.lock-button.locked {
    background: rgba(255, 193, 7, 0.2);
    color: #856404;
}

.lock-button.locked:hover {
    background: rgba(255, 193, 7, 0.3);
}

/* Slider verrouillé - couleur légèrement atténuée */
input[type="range"].locked {
    opacity: 0.6;
    pointer-events: none;
}

.slider-group label {
    flex: 1;
    margin-bottom: 0;
}

/* Slider d'opacité avec style distinct */
#layer-opacity {
    background: linear-gradient(to right, #f8f9fa 0%, #007bff 100%);
    height: 8px;
    border-radius: 4px;
    appearance: none;
    outline: none;
}

#layer-opacity::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#layer-opacity::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Styles pour la modale de tutoriel */
.tutorial-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    overflow-y: auto;
}

.tutorial-modal-content {
    background-color: #fff;
    margin: 2% auto;
    padding: 0;
    width: 90%;
    max-width: 900px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-height: 95vh;
    overflow-y: auto;
}

.tutorial-header {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 20px 30px;
    border-radius: 8px 8px 0 0;
    position: relative;
}

.tutorial-header h1 {
    margin: 0;
    border-bottom: none;
    font-size: 28px;
}

.tutorial-header p {
    margin: 10px 0 0 0;
    opacity: 0.9;
    font-size: 16px;
}

.tutorial-close {
    position: absolute;
    top: 15px;
    right: 25px;
    color: white;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    background: none;
    border: none;
    z-index: 10;
    padding: 0;
    margin: 0;
    width: auto;
    height: auto;
    display: block;
}

.tutorial-close:hover,
.tutorial-close:focus {
    opacity: 0.7;
}

.tutorial-body {
    padding: 30px;
    line-height: 1.6;
}

.tutorial-section {
    margin-bottom: 35px;
}

.tutorial-section h2 {
    color: #007bff;
    border-bottom: 2px solid #007bff;
    padding-bottom: 8px;
    margin-bottom: 20px;
    font-size: 22px;
}

.tutorial-section h3 {
    color: #495057;
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 18px;
}

.tutorial-section h4 {
    color: #6c757d;
    margin-top: 20px;
    margin-bottom: 12px;
    font-size: 16px;
}

.tutorial-section p {
    margin-bottom: 15px;
    text-align: justify;
}

.tutorial-section ul {
    margin-bottom: 15px;
    padding-left: 25px;
}

.tutorial-section li {
    margin-bottom: 8px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.feature-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.feature-card h4 {
    color: #007bff;
    margin-top: 0;
    margin-bottom: 10px;
}

.feature-card p {
    margin-bottom: 0;
    font-size: 14px;
}

.methodology-box {
    background: #e7f3ff;
    border-left: 4px solid #007bff;
    padding: 20px;
    margin: 20px 0;
    border-radius: 0 8px 8px 0;
}

.data-source {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 15px;
    margin: 10px 0;
    border-radius: 6px;
}

.data-source strong {
    color: #007bff;
}

.attribution-box {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    padding: 20px;
    margin: 20px 0;
    border-radius: 8px;
    border-left: 4px solid #ffc107;
}

/* Contact Section */
.contact-section {
    background: #f8fffe;
    border: 1px solid #20c997;
    border-radius: 8px;
    padding: 25px;
    margin: 30px 0;
}

.contact-section h2 {
    color: #20c997 !important;
    border-bottom-color: #20c997 !important;
}

.contact-info {
    margin-top: 20px;
}

.contact-card {
    background: white;
    border: 1px solid #20c997;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(32, 201, 151, 0.1);
}

.contact-card h4 {
    color: #20c997;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
}

.contact-details {
    background: #e6f9f5;
    padding: 15px;
    border-radius: 4px;
    margin-top: 15px;
    border-left: 3px solid #20c997;
}

.contact-details a {
    color: #20c997;
    text-decoration: none;
    font-weight: 500;
}

.contact-details a:hover {
    text-decoration: underline;
}

.contact-note {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
}

.contact-note em {
    color: #6c757d;
    font-weight: 500;
}

.contact-note ul {
    margin-top: 10px;
    margin-bottom: 5px;
}

.contact-note li {
    color: #495057;
    font-size: 14px;
}

.tutorial-footer {
    background: #f8f9fa;
    padding: 20px 30px;
    border-radius: 0 0 8px 8px;
    text-align: center;
    border-top: 1px solid #dee2e6;
}

.btn-tutorial {
    background: #007bff;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin: 5px;
    transition: background-color 0.2s;
}

.btn-tutorial:hover {
    background: #0056b3;
}

.btn-tutorial.secondary {
    background: #6c757d;
}

.btn-tutorial.secondary:hover {
    background: #545b62;
}

/* Responsive design pour la modale */
@media (max-width: 768px) {
    .tutorial-modal-content {
        width: 95%;
        margin: 1% auto;
    }
    
    .tutorial-header {
        padding: 15px 20px;
    }
    
    .tutorial-header h1 {
        font-size: 24px;
    }
    
    .tutorial-body {
        padding: 20px;
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
    }
}

/* Styles d'impression pour le tutoriel */
@media print {
    .tutorial-modal {
        display: block !important;
        position: static;
        background: none;
        overflow: visible;
    }
    
    .tutorial-modal-content {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border-radius: 0;
        max-height: none;
        overflow: visible;
    }
    
    .tutorial-header {
        background: #007bff !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .tutorial-close {
        display: none;
    }
    
    .tutorial-footer {
        display: none;
    }
    
    .tutorial-body {
        padding: 20px;
    }
    
    .feature-grid {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        page-break-inside: avoid;
    }
    
    .tutorial-section {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
    
    .methodology-box,
    .attribution-box {
        page-break-inside: avoid;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* Cacher le reste de l'application lors de l'impression */
    #app-container {
        display: none;
    }
}

/* Améliorations pour l'accessibilité */
.tutorial-modal:focus {
    outline: none;
}

.tutorial-close:focus,
.btn-tutorial:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Animation d'ouverture */
.tutorial-modal {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.tutorial-modal[style*="block"] {
    opacity: 1;
}

.tutorial-modal-content {
    transform: scale(0.9);
    transition: transform 0.3s ease-in-out;
}

.tutorial-modal[style*="block"] .tutorial-modal-content {
    transform: scale(1);
}