/* Variables CSS globales - Thème Archéologie */
:root {
    --primary-color: #8B7355;
    --primary-hover: #6F5B45;
    --secondary-color: #5D4E37;
    --accent-color: #CD853F;
    --success-color: #6B8E23;
    --error-color: #A0522D;
    --warning-color: #DAA520;
    --background-color: #FAF8F3;
    --surface-color: #FFFFFF;
    --border-color: #D4C4B0;
    --text-color: #3E2723;
    --text-muted: #6D5D4B;
    --shadow: 0 2px 4px rgba(94, 78, 55, 0.1);
    --shadow-lg: 0 10px 25px rgba(94, 78, 55, 0.15);
}

/* Reset et styles de base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    letter-spacing: 0.01em;
}

/* Layout principal */
#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1.25rem 0;
    box-shadow: var(--shadow-lg);
}

.header-content {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 2rem;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.logo {
    width: 96px;
    height: 96px;
    /* background: white;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); */
}

.title-group h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
    margin: 0;
    font-weight: 400;
}

.header-info {
    display: flex;
    gap: 1rem;
    flex-wrap: nowrap;
    align-items: center;
    flex-shrink: 0;
}

.zone-selector {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zone-selector label {
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0;
}

.zone-select {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
    color: var(--text-color);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.zone-select:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.zone-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* Sélecteur de méthode */
.method-selector {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.method-selector label {
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0;
}

.method-select {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
    color: var(--text-color);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.method-select:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.method-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* Sélecteur de palette */
.palette-select {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface-color);
    color: var(--text-color);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.palette-select:hover {
    border-color: var(--accent-color);
}

.palette-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 115, 85, 0.1);
}

/* Style générique pour les select */
.select {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface-color);
    color: var(--text-color);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.select:hover {
    border-color: var(--accent-color);
}

.select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 115, 85, 0.1);
}

.location-badge,
.method-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Panneau de contrôle */
.control-panel {
    width: 380px;
    background: var(--surface-color);
    border-right: 2px solid var(--border-color);
    padding: 0;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.panel-header {
    background: linear-gradient(to bottom, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1.5rem;
    border-bottom: 3px solid var(--accent-color);
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.panel-description {
    font-size: 0.875rem;
    opacity: 0.9;
    margin: 0;
}

.section {
    margin: 0;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.section:last-child {
    border-bottom: none;
}

.section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
}

.section-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: -0.5rem 0 1rem 0;
    line-height: 1.4;
}

.section-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: -0.5rem 0 1rem 0;
    font-style: italic;
}

/* Zones de contraintes */
.constraints-list {
    margin-top: 0.75rem;
    max-height: 150px;
    overflow-y: auto;
}

.constraint-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--background-color);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.constraint-item-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
}

.constraint-icon {
    width: 16px;
    height: 16px;
    background: rgba(128, 128, 128, 0.5);
    border: 2px solid rgba(96, 96, 96, 0.8);
    border-radius: 2px;
}

.constraint-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    color: var(--error-color);
    opacity: 0.6;
    transition: opacity 0.2s;
}

.constraint-delete:hover {
    opacity: 1;
}

/* Points de navigation */
.point-info {
    margin-bottom: 1rem;
}

.point-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background: var(--background-color);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    transition: all 0.2s;
}

.point-item:hover {
    border-color: var(--accent-color);
    box-shadow: 0 2px 6px rgba(139, 115, 85, 0.15);
}

.point-marker {
    font-size: 1rem;
    margin-right: 0.75rem;
    width: 20px;
}

.point-item div {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Paramètres */
.parameter {
    margin-bottom: 1rem;
}

.parameter label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.parameter input[type="range"] {
    width: 100%;
    margin-bottom: 0.25rem;
}

.parameter span {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--accent-color);
    background: var(--background-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    min-width: 40px;
    display: inline-block;
    text-align: center;
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-color));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 115, 85, 0.3);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

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

