/* --------------------------------------------------
   GLOBAL
-------------------------------------------------- */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f5f5f5;
}

button {
    cursor: pointer;
    border: none;
    font-family: inherit;
}

/* --------------------------------------------------
   HEADER
-------------------------------------------------- */
header,
.top-header {
    background: #2c3e50;
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left,
.header-right,
.profile-link {
    display: flex;
    align-items: center;
}

.logo {
    height: 40px;
    margin-right: 10px;
}

.app-title {
    font-size: 1.4em;
    font-weight: bold;
}

.header-right {
    gap: 15px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
}

.profile-link {
    gap: 10px;
    color: white;
    text-decoration: none;
}

.profile-btn {
    background: none;
    border: none;
    padding: 0;
}

/* --------------------------------------------------
   LAYOUT STRUCTURE
-------------------------------------------------- */
#container {
    display: flex;
    min-height: calc(100vh - 70px);
}

main {
    flex: 1;
    padding: 20px;
    background: white;
}

.welcome-container {
    max-width: 900px;
    margin: 20px auto;
    text-align: center;
    padding: 20px;
}

h1 {
    font-size: 2.4em;
    margin-bottom: 10px;
    color: #2c3e50;
}

p.subtitle {
    font-size: 1.2em;
    margin-bottom: 20px;
    color: #555;
}

/* --------------------------------------------------
   SIDEBAR
-------------------------------------------------- */
.sidebar {
    width: 220px;
    background: #1e1e1e;
    color: white;
    padding: 20px 0;
    transition: width 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar-toggle {
    color: white;
    font-size: 1.4em;
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.sidebar-toggle:hover {
    background: #333;
}

.menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu li {
    margin-bottom: 5px;
}

.menu-btn {
    width: 100%;
    background: none;
    color: white;
    padding: 12px 20px;
    text-align: left;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1em;
    transition: background 0.2s, padding-left 0.2s;
}

.menu-btn:hover {
    background: #333;
    padding-left: 25px;
}

.sidebar.collapsed .menu-btn span {
    display: none;
}

.sidebar.collapsed .menu-btn {
    justify-content: center;
}

/* --------------------------------------------------
   LOGIN LINKS
-------------------------------------------------- */
.login-links a {
    color: white;
    margin-left: 15px;
    text-decoration: none;
}

.login-links a:hover {
    text-decoration: underline;
}

/* --------------------------------------------------
   PROFILE PAGE
-------------------------------------------------- */
.profile-container {
    max-width: 500px;
    margin: auto;
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.profile-container form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-container input,
.profile-container select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

/* --------------------------------------------------
   MEMBER PROFILE
-------------------------------------------------- */
.member-profile {
    max-width: 700px;
    margin: auto;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.member-header {
    display: flex;
    align-items: center;
    gap: 15px;
}

.member-photo {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 2px solid #ddd;
    object-fit: cover;
}

.member-info h1 {
    margin: 0;
    font-size: 1.4em;
}

.family-name {
    font-size: 1em;
    color: #555;
    margin-top: 4px;
}

.member-badges {
    margin-top: 6px;
    display: flex;
    gap: 8px;
}

.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: bold;
    color: white;
}

.badge.age { background: #2ecc71; }

/* --------------------------------------------------
   TITLES + BUTTONS
-------------------------------------------------- */
.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 15px 0 8px 0;
}

.add-small,
.edit-small {
    font-size: 0.85em;
    padding: 4px 8px;
    background: #3498db;
    color: white;
    border-radius: 5px;
}

.add-small:hover,
.edit-small:hover {
    background: #2980b9;
}

.edit-btn {
    padding: 6px 10px;
    background: #f1c40f;
    color: black;
    border-radius: 5px;
}

.edit-btn:hover {
    background: #d4ac0d;
}

/* --------------------------------------------------
   MEMBER TABLE
-------------------------------------------------- */
.member-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.member-table thead {
    background: #2c3e50;
    color: white;
}

.member-table th,
.member-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #ddd;
}

.member-table tr:hover {
    background: #f0f0f0;
}

/* --------------------------------------------------
   RELATIONS
-------------------------------------------------- */
.relation-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.relation-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafafa;
    border: 1px solid #ddd;
    padding: 8px;
    border-radius: 8px;
}

.relation-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.relation-left img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid #ddd;
}

