/* --- קוד CSS עבור עץ המשפחה (מתוקן עם פריסה ספציפית לדורות) --- */

/* עיצוב כללי לעמוד */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
    text-align: center;
    direction: rtl; /* לוודא כיוון מימין לשמאל */
}

header {
    background-color: #4CAF50; /* ירוק */
    color: white;
    padding: 20px 0;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

header h1 {
    margin: 0;
    font-size: 2.8em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

nav {
    margin-top: 15px;
}

nav a {
    color: white;
    text-decoration: none;
    margin: 0 20px;
    font-weight: bold;
    font-size: 1.1em;
    transition: color 0.3s ease-in-out;
}

nav a:hover {
    color: #e0e0e0;
    text-decoration: underline;
}

main {
    padding: 20px;
    min-height: calc(100vh - 160px); /* גובה מינימלי למניעת פוטר צף */
    display: flex;
    justify-content: center;
    align-items: flex-start; /* יישור למעלה ולא למרכז אנכית */
}

footer {
    background-color: #333;
    color: white;
    padding: 15px 0;
    text-align: center;
    width: 100%;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.2);
}

/* עיצוב ספציפי לעץ המשפחה */
.family-tree-section {
    width: 100%;
    max-width: 1400px; /* הגדלתי את הרוחב המקסימלי כדי לאפשר יותר מקום */
    margin: 20px auto;
    padding: 0;
}

.family-tree-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    overflow-x: auto; /* מאפשר גלילה אופקית אם העץ רחב מדי */
    min-height: 400px; /* גובה מינימלי לקונטיינר העץ */
    position: relative;
}

.generation {
    display: flex;
    justify-content: center;
    flex-wrap: wrap; /* מאפשר שבירת שורות לדורות גדולים */
    margin-bottom: 50px; /* מרווח גדול יותר בין דורות */
    position: relative;
    width: 100%; /* לוודא שהדור תופס 100% מהרוחב של ה-family-tree-container */
}

/* מיקום ספציפי לדור הראשון - יישור למעלה */
.generation.level-1 {
    margin-bottom: 20px; /* מרווח קטן יותר מהדור הבא עבור הזוג הראשי */
}

.person-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 25px; /* מרווח בין אנשים */
    position: relative;
    padding-bottom: 25px; /* מרווח בשביל הקווים לילדים */
}

.person-info {
    background-color: #e3f2fd; /* כחול בהיר מאוד */
    border: 2px solid #2196F3; /* כחול */
    border-radius: 12px;
    padding: 12px 18px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    min-width: 130px; /* רוחב מינימלי גדול יותר */
    max-width: 160px; /* רוחב מקסימלי */
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 10; /* כדי שהמידע יהיה מעל הקווים */
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.person-info:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

.person-info img {
    width: 90px; /* גודל תמונה גדול יותר */
    height: 90px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #1976D2; /* כחול כהה יותר */
    margin-bottom: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.person-info span {
    font-weight: bold;
    color: #1A237E; /* כחול כהה מאוד */
    font-size: 1.1em;
    line-height: 1.3;
}

.person-info .role {
    font-size: 0.85em;
    color: #555;
    margin-top: 2px;
}

/* קונטיינר לזוג (אדם + בן/בת זוג) */
.person-pair-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 30px 40px 30px; /* מרווח גדול יותר סביב זוגות */
    position: relative;
    padding-bottom: 0px; /* ללא ריפוד תחתון כאן, הקווים יטופלו אחרת */
}

.person-pair-container.top-level-pair {
    margin-bottom: 20px; /* מרווח ספציפי לזוג העליון */
}

.person-and-spouse-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-bottom: 25px; /* מרווח לקו יורד מהזוג */
}

/* קו חיבור בין בני זוג */
.spouse-connector {
    width: 50px;
    height: 2px;
    background-color: #888;
    margin: 0 -2px; /* כדי לחבר בדיוק בין המסגרות */
    z-index: 5;
}

/* קונטיינר לילדים של זוג/אדם יחיד */
.children-container {
    display: flex;
    flex-direction: column; /* הילדים אחד מתחת לשני */
    align-items: center;
    width: 100%; /* תופס את כל הרוחב הזמין */
    position: relative;
    margin-top: 0px; /* מרווח מהקונטיינר של ההורים */
    padding-top: 20px; /* מרווח לקווים */
}

.actual-children-nodes-wrapper {
    display: flex;
    justify-content: center;
    flex-wrap: wrap; /* מאפשר גלישה לשורה הבאה */
    width: 100%;
    padding-top: 10px; /* מרווח מתחת לקו האופקי לילדים */
}

/* קווים חיבוריים */
/* הסתרת הקו היורד מכל "person-node" בודד */
.person-node .person-info::after {
    display: none;
}

/* קו יורד מ-primaryPersonWrapper (כלומר, מזוג או אדם יחיד שמוביל לילדים) */
.person-and-spouse-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0; /* ממוקם בתחתית ה-wrapper */
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 25px; /* קו אנכי יורד מהזוג/אדם */
    background-color: #888;
    z-index: 1;
}

.children-horizontal-line {
    height: 2px;
    background-color: #888;
    width: calc(100% - 60px); /* רוחב הקו האופקי - מותאם למרווחים */
    margin: 0 auto;
    position: relative;
    top: -10px; /* מיקום מעל הילדים */
    z-index: 1;
}

/* קו אנכי שמחבר כל ילד לקו האופקי של הילדים */
.children-container .person-node::before {
    content: '';
    position: absolute;
    top: -10px; /* בגובה הקו האופקי של הילדים */
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 10px; /* קו אנכי קצר שמחבר לקו האופקי */
    background-color: #888;
    z-index: 1;
}


/* קו יורד מההורים הראשיים (מיכאל ורחל) לדור הילדים שלהם */
.parent-to-children-line {
    height: 30px; /* אורך הקו היורד */
    width: 2px;
    background-color: #888;
    margin: 0 auto;
    position: relative;
    top: -20px; /* ממוקם מעל הקו האופקי של הילדים */
    z-index: 1;
}

/* מדיה קוורייס להתאמה למסכים קטנים יותר */
@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }
    nav a {
        margin: 0 10px;
        font-size: 1em;
    }
    .family-tree-container {
        padding: 15px;
        margin: 10px auto;
    }
    .person-node {
        margin: 10px 10px;
        padding-bottom: 20px;
    }
    .person-info {
        min-width: 100px;
        max-width: 130px;
        padding: 8px 12px;
    }
    .person-info img {
        width: 70px;
        height: 70px;
        margin-bottom: 5px;
    }
    .person-info span {
        font-size: 0.9em;
    }
    .spouse-connector {
        width: 30px;
        margin: 0 -1px;
    }
    .generation {
        margin-bottom: 30px;
    }
    .person-pair-container {
        margin: 0 15px 30px 15px;
    }
    .person-and-spouse-wrapper::after {
        height: 20px;
    }
    .children-container .person-node::before {
        top: -10px;
        height: 10px;
    }
    .children-horizontal-line {
        top: -10px;
    }
    .parent-to-children-line {
        height: 25px;
        top: -15px;
    }
}

@media (max-width: 480px) {
    .person-info {
        min-width: 80px;
        max-width: 100px;
        padding: 6px 8px;
    }
    .person-info img {
        width: 60px;
        height: 60px;
    }
    .person-info span {
        font-size: 0.8em;
    }
    .spouse-connector {
        width: 20px;
    }
    .person-node {
        margin: 8px 8px;
    }
    .person-pair-container {
        margin: 0 10px 20px 10px;
    }
}