.btn-secondary:hover {
    background-color: var(--warning-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(205, 133, 63, 0.3);
}

/* Groupe de boutons */
.button-group {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.button-group .btn-primary {
    flex: 1;
}

.button-group .btn-secondary {
    flex: 0 0 auto;
    min-width: 50px;
    max-width: 50px;
    padding: 0.75rem 0.5rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Bouton de bascule 3D */
.btn-toggle {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    font-size: 0.85rem;
    padding: 0.75rem 1.25rem;
}

.btn-toggle:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-toggle.active {
    background: linear-gradient(135deg, #10b981, #059669);
}

.btn-toggle.active:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

/* Conteneur de bascule de vue */
.view-toggle {
    margin-bottom: 1rem;
}

/* Contrôles 3D */
.controls-3d {
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    transition: all 0.3s ease;
}

.controls-3d.hidden {
    display: none;
}

.controls-3d .parameter {
    margin-bottom: 0.75rem;
}

.controls-3d .parameter:last-child {
    margin-bottom: 0;
}

/* Animation de chargement */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    color: var(--text-muted);
}

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

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

/* Résultats */
.results {
    background: linear-gradient(to bottom right, var(--background-color), #FFF8F0);
    border-radius: 8px;
    padding: 1.25rem;
    border: 2px solid var(--accent-color);
    box-shadow: var(--shadow);
}

.result-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: white;
    border-radius: 6px;
    border-left: 3px solid var(--accent-color);
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-item .label {
    font-weight: 600;
    color: var(--text-color);
}

.result-item span:last-child {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.05rem;
}

/* Profil altimétrique */
.elevation-profile {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    border: 2px solid var(--accent-color);
    box-shadow: var(--shadow);
    margin-top: 0.5rem;
}

.elevation-profile canvas {
    max-height: 200px;
    width: 100% !important;
}

/* Conteneur de carte */
.map-container {
    flex: 1;
    position: relative;
    background: var(--background-color);
}

#map {
    width: 100%;
    height: 100%;
}

.map-instructions {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(255, 255, 255, 0.97);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    color: var(--text-color);
    z-index: 1000;
    border: 2px solid var(--accent-color);
    max-width: 300px;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    transition: opacity 0.3s ease;
}

.instruction-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.map-legend {
    position: absolute;
    bottom: 2rem;
    left: 1rem;
    background: rgba(255, 255, 255, 0.97);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    color: var(--text-color);
    z-index: 1000;
    border: 2px solid var(--border-color);
}

.legend-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.25rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.legend-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.legend-marker.start {
    background: #10b981;
}

.legend-marker.end {
    background: #ef4444;
}

.legend-line {
    width: 30px;
    height: 4px;
    background: #10b981;
    border-radius: 2px;
}

.legend-water-flow {
    width: 30px;
    height: 4px;
    background: #3b82f6;
    border-radius: 2px;
}

.legend-constraint {
    width: 30px;
    height: 20px;
    background: rgba(128, 128, 128, 0.5);
    border: 2px solid rgba(96, 96, 96, 0.8);
    border-radius: 2px;
}

/* Points de dessin de contrainte */
.constraint-point {
    width: 12px;
    height: 12px;
    background: #ef4444;
    border: 2px solid white;
    border-radius: 50%;
    cursor: move;
    font-size: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.constraint-point:hover {
    transform: scale(1.3);
    background: #dc2626;
}

/* Marqueurs personnalisés sur la carte */
.custom-marker {
    transition: transform 0.2s ease;
}

.custom-marker:hover {
    transform: scale(1.2);
}

.custom-marker.start-marker {
    background-color: #10b981 !important;
}

.custom-marker.end-marker {
    background-color: #ef4444 !important;
}

/* Marqueurs multi-points */
.custom-marker.multi-start-marker {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 10px;
    font-weight: bold;
    line-height: 1;
}

/* Messages d'erreur */
.error-message {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--error-color);
    color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    max-width: 400px;
    border: 3px solid #8B4513;
}

.error-content {
    display: flex;
    align-items: center;
    padding: 1rem;
}

.error-icon {
    margin-right: 0.75rem;
    font-size: 1.25rem;
}

.close-error {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    margin-left: auto;
    padding: 0.25rem;
    border-radius: 0.25rem;
    opacity: 0.8;
}

.close-error:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

/* Footer */
.footer {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 2rem;
    border-top: 3px solid var(--accent-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.footer p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.8;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.footer .heart-icon {
    width: 16px;
    height: 16px;
    color: #ff6b6b;
    vertical-align: text-bottom;
    display: inline-block;
}

.footer .footer-logo {
    vertical-align: middle;
    display: inline-block;
    transition: opacity 0.2s;
}

.footer .footer-logo:hover {
    opacity: 0.8;
}

.footer a {
    color: white;
    text-decoration: none;
    transition: opacity 0.2s;
}

.footer a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.footer .footer-contact {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.footer .version-info {
    display: inline-block;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
}

.footer-section {
    opacity: 0.95;
}

.footer-section strong {
    font-weight: 600;
}

/* Classes utilitaires */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    
    .control-panel {
        width: 100%;
        max-height: 50vh;
    }
    
    .map-container {
        min-height: 50vh;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-info {
        width: 100%;
    }
    
    .logo {
        width: 50px;
        height: 50px;
    }
    
    .title-group h1 {
        font-size: 1.5rem;
    }
    
    .map-legend {
        bottom: 0.5rem;
        left: 0.5rem;
        font-size: 0.75rem;
        padding: 0.75rem;
    }
    
    .map-instructions {
        max-width: calc(100% - 2rem);
        font-size: 0.8rem;
        padding: 0.75rem 1rem;
    }
    
    .footer-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Styles pour les marqueurs MapLibre */
.maplibregl-marker {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.maplibregl-marker:hover {
    transform: scale(1.1);
}

/* Popup styles */
.maplibregl-popup-content {
    padding: 1rem;
    font-size: 0.875rem;
    border-radius: 8px;
    border: 2px solid var(--accent-color);
    box-shadow: var(--shadow-lg);
}

.maplibregl-popup-close-button {
    font-size: 1.25rem;
    padding: 0.5rem;
    color: var(--primary-color);
}

/* Animations d'apparition */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results:not(.hidden) {
    animation: fadeIn 0.3s ease-out;
}

.error-message:not(.hidden) {
    animation: fadeIn 0.3s ease-out;
}

/* Effet de survol sur les sections */
.section:hover {
    background: rgba(139, 115, 85, 0.02);
}

/* Style pour les checkboxes */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Style pour les range inputs */
input[type="range"] {
    accent-color: var(--primary-color);
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    cursor: grab;
}

input[type="range"]:active::-webkit-slider-thumb {
    cursor: grabbing;
}

/* Contrôle de sélection des fonds de carte */
.base-layer-control {
    background: white;
    border-radius: 4px;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.base-layer-btn {
    background: white;
    border: none;
    border-radius: 4px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 29px;
    height: 29px;
    transition: background-color 0.2s;
}

.base-layer-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.base-layer-btn svg {
    display: block;
    width: 20px;
    height: 20px;
    color: #333;
    margin: 0 auto;
}

.base-layer-menu {
    position: absolute;
    top: 0;
    right: 100%;
    margin-right: 8px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    min-width: 240px;
    padding: 8px 0;
    z-index: 10;
}

.base-layer-option {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.base-layer-option:hover {
    background-color: rgba(139, 115, 85, 0.1);
}

.base-layer-option input[type="radio"] {
    cursor: pointer;
    margin: 0;
    width: 16px;
    height: 16px;
}

.base-layer-option label {
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-color);
    margin: 0;
    flex: 1;
}

.base-layer-option input[type="radio"]:checked + label {
    font-weight: 600;
    color: var(--primary-color);
}