.relation-name {
    font-weight: bold;
    font-size: 0.9em;
}

.relation-details {
    font-size: 0.75em;
    color: #666;
}

/* --------------------------------------------------
   DELETE BUTTON
-------------------------------------------------- */
.delete-btn {
    font-size: 1.1em;
    background: none;
    color: #e74c3c;
}

.delete-btn:hover {
    color: #c0392b;
}

/* --------------------------------------------------
   TOASTS
-------------------------------------------------- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    padding: 12px 18px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.4s ease;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.toast.success { background: #2ecc71; }
.toast.error   { background: #e74c3c; }
.toast.info    { background: #3498db; }
.toast.warn    { background: #f39c12; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(50px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* --------------------------------------------------
   BUTTONS THAT LOOK LIKE LINKS
-------------------------------------------------- */
.member-form {
    display: inline;
}

.member-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: #3498db;
    cursor: pointer;
}

.member-link:hover {
    text-decoration: underline;
}

.features {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 60px auto;
    max-width: 1100px;
    padding: 0 20px;
}

.feature-box {
    background: white;
    border-radius: 12px;
    padding: 25px;
    width: 30%;
    min-width: 250px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-box:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.feature-box img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 15px;
    opacity: 0.9;
}

.feature-box h3 {
    margin-bottom: 10px;
    font-size: 1.3em;
    color: #2c3e50;
}

.feature-box p {
    color: #555;
    font-size: 1em;
}

/* Carte */
.form-card {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    margin-bottom: 25px;
}

.page-title {
    font-size: 24px;
    margin-bottom: 15px;
    color: #2c3e50;
}

/* Lignes en flex */
.form-row {
    display: flex;
    flex-wrap: nowrap;   /* important pour forcer sur une seule ligne */
    gap: 20px;
    margin-bottom: 15px;
}

.form-group.full {
    flex: 1 1 100%;
}

.form-group.half {
    flex: 1 1 50%;
}

/* Labels + champs */
.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-top: 5px;
    margin-bottom: 5px;
    color: #34495e;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.2);
    outline: none;
}

/* Boutons */
.btn-primary,
.btn-secondary {
    padding: 12px;
    border-radius: 8px;
    font-size: 16px;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #2ecc71;
    color: white;
}

.btn-secondary:hover {
    background: #27ae60;
}

.full-width {
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.table th, .table td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

.btn-small {
    padding: 6px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: white;
    margin-right: 5px;
}

.btn-success { background: #2ecc71; }
.btn-danger  { background: #e74c3c; }


/* ADMIN */

.admin-nav a {
    margin-right: 20px;
    font-weight: bold;
}

.cards {
    display: flex;
    gap: 20px;
    margin: 20px 0;
}

.card {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    flex: 1;
}

.requests {
    width: 100%;
    border-collapse: collapse;
}

.requests th, .requests td {
    border: 1px solid #ddd;
    padding: 8px;
}

.ok {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 5px 10px;
}

.ko {
    background: #e53935;
    color: white;
    border: none;
    padding: 5px 10px;
}


/*  Arbre  */
.tree-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.avatar-small {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
}

.member-card {
    display: inline-block;
    padding: 10px 15px;
    border-radius: 10px;
    background: #f5f5f5;
    position: relative;
    text-align: center;
    min-width: 140px;
}

.selected-member {
    background: #b7ff7a; /* vert pomme */
    border: 2px solid #6ac92d;
}

.member-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.member-btn {
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    flex-direction: column; /* IMPORTANT : avatar au-dessus du nom */
    align-items: center;
    gap: 6px;
}

.avatar-small {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-circle {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: #4a90e2;
    color: white;
    font-size: 26px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.member-name {
    font-weight: bold;
    font-size: 14px;
    line-height: 1.2;
}

.member-year {
    font-size: 13px;
    color: #555;
}

.delete-relation {
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
}

.delete-btn {
    background: #c00;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 14px;
    line-height: 22px;
}
