* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    height: 100vh;
    background-color: #fcf9f6; /* Fond doux inspiré de ton modèle */
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* --- MENU LATÉRAL --- */
.sidebar {
    width: 320px;
    background-color: #ffffff;
    border-right: 2px solid #e0e0e0;
    transition: width 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar.collapsed {
    width: 0px;
}

.sidebar.collapsed .sidebar-content {
    display: none;
}

#toggle-sidebar {
    position: absolute;
    right: -40px;
    top: 15px;
    width: 40px;
    height: 40px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-left: none;
    cursor: pointer;
    border-radius: 0 5px 5px 0;
    font-size: 1.2rem;
}

.sidebar-content {
    padding: 20px;
    overflow-y: auto;
    width: 320px; /* Maintient la largeur interne même pendant l'animation */
}

form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 15px 0 25px 0;
}

form input, form textarea, form button {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

form button, #export-btn {
    background-color: #d4af37; /* Code couleur "Or" */
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    transition: background 0.2s;
}

form button:hover, #export-btn:hover {
    background-color: #b5952f;
}

/* --- LISTE DES PERSONNES --- */
.draggable-item {
    padding: 10px;
    background: #f9f9f9;
    border: 1px solid #eee;
    margin-bottom: 10px;
    border-radius: 8px;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 15px;
}

.draggable-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

/* --- ZONE CANVAS --- */
.canvas-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.toolbar {
    padding: 15px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    z-index: 5;
}

/* Le parent qui fait office de "Caméra" */
#viewport {
    flex-grow: 1;
    position: relative;
    overflow: hidden; /* Masque ce qui sort de la vue */
    background-color: #e9e5e1; /* Gris doux pour le fond de l'application */
    cursor: grab;
}

#viewport:active {
    cursor: grabbing;
}

/* Le canvas devient une "feuille" physique */
#tree-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 2970px; /* Dimension A4 paysage par défaut */
    height: 2100px;
    background: #ffffff;
    box-shadow: 0 0 20px rgba(0,0,0,0.15); /* Effet d'ombre de la feuille */
    transform-origin: 0 0; /* Important pour le zoom */
}

#connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* --- BULLES (Rendu final sur l'arbre) --- */
.bubble {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Translate permet de centrer la bulle exactement sur le curseur de la souris lors du drop */
    transform: translate(-50%, -50%); 
    z-index: 2;
    cursor: pointer;
    transform-origin: center center; /* Important pour que le scale soit propre */
    transition: transform 0.2s ease-out; /* Animation fluide quand on change la taille */
}

.bubble-img-container {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 3px solid #d4af37; /* Anneau doré */
    overflow: hidden;
    background: #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.bubble img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bubble-info {
    text-align: center;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 12px;
    border-radius: 12px;
    min-width: 120px;
}

.bubble-role {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 2px;
}

.bubble-name {
    font-family: 'Georgia', serif; /* Typographie plus classique pour les noms */
    font-weight: bold;
    color: #4a3b32;
    font-size: 1.1rem;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    width: 90%;
    max-width: 500px;
}

.img-container {
    max-height: 400px;
    margin: 15px 0;
}

.img-container img {
    max-width: 100%;
    display: block; /* Nécessaire pour Cropper.js */
}

#btn-crop, #btn-cancel-crop {
    padding: 10px 15px;
    margin: 5px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

#btn-crop { background-color: #d4af37; color: white; }
#btn-cancel-crop { background-color: #ccc; color: #333; }

/* --- SÉLECTION ET INFOBULLES --- */
.bubble.selected .bubble-img-container {
    border-color: #e74c3c; /* Changement de couleur de la bordure en rouge/orange pour la sélection */
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.5);
}

.action-tooltip {
    position: absolute;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 6px 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    display: flex;
    gap: 8px;
    transform: translate(-50%, -130%); /* Positionne l'infobulle juste au-dessus du point ciblé */
}

.action-tooltip button {
    background: #f8f9fa;
    border: 1px solid #ddd;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-tooltip button:hover {
    background: #f0f0f0;
    border-color: #bbb;
}

.action-tooltip .btn-delete:hover {
    background: #fde8e8;
    border-color: #e74c3c;
}

/* Style pour la barre de taille dans la modale */
.range-container {
    margin: 15px 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.range-container label {
    font-size: 0.9rem;
    color: #666;
}

#edit-person-scale {
    cursor: pointer;
    accent-color: #d4af37;
}

.btn-cancel {
    background-color: #eee !important;
    color: #333 !important;
    margin-top: 5px;
}

/* Nouveaux styles pour les courbes SVG et l'éditeur de liens */
path.connection-line {
    fill: none;
    transition: stroke 0.2s, stroke-width 0.2s, filter 0.2s;
}

path.connection-line:hover {
    stroke-width: 5px !important;
    filter: drop-shadow(0px 0px 4px rgba(212, 175, 55, 0.6));
}

#edit-link-form select, #edit-link-form input[type="color"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    margin-top: 5px;
    cursor: pointer;
}

#edit-link-form input[type="color"] {
    height: 40px;
}

/* --- AMÉLIORATION DE LA TOOLBAR --- */
.toolbar button {
    background-color: #ffffff;
    color: #4a3b32;
    border: 1px solid #d4af37;
    padding: 8px 15px;
    border-radius: 4px;
    margin-left: 10px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.toolbar button:hover {
    background-color: #fcf9f6;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#export-btn {
    background-color: #d4af37;
    color: #fff;
}

#export-btn:hover {
    background-color: #b5952f;
}

#auth-btn {
    border-color: #4285F4;
    color: #4285F4;
}

#auth-btn:hover {
    background-color: #4285F4;
    color: white;
}

/* --- DASHBOARD MULTI-CANVAS --- */
.canvas-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.canvas-item:hover {
    background-color: #fcf9f6;
    border-left: 3px solid #d4af37;
}

/* --- ÉLÉMENTS DÉCORATIFS --- */
.btn-deco {
    background: #f4f4f4;
    border: 1px solid #ddd;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.btn-deco:hover {
    background: #e9e9e9;
}

.custom-element {
    position: absolute;
    transform-origin: center center;
    z-index: 1; /* Permet de rester derrière les bulles principales */
    cursor: pointer;
}

.custom-element.selected {
    outline: 2px dashed #e74c3c;
    outline-offset: 4px;
}

.custom-text-content {
    white-space: pre-wrap;
    text-align: center;
}

.custom-img-content {
    max-width: 250px; 
    display: block;
    pointer-events: none; 
}

/* --- STYLES DE BORDURES PERSONNALISÉS --- */
.bubble-style-classic { border-style: solid; }
.bubble-style-dashed { border-style: dashed; }
.bubble-style-double { border-style: double; border-width: 6px !important; }

/* Simule un anneau extérieur de feuilles / perles pour le côté mariage */
.bubble-style-floral {
    outline: 3px dotted currentColor;
    outline-offset: 4px;
    border-style: solid;
}

/* Retire la bordure classique et applique une aura lumineuse interne et externe */
.bubble-style-glow {
    border-color: transparent !important;
    box-shadow: 0 0 15px currentColor, inset 0 0 10px currentColor;
}