/*
 * File Name: family-tree.css
 * Description: Stili Frontend - Versione 1.8.1 (Galleria & Timeline Spaziata)
 */

/* --- 1. STRUTTURA GENERALE & ALBERO --- */
.mft-tree-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    min-height: 600px; /* Spazio per trascinare */
}

/* Messaggi di Errore */
.mft-error {
    color: #d63638;
    background: #fbeaea;
    padding: 15px;
    border-left: 4px solid #d63638;
}

/* Loading */
.mft-loading {
    text-align: center;
    padding: 50px;
    font-size: 1.2em;
    color: #666;
}

/* --- 2. RICERCA --- */
.mft-search-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    width: 300px;
}
.mft-search-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.mft-search-results {
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    position: absolute;
    width: 100%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.mft-result-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}
.mft-result-item:hover {
    background: #f0f6fc;
    color: #2271b1;
}

/* Tasto Reset */
#mft-reset-view {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    background: #fff;
    border: 1px solid #ccc;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.2s;
}
#mft-reset-view:hover {
    background: #f0f0f1;
    transform: scale(1.05);
}

/* --- 3. NODI ALBERO (CARD) --- */
.mft-node {
    width: 180px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    text-align: center;
    padding: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-block;
    vertical-align: top;
    margin: 10px;
}
.mft-node:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 10;
}
.mft-node.focus {
    border: 2px solid #2271b1;
    transform: scale(1.1);
    z-index: 20;
    background: #f0f6fc;
}
.mft-node.spouse {
    border: 2px dashed #e91e63; /* Rosa per coniuge */
}
.mft-node.active-search {
    border: 3px solid #d63638 !important;
    box-shadow: 0 0 15px rgba(214, 54, 56, 0.5);
    transform: scale(1.15);
    z-index: 50;
}

/* Foto Nodo */
.mft-node-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 10px auto;
    background-color: #eee;
    background-size: cover;
    background-position: center;
    border: 3px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Badges Privacy su Nodo */
.mft-badge-living {
    background: #e5f9e7; color: #2fb344; border: 1px solid #c3e6cb;
}
.mft-badge-restricted {
    background: #f0f0f1; color: #999; border: 1px solid #ccc;
}

.mft-node-name {
    font-weight: bold;
    font-size: 0.95em;
    margin-bottom: 5px;
    color: #333;
    line-height: 1.2;
}
.mft-node-dates {
    font-size: 0.8em;
    color: #666;
}

/* Bottoni su Nodo (Hover) */
.mft-node-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 8px;
}
.mft-node:hover .mft-node-overlay {
    opacity: 1;
}
.mft-btn-tree {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.2s;
}
.mft-action-focus {
    background: #2271b1;
    color: #fff;
}
.mft-action-focus:hover { background: #135e96; }
.btn-detail {
    background: #333;
    color: #fff;
    text-decoration: none;
    display: inline-block;
}
.btn-detail:hover { background: #555; }

/* Layout Focused (Righe) */
.mft-gen-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 40px;
    position: relative;
}
/* Linee di collegamento (Semplificate CSS) */
.mft-gen-row::after {
    content: '';
    display: block;
    width: 100%;
    height: 0;
}

/* --- 4. SCHEDA DETTAGLIO (PHP) --- */
.mft-detail-wrap {
    background: #fff;
    padding: 30px;
    max-width: 900px;
    margin: 20px auto;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    border-radius: 10px;
    font-family: inherit;
}

/* Header Scheda */
.mft-detail-header {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    align-items: flex-start;
}
.mft-detail-photo {
    width: 180px;
    height: 220px;
    background-color: #eee;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    flex-shrink: 0;
    /* Proprietà di fallback se lo sprite non sovrascrive */
    background-size: cover;
    background-position: center;
}
.mft-detail-info {
    flex-grow: 1;
}
.mft-detail-name {
    margin-top: 0;
    font-size: 2em;
    color: #2c3e50;
    border-bottom: 2px solid #f0f0f1;
    padding-bottom: 10px;
    margin-bottom: 15px;
}
.mft-detail-job {
    margin-bottom: 8px;
    font-size: 1.05em;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}
.mft-detail-job .dashicons {
    color: #2271b1;
}

/* --- 5. GALLERIA FOTOGRAFICA (NEW) --- */
.mft-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 25px;
    margin-bottom: 35px;
}
.mft-gallery-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: #f0f0f1;
}
.mft-gallery-item:hover {
    transform: scale(1.03);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 2;
}
.mft-gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Taglia l'immagine per riempire il quadrato */
    display: block;
}
.mft-gallery-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.mft-gallery-item:hover .mft-gallery-overlay {
    opacity: 1;
}
.mft-icon-zoom {
    color: #fff;
    font-size: 24px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* --- 6. CRONOLOGIA EVENTI (AGGIORNATO) --- */
.mft-timeline-item {
    position: relative;
    padding: 12px 0 12px 30px; /* Spazio a sinistra per il pallino */
    border-left: 2px solid #e5e5e5;
    margin-left: 10px;
    transition: background 0.2s;
}
.mft-timeline-item:hover {
    background: #fcfcfc;
}
/* Pallino Timeline Base */
.mft-timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 18px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2271b1;
    border: 2px solid #fff;
}

