/* Override base template for full-height map */
.content-wrapper { padding-top: 0 !important; }
.content-wrapper > .container-fluid { padding: 0 !important; max-width: 100% !important; }

/* Layout principal */
.map-page {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

/* Panneau latéral (fiche parcelle) */
.sidebar {
    width: 380px;
    min-width: 320px;
    background: white;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: margin-left 0.3s ease;
}
.sidebar.collapsed {
    margin-left: -380px;
}
.sidebar-header {
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}
.sidebar-toggle {
    position: absolute;
    left: 380px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1001;
    background: white;
    border: 1px solid #dee2e6;
    border-left: none;
    border-radius: 0 6px 6px 0;
    padding: 10px 6px;
    cursor: pointer;
    transition: left 0.3s ease;
}
.sidebar.collapsed + .sidebar-toggle {
    left: 0;
}

/* Sections dans la sidebar */
.info-section {
    border-bottom: 1px solid #eee;
    padding: 12px 15px;
}
.info-section:last-child {
    border-bottom: none;
}
.info-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.85rem;
}
.info-row .label {
    color: #6c757d;
}
.info-row .value {
    font-weight: 500;
    text-align: right;
}
.info-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.info-badge.success { background: #d4edda; color: #155724; }
.info-badge.warning { background: #fff3cd; color: #856404; }
.info-badge.danger { background: #f8d7da; color: #721c24; }
.info-badge.info { background: #d1ecf1; color: #0c5460; }

/* Placeholder quand pas de parcelle sélectionnée */
.placeholder-message {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}
.placeholder-message i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Zone carte */
.map-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

/* Panneau de contrôle en haut */
.control-bar {
    background: white;
    border-bottom: 1px solid #dee2e6;
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}
.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.control-group-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #6c757d;
    font-weight: 600;
}
.control-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
}
.control-item input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}
.control-item label {
    cursor: pointer;
    margin: 0;
}
.control-item .badge {
    font-size: 0.75rem;
    padding: 4px 8px;
}

/* Layer category dropdowns */
.layer-categories {
    flex-wrap: wrap;
}
.layer-category {
    position: relative;
}
.layer-category-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    color: #495057;
    white-space: nowrap;
}
.layer-category-btn:hover {
    background: #e9ecef;
    border-color: #ced4da;
}
.layer-category-btn.active {
    background: #e7f1ff;
    border-color: #0d6efd;
    color: #0d6efd;
}
.layer-category-btn i {
    font-size: 0.9rem;
}
.cat-badge {
    font-size: 0.7rem;
    padding: 1px 6px;
    background: #6c757d;
    color: white;
    border-radius: 10px;
    font-weight: 600;
    line-height: 1.4;
}
.cat-badge.has-active {
    background: #0d6efd;
}
.layer-category-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 8px;
    min-width: 220px;
    z-index: 1001;
    flex-direction: column;
    gap: 2px;
}
.layer-category-dropdown.show {
    display: flex;
}
.layer-category-dropdown .control-item {
    padding: 6px 8px;
    border-radius: 4px;
    transition: background 0.1s;
}
.layer-category-dropdown .control-item:hover {
    background: #f8f9fa;
}

/* Carte */
#map-container {
    flex: 1;
    position: relative;
    min-height: 0; /* Fix flex child overflow */
}
#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Légende PLU inline dans la barre de contrôle */
.legend-inline {
    display: flex;
    gap: 12px;
    padding: 4px 10px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.8rem;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.legend-color {
    width: 14px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.2);
}

/* Bandeau info PLUi */
.plui-notice {
    position: absolute;
    bottom: 25px;
    right: 10px;
    z-index: 1000;
    background: rgba(255, 243, 205, 0.95);
    border: 1px solid #ffc107;
    padding: 8px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    font-size: 0.75rem;
    max-width: 280px;
    color: #856404;
}
.plui-notice strong {
    display: block;
    margin-bottom: 4px;
}
.plui-notice a {
    color: #856404;
    text-decoration: underline;
}
.plui-notice .close-notice {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: #856404;
    line-height: 1;
}

