/* ═══════════════════════════════════════════════════
   Observations de la faune et de la flore — styles.css
   ═══════════════════════════════════════════════════ */

/* ─── Barre supérieure ──────────────────────────── */
.obs-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem 1.5rem 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    margin-bottom: 1rem;
}

.obs-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    color: #2c3e50;
}

.obs-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ─── Boutons ────────────────────────────────────── */
.obs-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.obs-btn:active {
    transform: scale(0.97);
}

.obs-btn-login {
    background: #2c7a4b;
    color: #fff;
}
.obs-btn-login:hover {
    background: #235f3a;
}

.obs-btn-import {
    background: #1a6fa8;
    color: #fff;
}
.obs-btn-import:hover {
    background: #145585;
}

.obs-btn-logout {
    background: #b94040;
    color: #fff;
    border: none;
}
.obs-btn-logout:hover {
    background: #922f2f;
}

/* ─── Message flash ─────────────────────────────── */
.obs-message {
    margin: 0 1.5rem 1rem;
    padding: 0.7rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}
.obs-message--success {
    background: #e6f4ec;
    color: #1d6e3e;
    border-left: 4px solid #2c7a4b;
}
.obs-message--error {
    background: #fdecea;
    color: #a0291a;
    border-left: 4px solid #c0392b;
}

/* ─── Zone principale ───────────────────────────── */
.obs-main {
    padding: 1.5rem;
    min-height: 200px;
}
.obs-placeholder {
    color: #aaa;
    font-style: italic;
    text-align: center;
    margin-top: 3rem;
}

/* ─── Overlay / Modal ───────────────────────────── */
.obs-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.obs-overlay.active {
    display: flex;
}

.obs-modal {
    position: relative;
    background: #fff;
    border-radius: 10px;
    padding: 2rem 2.5rem;
    width: min(420px, 92vw);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    animation: obsModalIn 0.18s ease;
}
@keyframes obsModalIn {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.obs-modal h3 {
    margin: 0 0 1.2rem;
    font-size: 1.15rem;
    color: #2c3e50;
}

.obs-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.9rem;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
}
.obs-modal-close:hover {
    color: #444;
}

.obs-modal-hint {
    font-size: 0.85rem;
    color: #666;
    margin: -0.5rem 0 1.2rem;
    line-height: 1.5;
}
.obs-modal-hint code {
    background: #f0f0f0;
    border-radius: 3px;
    padding: 0 3px;
    font-size: 0.82rem;
}

/* ─── Formulaire interne ─────────────────────────── */
.obs-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.obs-form label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
}
.obs-form input[type="password"],
.obs-form input[type="file"] {
    padding: 0.5rem 0.7rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.2s;
}
.obs-form input[type="password"]:focus {
    border-color: #2c7a4b;
    box-shadow: 0 0 0 2px rgba(44,122,75,0.12);
}
.obs-form input[type="file"] {
    padding: 0.4rem;
    cursor: pointer;
}

/* ─── Loader spinner ─────────────────────────────── */
.obs-loader {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    color: #666;
}
.obs-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: #1a6fa8;
    border-radius: 50%;
    animation: obsSpin 0.7s linear infinite;
}
@keyframes obsSpin {
    to { transform: rotate(360deg); }
}

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 560px) {
    .obs-topbar {
        padding: 0.75rem 1rem 0.5rem;
    }
    .obs-title {
        font-size: 1.05rem;
    }
    .obs-modal {
        padding: 1.5rem 1.25rem;
    }
}

