/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Layout principal */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

/* Panneaux */
.search-panel, .results-panel {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.search-panel {
    background: rgba(255,255,255,0.95);
}

.results-panel {
    background: rgba(255,255,255,0.95);
}

/* Formulaire */
#searchForm {
    margin-bottom: 25px;
}

/* Sélecteur de mode de recherche */
.search-mode-selector {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.search-mode-selector h3 {
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.1rem;
}

.mode-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mode-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-option:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.mode-option input[type="radio"] {
    margin: 0;
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.mode-option input[type="radio"]:checked + span {
    color: #667eea;
    font-weight: 600;
}

.mode-option span {
    font-weight: 500;
    color: #495057;
    margin-bottom: 5px;
    display: block;
}

.mode-option small {
    color: #6c757d;
    font-size: 13px;
    line-height: 1.4;
    display: block;
}

.mode-option input[type="radio"]:checked ~ small {
    color: #495057;
}

/* Champs spécifiques au mode proximité */
.proximity-fields {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 15px;
    background: #e8f4fd;
    border-radius: 8px;
    border-left: 3px solid #007bff;
    margin-bottom: 15px;
}

.proximity-fields .field-group label {
    color: #0056b3;
    font-weight: 600;
}

.proximity-fields .distance-input input {
    border-color: #007bff;
}

.proximity-fields .distance-input input:focus {
    border-color: #0056b3;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.conditions-container {
    margin-bottom: 20px;
}

.condition-group {
    margin-bottom: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.condition-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.condition-number {
    font-weight: bold;
    color: #667eea;
    font-size: 1.1rem;
}

.remove-condition {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.remove-condition:hover {
    background: #c82333;
    transform: scale(1.1);
}

.condition-fields {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-group label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.field-group select,
.field-group input {
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.field-group select:focus,
.field-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.field-group input:disabled {
    background: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

/* Types container avec cases à cocher */
.types-container {
    max-height: 120px;
    overflow-y: auto;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    background: white;
}

.types-container.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
}

.no-types {
    color: #6c757d;
    font-style: italic;
    margin: 0;
    text-align: center;
}

.type-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.type-checkbox:hover {
    background-color: #f8f9fa;
}

.type-checkbox input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
}

.type-checkbox label {
    margin: 0;
    cursor: pointer;
    font-weight: normal;
    font-size: 13px;
    flex: 1;
}

/* Recherche par nom */
.name-search {
    display: flex;
    gap: 10px;
    align-items: center;
}

.name-search select {
    min-width: 140px;
}

.name-search input {
    flex: 1;
}

/* Distance avec unité */
.distance-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.distance-input input {
    flex: 1;
    max-width: 150px;
}

.distance-input .unit {
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
}

/* Contrôles */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.operators {
    display: flex;
    gap: 10px;
}

/* Boutons */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-operator {
    background: #17a2b8;
    color: white;
    min-width: 50px;
    justify-content: center;
}

/* Section requête */
.query-section {
    margin-top: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.query-section h3 {
    margin-bottom: 15px;
    color: #495057;
}

.query-display {
    background: #2d3748;
    color: #e2e8f0;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 100px;
    margin-bottom: 15px;
    border: 1px solid #4a5568;
}

/* Carte */
.map-container {
    margin-bottom: 25px;
}

.map-container h3 {
    margin-bottom: 15px;
    color: #495057;
}

/* Recherche d'adresse */
.address-search {
    position: relative;
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

.address-search input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.address-search input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.address-search button {
    padding: 10px 15px;
    min-width: auto;
}

.address-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 50px;
    background: white;
    border: 2px solid #e9ecef;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.address-suggestion {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.2s ease;
}

.address-suggestion:hover {
    background-color: #f8f9fa;
}

.address-suggestion:last-child {
    border-bottom: none;
}

.address-suggestion .suggestion-name {
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
}

.address-suggestion .suggestion-details {
    font-size: 12px;
    color: #6c757d;
}

#map {
    height: 400px;
    border-radius: 10px;
    border: 2px solid #e9ecef;
}

.map-info {
    margin-top: 10px;
    padding: 10px;
    background: #e3f2fd;
    border-radius: 8px;
    font-size: 14px;
    color: #1565c0;
}

/* Informations résultats */
.results-info {
    margin-bottom: 25px;
}

.results-count {
    padding: 15px;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    color: #155724;
    font-weight: bold;
    text-align: center;
}

.loading {
    padding: 15px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    color: #856404;
    text-align: center;
    font-weight: bold;
}

.loading i {
    margin-right: 10px;
}

/* Liste des résultats */
.results-list {
    margin-bottom: 25px;
}

.results-list h4 {
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.1rem;
}

/* Sections séparées des résultats */
.main-results-section {
    margin-bottom: 30px;
}

.complement-results-section {
    margin-bottom: 25px;
}

.main-results-section h4 {
    color: #2196f3;
    font-weight: 600;
    border-left: 4px solid #2196f3;
    padding-left: 12px;
    margin-bottom: 15px;
}

.complement-results-section h4 {
    color: #ff9800;
    font-weight: 600;
    border-left: 4px solid #ff9800;
    padding-left: 12px;
    margin-bottom: 15px;
}

.results-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: white;
}

#resultsTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#resultsTable thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

#resultsTable th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
}

#resultsTable td {
    padding: 10px 8px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
}

#resultsTable tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#resultsTable tbody tr:hover {
    background-color: #f8f9fa;
}

#resultsTable tbody tr.selected {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.result-name {
    font-weight: 600;
    color: #495057;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-type {
    color: #6c757d;
    font-size: 13px;
}