/* Marqueur adresse */
.address-marker {
    background: #dc3545;
    border: 2px solid white;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Loader */
.loader {
    text-align: center;
    padding: 20px;
    color: #6c757d;
}
.loader i {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Boutons d'info et tooltips */
.info-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #6c757d;
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    cursor: pointer;
    margin-left: 4px;
    vertical-align: middle;
}
.info-help:hover {
    background: #0d6efd;
}
.info-detail {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 8px 10px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: #495057;
    line-height: 1.4;
}
.info-detail ul {
    margin: 4px 0 0 0;
    padding-left: 18px;
}
.info-detail li {
    margin-bottom: 2px;
}
.risk-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.risk-tag {
    display: inline-block;
    padding: 2px 6px;
    background: #fff3cd;
    color: #856404;
    border-radius: 3px;
    font-size: 0.75rem;
}
.risk-tag.danger {
    background: #f8d7da;
    color: #721c24;
}

/* Modale de consentement */
.consent-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.consent-overlay.hidden {
    display: none;
}
.consent-modal {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
    text-align: center;
}
@keyframes slideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.consent-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}
.consent-icon i {
    font-size: 2rem;
    color: white;
}
.consent-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 12px;
}
.consent-text {
    color: #495057;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 24px;
}
.consent-text strong {
    color: #0d6efd;
}
.consent-features {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
}
.consent-features-title {
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 10px;
    font-size: 0.9rem;
}
.consent-features ul {
    margin: 0;
    padding-left: 20px;
    color: #495057;
    font-size: 0.85rem;
}
.consent-features li {
    margin-bottom: 6px;
}
.consent-features li i {
    color: #198754;
    margin-right: 6px;
}
.consent-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.consent-btn {
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.consent-btn-register {
    background: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
    color: white;
}
.consent-btn-register:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.4);
}
.consent-btn-accept {
    background: #198754;
    color: white;
}
.consent-btn-accept:hover {
    background: #157347;
    transform: translateY(-1px);
}
.consent-btn-refuse {
    background: transparent;
    color: #6c757d;
    border: 1px solid #dee2e6;
}
.consent-btn-refuse:hover {
    background: #f8f9fa;
}
.consent-note {
    margin-top: 16px;
    font-size: 0.75rem;
    color: #6c757d;
}

/* Bannière mode limité (après refus) */
.limited-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
    z-index: 9999;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    border-top: 2px solid #ffc107;
    animation: slideUpBanner 0.4s ease-out;
}
@keyframes slideUpBanner {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.limited-banner.hidden {
    display: none;
}
.limited-banner-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.limited-banner-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}
.limited-banner-text {
    flex: 1;
    min-width: 200px;
    color: #856404;
    font-size: 0.9rem;
}
.limited-banner-text strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 2px;
}
.limited-banner-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.limited-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.limited-btn-accept {
    background: #198754;
    color: white;
}
.limited-btn-accept:hover {
    background: #157347;
}
.limited-btn-register {
    background: #0d6efd;
    color: white;
}
.limited-btn-register:hover {
    background: #0b5ed7;
}
.limited-btn-close {
    background: transparent;
    color: #856404;
    padding: 8px;
}
.limited-btn-close:hover {
    background: rgba(0,0,0,0.1);
}

/* Compteur de visiteurs */
.visitor-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #f8f9fa;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #495057;
}
.visitor-counter i {
    color: #6c757d;
}
.visitor-counter #visitor-count {
    font-weight: 700;
    color: #0d6efd;
}

