:root {
    --primary: #0078d4;
    --primary-dark: #0056a3;
    --danger: #dc3545;
    --bg: #f4f6f8;
    --card-bg: #fff;
    --text: #333;
    --radius: 14px;
}

body {
    font-family: "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    margin: 0;
    color: var(--text);
}

header {
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

header h1 {
    margin: 0;
    font-size: 1.8em;
}

.logout {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius);
    text-decoration: none;
    transition: 0.3s;
}

.logout:hover { background: rgba(255,255,255,0.4); }

main {
    padding: 30px;
    max-width: 1200px;
    margin: auto;
}

.chantier-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: 0.3s;
}

.btn-primary:hover { background: var(--primary-dark); }

.chantier-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.chantier-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chantier-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 12px rgba(0,0,0,0.2);
}

.chantier-card h3 {
    margin: 0 0 10px;
}

.chantier-card p {
    flex-grow: 1;
}

.chantier-actions {
    margin-top: 15px;
}

.btn, .btn-danger {
    padding: 8px 12px;
    border-radius: var(--radius);
    text-decoration: none;
    margin-right: 5px;
    transition: 0.3s;
    display: inline-block;
}

.btn {
    background: #e9ecef;
    color: #333;
}

.btn:hover {
    background: #d6d8db;
}

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

.btn-danger:hover {
    background: #b52b38;
}

/* MODAL */
.modal {
	z-index: 10000; /* Valeur très élevée (par défaut Leaflet utilise souvent 400 ou plus) */
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

input, textarea {
    width: 100%;
    padding: 10px;
    margin: 8px 0 16px;
    border: 1px solid #ccc;
    border-radius: var(--radius);
    font-size: 1em;
}

@media (max-width: 600px) {
    header h1 { font-size: 1.3em; }
    .chantier-card { padding: 15px; }
}

.chantier-details {
    background: white;
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.map {
    height: 300px;
    border-radius: var(--radius);
    margin-bottom: 25px;
}

.photo-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* --- Galerie / Lightbox / Map additions (Metro UI compatible) --- */
.photo-grid { display:grid; grid-template-columns: repeat(auto-fill,minmax(180px,1fr)); gap:12px; }
.photo-card { background:#fff; border-radius:10px; overflow:hidden; box-shadow:0 6px 18px rgba(0,0,0,0.06); }
.photo-card img{ width:100%; height:160px; object-fit:cover; cursor:pointer; display:block; }
.photo-card .meta { padding:10px; font-size:0.95rem; color:#222; }

/* Lightbox */
.lightbox { position:fixed; inset:0; background:rgba(0,0,0,0.85); display:none; align-items:center; justify-content:center; z-index:9999; }
.lightbox .inner { display:flex; gap:14px; align-items:flex-start; max-width:95%; max-height:95%; }
.lightbox img { max-width:70vw; max-height:80vh; border-radius:8px; }

/* Map */
.map { height:320px; border-radius:10px; overflow:hidden; margin-bottom:10px; }

/* Buttons Metro style */
.btn-primary { background:var(--primary); color:#fff; padding:10px 14px; border-radius:8px; border:none; cursor:pointer; }
.btn { background:#f1f3f5; color:#222; padding:8px 12px; border-radius:8px; border:none; cursor:pointer; }
.btn-danger { background:#dc3545; color:#fff; padding:8px 12px; border-radius:8px; border:none; cursor:pointer; }

/* Responsive */
@media(max-width:700px){
  .photo-card img{ height:140px; }
  .lightbox img{ max-width:90vw; }
}

/* CSS OBLIGATOIRE POUR L'AFFICHAGE DE LA CARTE */
#chantierMap {
	height: 500px; /* C'est souvent l'oubli : SANS HAUTEUR, LA CARTE NE S'AFFICHE PAS ! */
	width: 100%;
	margin-bottom: 20px;
	border: 1px solid #ccc;
}
		

/* Nouveaux styles pour l'icône d'appareil photo avec champ de vision */
    .camera-icon-container {
        position: relative;
        width: 24px; /* Taille de base de l'icône */
        height: 24px;
        /* background-color: transparent; */ /* Peut être utile pour le débogage */
        display: flex;
        justify-content: center;
        align-items: center;
        transform-origin: center center; /* Point de rotation */
    }

    .camera-body {
        width: 18px;
        height: 14px;
        background-color: #333; /* Corps de l'appareil photo */
        border: 2px solid #fff;
        border-radius: 3px;
        position: absolute;
        z-index: 1; /* S'assure que le corps est au-dessus du champ de vision si superposé */
    }

    .camera-lens {
        width: 8px;
        height: 8px;
        background-color: #666; /* Lentille */
        border: 1px solid #fff;
        border-radius: 50%;
        position: absolute;
        z-index: 2;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    .field-of-view {
        position: absolute;
        top: -15px; /* Décaler vers l'avant de l'appareil */
        width: 0;
        height: 0;
        border-left: 10px solid transparent; /* Largeur de la base du triangle */
        border-right: 10px solid transparent;
        border-bottom: 20px solid rgba(255, 0, 0, 0.6); /* Couleur et hauteur du champ de vision */
        transform-origin: center bottom; /* Point de rotation du champ de vision */
        z-index: 0; /* En arrière-plan de l'appareil photo */
        /* Pour que le triangle pointe vers le haut par défaut (0 deg) */
        transform: translateY(-50%) rotate(0deg); 
        pointer-events: none; /* Ignore les clics */
    }

    /* NOUVEAU STYLE POUR L'UTILISATEUR (Marqueur Dynamique) */
    .current-location-icon {
        background-color: #00AA00; /* Vert pour la position actuelle */
        border: 2px solid #fff;
        border-radius: 50%;
        width: 24px;
        height: 24px;
        box-shadow: 0 0 5px rgba(0,0,0,0.5);
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
        transform-origin: center center;
    }
    
    .current-location-pointer {
        /* Pointe de la boussole */
        width: 0;
        height: 0;
        border-left: 6px solid transparent;
        border-right: 6px solid transparent;
        border-bottom: 12px solid #FF5733; /* Couleur de la pointe */
        position: absolute;
        top: -10px; /* Positionnement au-dessus du centre */
        pointer-events: none;
    }