.result-category {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #007bff;
    background: #f8f9ff;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.result-coords {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
}

.result-role {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    text-align: center;
}

.result-actions {
    display: flex;
    gap: 5px;
    align-items: center;
}

.result-actions .btn {
    padding: 4px 8px;
    font-size: 12px;
    min-width: auto;
}

.zoom-btn {
    background: #17a2b8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    background: #138496;
    transform: scale(1.05);
}

.external-link {
    color: #6c757d;
    text-decoration: none;
    font-size: 12px;
    transition: color 0.2s ease;
}

.external-link:hover {
    color: #495057;
}

/* Section export */
.export-section h3 {
    margin-bottom: 15px;
    color: #495057;
}

.export-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Opérateurs logiques */
.logic-operator {
    display: inline-block;
    padding: 5px 10px;
    background: #17a2b8;
    color: white;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    margin: 5px;
}

.logic-operator.and {
    background: #28a745;
}

.logic-operator.or {
    background: #ffc107;
    color: #212529;
}

.logic-operator.paren {
    background: #6f42c1;
}

/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .condition-fields {
        grid-template-columns: 1fr;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .operators {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    #map {
        height: 300px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .search-panel, .results-panel {
        padding: 15px;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 13px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.condition-group {
    animation: fadeIn 0.3s ease;
}

/* Scrollbar personnalisée */
.query-display::-webkit-scrollbar {
    width: 8px;
}

.query-display::-webkit-scrollbar-track {
    background: #4a5568;
    border-radius: 4px;
}

.query-display::-webkit-scrollbar-thumb {
    background: #718096;
    border-radius: 4px;
}

.query-display::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Tooltips */
[title] {
    position: relative;
}

/* États de validation */
.condition-fields select:invalid,
.condition-fields input:invalid {
    border-color: #dc3545;
}

.condition-fields select:valid,
.condition-fields input:valid {
    border-color: #28a745;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.leaflet-popup-content {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.4;
}

/* Indicateur de chargement pour la carte */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.9);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    z-index: 1000;
}

/* Messages d'erreur */
.error-message {
    padding: 15px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    color: #721c24;
    margin: 10px 0;
}

.success-message {
    padding: 15px;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    color: #155724;
    margin: 10px 0;
}

/* Amélioration de l'accessibilité */
.btn:focus,
select:focus,
input:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    body {
        background: white;
    }
    
    .search-panel, .results-panel {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .btn {
        display: none;
    }
    
    #map {
        height: 300px;
        border: 1px solid #ddd;
    }
}