/* Contrôles de zoom personnalisés */
.custom-zoom-control {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    padding: 4px;
}
.zoom-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #495057;
    transition: all 0.15s;
}
.zoom-btn:hover {
    background: #e9ecef;
    color: #212529;
}
.zoom-btn:active {
    background: #dee2e6;
    transform: scale(0.95);
}
.zoom-btn.home-btn {
    color: #0d6efd;
    border-top: 1px solid #eee;
    margin-top: 2px;
    padding-top: 2px;
}
.zoom-btn.home-btn:hover {
    background: #e7f1ff;
    color: #0a58ca;
}
.zoom-btn.home-btn.disabled {
    color: #adb5bd;
    cursor: not-allowed;
}
.zoom-btn.home-btn.disabled:hover {
    background: white;
}
.zoom-separator {
    height: 1px;
    background: #dee2e6;
}

/* Panneau recherche d'adresse (flottant gauche) */
.address-search-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    padding: 10px;
    width: 300px;
    max-width: calc(100vw - 80px);
}
.address-search-panel .search-row {
    display: flex;
    gap: 6px;
}
.address-search-panel input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.9rem;
}
.address-search-panel input[type="text"]:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}
.address-search-panel .search-btn {
    padding: 8px 12px;
    background: #0d6efd;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
}
.address-search-panel .search-btn:hover {
    background: #0a58ca;
}
.address-search-panel .search-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}
.address-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-top: -6px;
    padding-top: 6px;
}
.address-search-dropdown.show {
    display: block;
}
.address-search-dropdown .dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
}
.address-search-dropdown .dropdown-item:last-child {
    border-bottom: none;
}
.address-search-dropdown .dropdown-item:hover,
.address-search-dropdown .dropdown-item.active {
    background: #e7f1ff;
}
.address-search-dropdown .dropdown-item .address-main {
    font-weight: 500;
    color: #212529;
}
.address-search-dropdown .dropdown-item .address-context {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 2px;
}
.address-search-panel .option-row {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #495057;
}
.address-search-panel .option-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.address-search-panel .option-row label {
    cursor: pointer;
    margin: 0;
}
.address-search-panel .help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #6c757d;
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    cursor: help;
    margin-left: 2px;
}
.address-search-panel .help-icon:hover {
    background: #0d6efd;
    margin: 2px 4px;
}

/* Responsive Mobile */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        z-index: 1050;
        width: 100%;
        max-width: 350px;
    }
    .sidebar.collapsed {
        margin-left: -100%;
    }
    .sidebar-toggle {
        left: 0;
        top: auto;
        bottom: 80px;
        transform: none;
        border-radius: 0 6px 6px 0;
    }
    .sidebar:not(.collapsed) + .sidebar-toggle {
        left: 350px;
    }
}

@media (max-width: 767.98px) {
    .control-bar {
        padding: 8px 10px;
        gap: 8px;
        flex-direction: column;
        align-items: stretch;
    }
    .control-group-title {
        display: none;
    }
    .control-bar > .control-group:first-of-type {
        order: 2;
    }
    .control-bar > .control-group:first-of-type select {
        font-size: 0.8rem !important;
        padding: 4px 8px;
    }
    /* Layer category buttons: icon + badge only */
    .layer-categories {
        order: 3;
        gap: 6px;
    }
    .layer-category-btn {
        padding: 5px 8px;
        font-size: 0.8rem;
    }
    .layer-category-btn .cat-label {
        display: none;
    }
    .layer-category-dropdown {
        min-width: 200px;
    }
    .layer-category-dropdown .control-item {
        font-size: 0.85rem;
    }
    /* Légende PLU */
    .legend-inline {
        order: 4;
        display: none;
    }
    .legend-inline.show {
        display: flex;
    }
    .legend-bar {
        font-size: 0.7rem;
        padding: 5px 10px;
    }
    /* Notice PLUi plus compacte */
    .plui-notice {
        font-size: 0.75rem;
        padding: 8px 12px;
        max-width: 200px;
    }
}

/* Très petits écrans */
@media (max-width: 400px) {
    .control-bar {
        padding: 6px 8px;
        gap: 6px;
    }
    .layer-category-btn {
        padding: 4px 6px;
    }
    .cat-badge {
        font-size: 0.65rem;
        padding: 1px 4px;
    }
}