/* Varianti Colore Pallini Timeline (Per icona nascita/figlio/morte) */
.tl-icon-birth::before { background: #46b450 !important; border-color: #46b450 !important; }
.tl-icon-death::before { background: #333 !important; border-color: #333 !important; }
.tl-icon-child::before { background: #f0c33c !important; border-color: #f0c33c !important; }

/* Data Evento distanziata */
.mft-event-date {
    font-weight: 700;
    color: #2271b1;
    display: inline-block;
    min-width: 130px; /* Aumentato per maggiore spazio */
    margin-right: 15px; /* Margine destro aggiunto */
}

.mft-event-tag-badge {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: bold;
    margin-left: 8px;
    text-transform: uppercase;
    vertical-align: middle;
}

/* --- 7. GRIGLIA RELAZIONI (Cards in basso) --- */
.mft-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 30px;
}
.mft-detail-card {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #eee;
}
.mft-detail-card h3 {
    margin-top: 0;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
    font-size: 1.1em;
    color: #444;
}
.card-gallery h3 { border-color: #f0c33c; color: #b08d2b; } /* Stile speciale Galleria */
.card-parents h3 { border-color: #2271b1; color: #2271b1; }
.card-spouse h3 { border-color: #e91e63; color: #e91e63; }
.card-children h3 { border-color: #46b450; color: #46b450; }
.card-siblings h3 { border-color: #9c27b0; color: #9c27b0; }

.mft-detail-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.mft-detail-list li {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px dashed #ddd;
}
.mft-detail-list li:last-child { border: none; }
.mft-detail-link {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.2s;
}
.mft-detail-link:hover { color: #2271b1; }

/* Contributo */
.mft-contribute-box {
    background: #fff8e5;
    border: 1px solid #f0c33c;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    gap: 20px;
    align-items: center;
}
.mft-contribute-icon {
    font-size: 30px;
    color: #f0c33c;
    width: 30px;
    height: 30px;
}
.mft-contribute-text h4 { margin: 0 0 5px 0; }
.mft-contribute-text p { margin: 0 0 15px 0; font-size: 0.9em; line-height: 1.4; }
.mft-btn-contribute {
    background: #f0c33c;
    color: #fff;
    padding: 8px 15px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    display: inline-block;
}
.mft-btn-contribute:hover { background: #dcb336; color: #fff; }

/* --- 8. RESPONSIVE MOBILE --- */
@media (max-width: 768px) {
    .mft-detail-header {
        flex-direction: column;
        text-align: center;
    }
    .mft-detail-photo {
        margin: 0 auto;
    }
    .mft-detail-job {
        justify-content: center;
    }
    .mft-action-bar {
        flex-direction: column;
        gap: 15px;
    }
    .mft-gallery-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 colonne su mobile */
    }
    /* Fix Timeline su mobile: la data va a capo */
    .mft-event-date {
        display: block; 
        margin-bottom: 5px;
        min-width: auto;
    }
    .mft-timeline-item {
        padding-left: 15px;
    }
}