/* Full viewport layout */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Navbar offset */
body {
    padding-top: 56px;
}

/* Main app container - flex layout */
.app-container {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

/* Map fills available space */
#map {
    flex: 1;
    min-width: 0;
    background-color: #f0f0f0;
}

/* Sidebar - fixed width on desktop */
.sidebar {
    width: 320px;
    background-color: #fff;
    border-left: 1px solid #dee2e6;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.sidebar-header h5 {
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.5rem;
    word-break: break-word;
}

/* Form in sidebar */
.sidebar-form {
    flex: 1;
}

.sidebar-form .form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #495057;
    margin-bottom: 0.4rem;
}

.sidebar-form .form-control,
.sidebar-form .form-select {
    font-size: 0.9rem;
    border: 1px solid #dee2e6;
}

.sidebar-form .form-control:focus,
.sidebar-form .form-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.sidebar-form button {
    margin-top: 1rem;
    font-weight: 500;
}

/* Status badges */
.badge-actif {
    background-color: #198754;
}

.badge-inactif {
    background-color: #6c757d;
}

.badge-en_attente {
    background-color: #fd7e14;
}

/* Form message alerts */
#formMessage {
    font-size: 0.9rem;
    margin-top: 1rem;
}

/* Leaflet popup styling */
.leaflet-popup-content {
    font-size: 0.9rem;
    font-family: inherit;
}

.leaflet-popup-content p {
    margin: 0.25rem 0;
}

.leaflet-popup-content strong {
    color: #212529;
}

/* Leaflet popup close button */
.leaflet-popup-close-button {
    color: #495057;
    font-weight: bold;
    font-size: 1.2rem;
}

.leaflet-popup-close-button:hover {
    color: #212529;
}

/* Filter select in navbar */
#filterStatus {
    background-color: #495057;
    color: white;
    border-color: #495057;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
}

#filterStatus:focus {
    background-color: #495057;
    color: white;
    border-color: #0d6efd;
}

#filterStatus option {
    color: #212529;
    background-color: white;
}

/* Sidebar toggle button (mobile) */
#sidebarToggle {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
}

/* Sidebar close button (mobile) */
#sidebarClose {
    margin-top: -0.25rem;
}

/* Mobile/Tablet responsiveness */
@media (max-width: 767.98px) {
    /* Hide sidebar on small screens */
    .sidebar {
        position: fixed;
        right: -320px;
        top: 56px;
        height: calc(100vh - 56px);
        width: 320px;
        z-index: 1040;
        transition: right 0.3s ease;
        border-left: none;
        border-right: 1px solid #dee2e6;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    }

    .sidebar.show {
        right: 0;
    }

    .sidebar-close {
        display: block !important;
    }

    #sidebarToggle {
        display: block !important;
    }

    /* Darken map background when sidebar is open */
    .map-overlay {
        position: fixed;
        top: 56px;
        left: 0;
        width: 100%;
        height: calc(100vh - 56px);
        background-color: rgba(0, 0, 0, 0.3);
        z-index: 1039;
        display: none;
    }

    .map-overlay.show {
        display: block;
    }

    /* App container on mobile */
    .app-container {
        flex-direction: column;
    }

    #map {
        height: 100%;
    }

    /* Adjust form for smaller screen */
    .sidebar-form .form-label {
        font-size: 0.85rem;
    }

    .sidebar-form .form-control,
    .sidebar-form .form-select {
        font-size: 0.85rem;
    }
}

/* Medium screens (tablets) */
@media (max-width: 991.98px) {
    .sidebar {
        width: 280px;
    }
}

/* Small sidebar adjustments */
@media (max-width: 575.98px) {
    .sidebar {
        width: 100%;
    }

    .sidebar-header h5 {
        font-size: 1.2rem;
    }

    .sidebar-header {
        margin-bottom: 1rem;
    }

    .sidebar-form .mb-3 {
        margin-bottom: 0.75rem !important;
    }

    .navbar {
        padding: 0.4rem 0;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    #filterStatus {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Leaflet layer group highlight style (applied via JS) */
.leaflet-interactive.highlighted {
    stroke: #0d6efd;
    stroke-width: 4;
}

/* Loading state (if needed) */
.loading {
    opacity: 0.6;
    cursor: wait;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1050;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

@media (max-width: 575.98px) {
    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        margin: 0 auto;
    }
}