/* ─── Bouton Taxonomie ──────────────────────────── */
.obs-btn-taxo {
    background: #7b4fa6;
    color: #fff;
}
.obs-btn-taxo:hover {
    background: #603984;
}
.obs-btn-taxo:hover { background: #603984; }

/* ─── Modale large ───────────────────────────────── */
.obs-modal--wide {
    width: min(540px, 95vw);
}

/* ─── Cartes de mode ─────────────────────────────── */
.obs-mode-cards {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.obs-mode-card {
    flex: 1;
    min-width: 180px;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.obs-mode-card:has(input:checked) {
    border-color: #7b4fa6;
    background: #f5eeff;
}
.obs-mode-card input[type="radio"] {
    margin-top: 3px;
    accent-color: #7b4fa6;
    flex-shrink: 0;
}
.obs-mode-label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.obs-mode-label strong { font-size: 0.9rem; color: #2c3e50; }
.obs-mode-label small  { font-size: 0.78rem; color: #777; }

/* ─── Barre de progression ───────────────────────── */
.obs-progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.4rem;
}
.obs-progress-bar-track {
    width: 100%;
    height: 10px;
    background: #e8e8e8;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}
.obs-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #7b4fa6, #a07cc5);
    border-radius: 5px;
    transition: width 0.3s ease;
}

/* ─── Log de progression ─────────────────────────── */
.obs-progress-log {
    max-height: 180px;
    overflow-y: auto;
    font-size: 0.78rem;
    color: #666;
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    line-height: 1.7;
}
.obs-progress-log .log-ok      { color: #2c7a4b; }
.obs-progress-log .log-skip    { color: #999; }
.obs-progress-log .log-update  { color: #1a6fa8; }
.obs-progress-log .log-error   { color: #c0392b; }

/* ─── Arbre taxonomique ──────────────────────────── */
.taxo-summary {
    font-size: 0.82rem;
    color: #999;
    margin: 0 0 1rem 0.25rem;
}

/* ── Racine ── */
.taxo-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* ── ul enfants : les lignes de connexion ── */
.taxo-children {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1.6rem;
    position: relative;
}

/* Ligne verticale sur toute la hauteur du groupe */
.taxo-children::before {
    content: '';
    position: absolute;
    left: 0.55rem;
    top: 0;
    bottom: 0.7em;
    border-left: 1px solid #c0d8c3;
}

/* Ligne horizontale vers chaque enfant */
.taxo-children > li {
    position: relative;
}
.taxo-children > li::before {
    content: '';
    position: absolute;
    left: -1.05rem;
    top: 0.72em;
    width: 0.7rem;
    border-top: 1px solid #c0d8c3;
}

/* ── Ligne de contenu (row) ── */
.taxo-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.35rem 0.22rem 0;
    border-radius: 4px;
    line-height: 1.45;
    cursor: default;
}
.taxo-row:hover {
    background: #f0f5f1;
}

/* ── Bouton plier/déplier ── */
.taxo-toggle {
    background: none;
    border: none;
    padding: 0 0.1rem;
    font-size: 0.8rem;
    color: #9ab89e;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
    width: 1rem;
    text-align: center;
    transition: transform 0.18s;
    transform-origin: center;
}
.taxo-toggle:hover { color: #3a7d44; }
.taxo-toggle.closed { transform: rotate(-90deg); }

.taxo-toggle-placeholder {
    display: inline-block;
    width: 1rem;
    flex-shrink: 0;
}

/* ── Nœuds intermédiaires ── */
.taxo-group-row { cursor: pointer; }
.taxo-group-name {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;

    color: #7a9a7e;
}
.taxo-group-lat {
    font-size: 0.74rem;
    color: #bbb;
    font-style: italic;
}

/* ── Espèces observées ── */
.taxo-leaf .taxo-row {
    padding-left: 0;
}
.taxo-icon {
    font-size: 0.45rem;
    color: #3a7d44;
    flex-shrink: 0;
    margin-right: 0.1rem;
    line-height: 1;
    position: relative;
    top: -0.05em;
}
.taxo-leaf strong {
    font-size: 0.97rem;
    color: #1a3d20;
    font-weight: 700;
}
.taxo-leaf em {
    font-size: 0.83rem;
    color: #7a9a7e;
    font-style: italic;
    font-weight: 400;
}

/* ── Branche repliée ── */
.taxo-children.hidden { display: none; }

/* ─── Bouton d'édition inline ────────────────────── */
.taxo-row {
    position: relative;
}
.taxo-edit-btn {
    display: none;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;
    background: none;
    border: 1px solid #c5d9c7;
    border-radius: 4px;
    color: #7a9a7e;
    font-size: 0.78rem;
    width: 1.4rem;
    height: 1.4rem;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.taxo-row:hover .taxo-edit-btn {
    display: inline-flex;
}
.taxo-edit-btn:hover {
    background: #e8f0e9;
    color: #2c7a4b;
    border-color: #9ab89e;
}

/* ─── Champ d'édition inline ─────────────────────── */
.taxo-edit-form {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex: 1;
    min-width: 0;
}
.taxo-edit-input {
    flex: 1;
    min-width: 0;
    padding: 0.15rem 0.4rem;
    border: 1px solid #7a9a7e;
    border-radius: 4px;
    font-size: 0.88rem;
    outline: none;
    font-family: inherit;
}
.taxo-edit-input:focus {
    border-color: #2c7a4b;
    box-shadow: 0 0 0 2px rgba(44,122,75,0.12);
}
.taxo-edit-save,
.taxo-edit-cancel {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    width: 1.4rem;
    height: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.taxo-edit-save   { border-color: #2c7a4b; color: #2c7a4b; }
.taxo-edit-save:hover   { background: #e8f0e9; }
.taxo-edit-cancel { border-color: #ccc; color: #999; }
.taxo-edit-cancel:hover { background: #f4f4f4; }

/* Nom forcé : petite marque visuelle */
.taxo-name-forced strong,
.taxo-name-forced .taxo-group-name {
    color: #5a3fa0;
}

/* ─── Chaîne de taxons enfant-unique ────────────── */
.taxo-chain-row {
    flex-wrap: nowrap;
    gap: 0.2rem 0.15rem;
    align-items: center;
    overflow: hidden;
}
.taxo-chain-token {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    flex-shrink: 1;
    min-width: 0;
}
.taxo-chain-leaf {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    flex-shrink: 1;
    min-width: 0;
}
.taxo-arrow {
    color: #b0c8b2;
    font-size: 0.8rem;
    flex-shrink: 0;
    margin: 0 0.1rem;
}

/* Afficher le bouton ✎ au survol du token dans une chaîne */
.taxo-chain-token:hover .taxo-edit-btn,
.taxo-chain-leaf:hover .taxo-edit-btn {
    display: inline-flex;
}

/* ─── Bouton Administration ──────────────────────── */
.obs-btn-admin {
    background: #4a4a6a;
    color: #fff;
    text-decoration: none;
}
.obs-btn-admin:hover {
    background: #35354f;
}

/* ═══════════════════════════════════════════════════
   Barre de filtres — bandeau horizontal compact
   ═══════════════════════════════════════════════════ */
.obs-filters {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 1.2rem;
    background: #f7fbf7;
    border-bottom: 1px solid #e4ede5;
    overflow-x: auto;
    scrollbar-width: thin;
    min-height: 44px;
}

/* Petit label texte ("Du") */
.obs-fi-label {
    font-size: 0.72rem;
    color: #aaa;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Flèche entre dates */
.obs-fi-sep {
    font-size: 0.7rem;
    color: #ccc;
    flex-shrink: 0;
}

/* Champs date */
.obs-fi-date {
    padding: 0.2rem 0.3rem;
    border: 1px solid #d8ead9;
    border-radius: 4px;
    font-size: 0.78rem;
    color: #2c3e2d;
    background: #fff;
    outline: none;
    flex-shrink: 0;
    width: 120px;
    cursor: pointer;
}
.obs-fi-date:focus {
    border-color: #3a7d44;
    box-shadow: 0 0 0 2px rgba(58,125,68,.1);
}

/* Séparateur vertical */
.obs-fi-divider {
    width: 1px;
    height: 18px;
    background: #d8ead9;
    flex-shrink: 0;
    margin: 0 0.2rem;
}

/* Checkbox */
.obs-fi-check {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: #555;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
}
.obs-fi-check input { accent-color: #3a7d44; }

/* Select lieu */
.obs-fi-select {
    padding: 0.2rem 0.35rem;
    border: 1px solid #d8ead9;
    border-radius: 4px;
    font-size: 0.78rem;
    background: #fff;
    color: #2c3e2d;
    outline: none;
    cursor: pointer;
    max-width: 170px;
    flex-shrink: 0;
}
.obs-fi-select:focus {
    border-color: #3a7d44;
    box-shadow: 0 0 0 2px rgba(58,125,68,.1);
}

/* Boutons icônes taxonomiques */
.obs-fi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    font-size: 1.15rem;
    border: 1px solid transparent;
    border-radius: 5px;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
    filter: grayscale(1) opacity(.4);
    transition: filter .15s, border-color .15s, background .15s, transform .1s;
    padding: 0;
    line-height: 1;
}
.obs-fi-icon:hover {
    filter: grayscale(.2) opacity(.85);
    border-color: #c5d9c7;
    background: #f0f7f1;
    transform: scale(1.15);
}
.obs-fi-icon.active {
    filter: none;
    border-color: #3a7d44;
    background: #e8f5ea;
    transform: scale(1.15);
}

/* Bouton reset */
.obs-fi-reset {
    font-size: 0.72rem;
    color: #ccc;
    text-decoration: none;
    flex-shrink: 0;
    padding: 0.1rem 0.25rem;
    border-radius: 3px;
    transition: color .15s, background .15s;
}
.obs-fi-reset:hover {
    color: #c0392b;
    background: #fdecea;
}

@media (max-width: 700px) {
    .obs-fi-date { width: 100px; font-size: 0.72rem; }
    .obs-fi-select { max-width: 120px; }
    .obs-fi-icon { width: 1.7rem; height: 1.7rem; font-size: 1rem; }
}


/* ─── Détail observations par espèce ────────────── */
.taxo-leaf-toggle {
    background: none !important;
    border: none !important;
    color: #b0c8b2;
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0 2px !important;
    width: 1rem;
    flex-shrink: 0;
    transition: color .15s, transform .18s;
}
.taxo-leaf-toggle:hover { color: #3a7d44; }
.taxo-leaf-toggle.open  { transform: rotate(90deg); color: #3a7d44; }

.taxo-obs-panel {
    padding: 0.4rem 0.5rem 0.6rem 2.2rem;
}
.taxo-obs-loading {
    font-size: 0.78rem; color: #aaa; font-style: italic;
    display: flex; align-items: center; gap: 0.4rem;
}
.taxo-obs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
    margin-top: 0.3rem;
}
.taxo-obs-card {
    border: 1px solid #e4ede5;
    border-radius: 7px;
    overflow: hidden;
    background: #fff;
    font-size: 0.75rem;
    transition: box-shadow .15s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.taxo-obs-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.1); }
.taxo-obs-img {
    width: 100%; aspect-ratio: 4/3;
    object-fit: cover; display: block;
    background: #f0f5f1;
}
.taxo-obs-img-placeholder {
    width: 100%; aspect-ratio: 4/3;
    background: #f0f5f1;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: #c5d9c7;
}
.taxo-obs-info {
    padding: 0.3rem 0.45rem;
    display: flex; flex-direction: column; gap: 0.1rem;
}
.taxo-obs-date { font-weight: 600; color: #2c3e2d; }
.taxo-obs-lieu { color: #7a9a7e; font-size: 0.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.taxo-obs-empty { font-size: 0.8rem; color: #aaa; font-style: italic; margin-top: 0.3rem; }

/* ═══════════════════════════════════════════════════
   Photo sélectionnée sur les feuilles taxonomiques
   ═══════════════════════════════════════════════════ */

/* Position relative sur le li, hauteur fixe uniquement sur la row */
.taxo-leaf--has-photo,
.taxo-chain-is-leaf {
    position: relative;
    /* Pas de height fixe ici : le li doit pouvoir grandir quand le panel s'ouvre */
}
.taxo-leaf--has-photo .taxo-leaf-row {
    height: 100px;
    align-items: center;
    padding-right: calc(100px * 16 / 9 + 8px);
}
.taxo-chain-is-leaf .taxo-chain-row {
    height: 100px;
    align-items: center;
    padding-right: calc(100px * 16 / 9 + 8px);
    flex-wrap: nowrap;
    overflow: hidden;
}

/* Points de suite entre le nom et la photo */
.taxo-leaf--has-photo .taxo-name-display,
.taxo-chain-leaf--has-photo .taxo-name-display {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
    -webkit-mask-image: linear-gradient(to right, black 50%, transparent 90%);
    mask-image: linear-gradient(to right, black 50%, transparent 90%);
}

.taxo-leaf--has-photo .taxo-name-display::after,
.taxo-chain-leaf--has-photo .taxo-name-display::after {
    content: ' ····················································';
    font-size: 0.6rem;
    color: #c5d9c7;
    letter-spacing: 0.15em;
    vertical-align: middle;
}

/* Photo 16:9 — positionnée en absolute sur le li, right calculé par JS */
.taxo-leaf-photo {
    position: absolute;
    top: 0;
    right: 0;   /* valeur initiale, écrasée par JS via alignLeafPhotos() */
    display: block;
    height: 100px;
    width: calc(100px * 16 / 9);   /* ~178px */
    cursor: zoom-in;
    overflow: hidden;
    z-index: 1;
}

/* Fond flouté/déformé qui remplit le 16:9 */
.taxo-leaf-photo .lp-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(6px) brightness(.55) saturate(.7);
    transform: scale(1.05); /* déborde légèrement pour masquer les bords du blur */
}

/* Image réelle centrée par dessus en contain */
.taxo-leaf-photo img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform .25s;
    z-index: 1;
}
.taxo-leaf-photo:hover img {
    transform: scale(1.04);
}

/* ── Lightbox ── */
#taxo-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    flex-direction: column;
    cursor: zoom-out;
    overflow: hidden;
}
#taxo-lightbox.active { display: flex; }

/* Fond flouté — même image étirée */
#taxo-lb-bg {
    position: absolute;
    inset: -30px;
    background-size: cover;
    background-position: center;
    filter: blur(22px) brightness(.3);
    z-index: 0;
}

/* Bande noire haut */
#taxo-lb-top {
    flex-shrink: 0;
    background: rgba(0,0,0,.75);
    padding: 0.75rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    z-index: 2;
    position: relative;
}
#taxo-lb-nom-fr {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}
#taxo-lb-nom-lat {
    font-size: 0.8rem;
    font-style: italic;
    color: rgba(255,255,255,.65);
}

/* Zone centrale — image centrée dans l'espace disponible */
#taxo-lb-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    min-height: 0;
}

#taxo-lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* Bande noire bas */
#taxo-lb-bottom {
    flex-shrink: 0;
    background: rgba(0,0,0,.75);
    padding: 0.65rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2;
    position: relative;
}
#taxo-lb-lieu { font-size: 0.85rem; color: rgba(255,255,255,.8); }
#taxo-lb-date { font-size: 0.85rem; color: rgba(255,255,255,.65); }

/* ─── Formulaire inline (déconnexion) — sans style propre ── */
.obs-actions form {
    display: contents;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}

.obs-btn-secondary {
    background: #edf2ef;
    color: #2c3e50;
    border: 1px solid #d8e2db;
}
.obs-btn-secondary:hover {
    background: #e2ebe4;
}
