/**
 * Styles communs à toutes les pages
 * Les pages de connexion (index.php, reset-password.php) ajoutent css/connexion.css.
 * Couleurs de l'app : variables --app-primaire et --app-secondaire, déclarées par chaque page
 * depuis APP_PRIMARY_COLOR et APP_SECONDARY_COLOR (api/config/constants.php).
 */

/* === CARTE === */
#map {
    width: 100%;
    height: 100vh;
    z-index: 1;
    background: #fff;
}

/* === BARRE LATÉRALE (comme acces_eau) === */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 350px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

#sidebar.collapsed {
    transform: translateX(-350px);
}

.sidebar-titre {
    font-size: 1.3rem;
    color: var(--app-secondaire);
}

.sidebar-sous-titre {
    font-size: 0.9rem;
    color: #555;
}

#sidebar-open-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 999;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px 15px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    font-size: 1.5rem;
    line-height: 1;
}

#sidebar-open-btn:hover {
    background: #f8f9fa;
}

.accordion-button:not(.collapsed) {
    color: #333;
}

@media (max-width: 768px) {
    #sidebar {
        width: 100%;
    }

    #sidebar.collapsed {
        transform: translateX(-100%);
    }
}

/* === JAUGES D'OPACITÉ DES FONDS DE CARTE === */
.basemap-opacity {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #555;
    cursor: pointer;
}

.basemap-opacity::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #0d6efd;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    margin-top: -5px;
}

.basemap-opacity::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #0d6efd;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.basemap-opacity::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: #555;
}

.basemap-opacity::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: #555;
}

/* === LÉGENDES DE CARTE (ex. Corine Land Cover) === */
#legends-container {
    position: absolute;
    bottom: 60px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 75vh;
    overflow-y: auto;
}

.map-legend {
    position: relative;
    background: white;
    padding: 15px;
    padding-top: 25px;
    border: 2px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    max-width: 300px;
}

.map-legend .btn-close-legend {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 0.75rem;
}

.legend-title {
    font-weight: bold;
}

.clc-legend {
    font-size: 0.75rem;
}

.clc-category {
    margin-bottom: 8px;
}

.clc-category-title {
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid #ddd;
}

.clc-item {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
    line-height: 1.2;
}

.clc-color {
    width: 16px;
    height: 12px;
    min-width: 16px;
    margin-right: 6px;
    border: 1px solid #ccc;
}

.clc-label {
    color: #333;
}

/* === BOUTONS DE CARTE (plein écran, zoom par emprise) : icônes SVG en data URI === */
.leaflet-bar a.bouton-carte {
    display: block;
    width: 30px;
    height: 30px;
    cursor: pointer;
    background-color: #fff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 16px;
}

.leaflet-bar a.bouton-carte:hover {
    background-color: #f4f4f4;
}

.leaflet-bar a.bouton-plein-ecran {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4' fill='none' stroke='%23333' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.leaflet-bar a.bouton-plein-ecran.actif {
    background-color: #3498db;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M6 2v4H2M10 6h4V2M14 10h-4v4M2 14h4v-4' fill='none' stroke='%23fff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.leaflet-bar a.bouton-zoom-emprise {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Crect x='1' y='1' width='14' height='14' rx='1' fill='none' stroke='%23333' stroke-width='1.5' stroke-dasharray='3 2'/%3E%3Cpath d='M4 1V0M12 1V0M4 15v1M12 15v1M1 4H0M1 12H0M15 4h1M15 12h1' stroke='%23333' stroke-width='1.2'/%3E%3C/svg%3E");
}

.leaflet-bar a.bouton-zoom-emprise.actif {
    background-color: #3498db;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Crect x='1' y='1' width='14' height='14' rx='1' fill='none' stroke='%23fff' stroke-width='1.5' stroke-dasharray='3 2'/%3E%3Cpath d='M4 1V0M12 1V0M4 15v1M12 15v1M1 4H0M1 12H0M15 4h1M15 12h1' stroke='%23fff' stroke-width='1.2'/%3E%3C/svg%3E");
}

/* === TOAST CONTAINER === */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9998;
    min-width: 300px;
}

/* === LEAFLET POPUP === */
.leaflet-popup-content {
    margin: 10px;
}

.leaflet-popup-content h6 {
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
    text-align: center;
}

.leaflet-popup-content .popup-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 0.82rem;
}

.leaflet-popup-content .popup-table td {
    padding: 4px 6px;
    vertical-align: top;
    border-bottom: 1px solid #eee;
}

.leaflet-popup-content .popup-table td:first-child {
    font-weight: 600;
    color: #555;
    white-space: nowrap;
    padding-right: 12px;
}

.leaflet-popup-content .popup-table tr:last-child td {
    border-bottom: none;
}

/* === CONTRÔLE UTILISATEUR (Leaflet) === */
.user-control {
    background: white;
    padding: 8px 12px;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
    font-size: 0.85rem;
}

.user-control .user-buttons {
    display: flex;
    gap: 6px;
}

.user-control .user-details {
    color: #666;
    font-size: 0.8rem;
}

.user-control .user-email {
    color: #333;
}

.user-control .user-role {
    margin-left: 6px;
}

.user-control .btn-logout,
.user-control .btn-admin,
.user-control #btn-change-pwd {
    padding: 2px 8px;
    font-size: 0.75rem;
}

/* === BOUTONS AUX COULEURS DE L'APP (pages Bootstrap) === */
.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:disabled {
    background-color: var(--app-secondaire, #18bc9c);
    border-color: var(--app-secondaire, #18bc9c);
}

.btn-primary:hover {
    filter: brightness(0.9);
}

.btn-primary:disabled {
    opacity: 0.6;
}

/* === RÈGLES DE MOT DE PASSE (reset-password.php, modale de app.php) ===
   Le symbole vient UNIQUEMENT d'ici (::before) : ne rien écrire dans .rule-icon côté HTML. */
.regles-mdp {
    list-style: none;
    padding-left: 0;
    margin: 6px 0 0;
    font-size: 0.85rem;
}

.regles-mdp li {
    padding: 2px 0;
}

.regles-mdp .rule-icon {
    display: inline-block;
    width: 16px;
    margin-right: 5px;
}

.regles-mdp li .rule-icon::before {
    content: "○";
    color: #6c757d;
}

.regles-mdp li.valid {
    color: #198754;
}

.regles-mdp li.valid .rule-icon::before {
    content: "✓";
    color: inherit;
}

.regles-mdp li.invalid {
    color: #dc3545;
}

.regles-mdp li.invalid .rule-icon::before {
    content: "✗";
    color: inherit;
}

/* === VALIDATION DES CHAMPS (Bootstrap) === */
.form-control.is-valid {
    border-color: #198754;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.is-invalid {
    border-color: #dc3545;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

/* === BADGES === */
.badge-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}
