/* ===================================================
   Atlas Biodiversite Communale — Styles
   =================================================== */

:root {
    --color-primary: #2d6a4f;
    --color-primary-light: #40916c;
    --color-bg: #f8f9fa;
    --color-text: #212529;
    --color-border: #dee2e6;
    --color-off: #6c757d;
    --color-on: #e63946;
    --color-traitement: #f4a261;
    --header-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    color: var(--color-text);
    background: var(--color-bg);
}

/* Header */
#app-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1rem;
    background: var(--color-primary);
    color: white;
}

#app-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

#app-header p {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Map */
#map {
    height: calc(100vh - var(--header-height));
    width: 100%;
}

/* Balise markers */
.balise-marker {
    background: none;
    border: none;
}

.balise-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid #264653;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

.balise-marker:hover .balise-dot {
    transform: scale(1.3);
}

/* Popups */
.balise-popup {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.balise-popup strong {
    font-size: 1rem;
}

.popup-circuit {
    color: #6c757d;
    font-size: 0.8rem;
}

.popup-statut {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    width: fit-content;
}

.popup-statut--off { background: var(--color-primary); }
.popup-statut--on { background: var(--color-on); }
.popup-statut--ecoute-terminee { background: #457b9d; }
.popup-statut--traitement-en-cours { background: var(--color-traitement); color: #212529; }

.popup-operateur {
    font-weight: 500;
}

.popup-date {
    font-size: 0.8rem;
    color: #6c757d;
}

/* Legend */
.legend {
    background: white;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
    font-size: 0.8rem;
    line-height: 1.8;
}

.legend strong {
    display: block;
    margin-bottom: 0.2rem;
}

.legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.legend-line {
    display: inline-block;
    width: 16px;
    height: 3px;
    margin-right: 0.4rem;
    vertical-align: middle;
    border-radius: 2px;
}

/* Leaflet layer control override */
.leaflet-control-layers {
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.45rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: white; }
.btn-secondary { background: var(--color-border); color: var(--color-text); }
.btn-warning { background: var(--color-traitement); color: #212529; }
.btn-success { background: var(--color-primary-light); color: white; }
.btn-info { background: #457b9d; color: white; }

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    margin-top: 0.4rem;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
    color: var(--color-primary);
}

.modal-subtitle {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

/* Form */
.form-group {
    margin-bottom: 0.8rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.form-group .required {
    color: var(--color-on);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(45, 106, 79, 0.15);
}

.form-group input[readonly] {
    background: #f1f3f5;
    color: #6c757d;
}

.field-error {
    font-size: 0.75rem;
    color: var(--color-on);
}

.form-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 1.2rem;
}

.form-actions .btn {
    flex: 1;
}

.form-msg {
    margin-top: 0.8rem;
    padding: 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
}

.form-msg--success { background: #d3f9d8; color: #2b8a3e; }
.form-msg--error { background: #ffe3e3; color: #c92a2a; }

/* Popup buttons */
.balise-popup .btn {
    display: block;
    width: 100%;
}

/* Responsive */
@media (max-width: 600px) {
    #app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        height: auto;
        padding: 0.5rem 1rem;
    }

    #app-header h1 {
        font-size: 1rem;
    }

    #map {
        height: calc(100vh - 70px);
    }
}
