/* ============================================================
   Arbre généalogique - styles applicatifs (hors CSS Family Chart)
   ============================================================ */

:root {
  --color-bg: radial-gradient(ellipse at 20% 30%, rgba(80,120,160,0.22) 0%, transparent 60%), radial-gradient(ellipse at 80% 70%, rgba(140,80,120,0.18) 0%, transparent 55%), linear-gradient(145deg, rgb(18,22,34) 0%, rgb(28,32,44) 40%, rgb(22,26,36) 100%);
  --color-text: #fff;
  --color-accent-purple: #6a5acd;
  /* --color-accent-blue: #457D35; */
  /* --color-accent-pink: #B99A2C; */
  --color-accent-blue: #4a90d9;
  --color-accent-pink: #d9699a;
  --color-accent-bluedark: #6d87a2;
  --color-accent-pinkdark: #8f7580;
  --color-danger: #d9534f;
  --sidebar-width: 380px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: 'Roboto', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  overflow: hidden;
}

.screen { width: 100%; height: 100%; }
.hidden { display: none !important; }

/* ---------------- Écran de connexion ---------------- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 32px 40px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
  box-shadow: 20px 20px 15px rgba(0,0,0,0.4);
}

.login-logo { width: 80px; margin: 0 auto 8px; }
.login-card h1 { font-size: 1.3rem; margin: 0 0 12px; }
.login-card label { text-align: left; font-size: 0.85rem; opacity: 0.8; }
.login-card input {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: var(--color-text);
  font-size: 1rem;
}
.login-card button {
  margin-top: 12px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--color-accent-blue), var(--color-accent-purple));
  color: white;
  font-weight: bold;
  cursor: pointer;
}
.login-card button:hover { opacity: 0.9; }

.error-message { color: #ff8a80; font-size: 0.85rem; }
.info-message { color: #b3d9ff; font-size: 0.85rem; }

/* ---------------- Application principale ---------------- */
#app-screen { position: relative; }

#logout-btn {
  position: fixed;
  top: 16px; left: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(20,20,20,0.85);
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--color-text);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
#logout-btn:hover { background: rgba(255,255,255,0.15); }
#logout-btn i { font-size: 1rem; }

#reset-tree-btn {
  position: fixed;
  top: 66px; left: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(20,20,20,0.85);
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--color-text);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
#reset-tree-btn:hover { background: rgba(255,255,255,0.15); }
#reset-tree-btn i { font-size: 1rem; }

#mode-switch-container {
  position: fixed;
  top: 116px; left: 16px;
  z-index: 60;
  background: rgba(20,20,20,0.85);
  padding: 8px 14px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.switch-label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.switch { position: relative; display: inline-block; width: 42px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255,255,255,0.2);
  border-radius: 22px;
  transition: 0.2s;
}
.slider::before {
  position: absolute; content: "";
  height: 16px; width: 16px; left: 3px; bottom: 3px;
  background-color: white; border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider { background: linear-gradient(90deg, var(--color-accent-blue), var(--color-accent-purple)); }
.switch input:checked + .slider::before { transform: translateX(20px); }

#FamilyChart {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 8px;
  width: 100%;
  background: var(--color-bg);
}

/* ---------------- Overlay latéral ---------------- */
#sidebar-overlay {
  position: fixed;
  top: 0; right: 0;
  width: var(--sidebar-width);
  max-width: 90vw;
  height: 100%;
  background: rgb(24,24,24);
  box-shadow: -4px 0 20px rgba(0,0,0,0.5);
  z-index: 100;
  padding: 24px 20px;
  overflow-y: auto;
  transform: translateX(0);
  transition: transform 0.25s ease;
}
#sidebar-overlay.hidden { transform: translateX(100%); display: block !important; visibility: hidden; }

.overlay-close {
  position: absolute; top: 12px; right: 16px;
  background: transparent; border: none; color: var(--color-text);
  font-size: 1.3rem; cursor: pointer; line-height: 1;
}

.sidebar-section { margin-top: 8px; }
.sidebar-section:empty { margin: 0; }

.person-info-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 0.9rem; }
.person-info-row span:first-child { opacity: 0.7; }
.person-avatar { width: 100%; max-height: 220px; object-fit: cover; border-radius: 8px; margin-bottom: 12px; }
.person-title { font-size: 1.2rem; font-weight: bold; margin-bottom: 12px; }

.show-direct-family-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin: 12px 0 4px; padding: 10px;
  border: 1px solid rgba(255,255,255,0.25); border-radius: 6px;
  background: rgba(255,255,255,0.08); color: var(--color-text);
  font-size: 0.85rem; cursor: pointer;
}
.show-direct-family-btn:hover { background: rgba(255,255,255,0.18); }

.documents-title { font-size: 0.95rem; font-weight: bold; margin: 16px 0 8px; opacity: 0.9; }
.documents-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.document-thumb {
  position: relative;
  width: 70px; height: 70px; border-radius: 6px; overflow: hidden; cursor: pointer;
  background: rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; text-align: center; border: 1px solid rgba(255,255,255,0.1);
}
.document-thumb img { width: 100%; height: 100%; object-fit: cover; }
.document-thumb.document-principale { outline: 2px solid gold; }
.document-delete-btn {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(217,83,79,0.9); color: white; border: none;
  font-size: 0.65rem; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.document-principal-btn {
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(20,20,20,0.75); color: rgba(255,255,255,0.6); border: none;
  font-size: 0.65rem; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.document-principal-btn.is-principale { color: gold; background: rgba(20,20,20,0.9); }

.upload-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.upload-row label {
  display: inline-block; padding: 6px 10px; border-radius: 6px; font-size: 0.8rem;
  background: rgba(255,255,255,0.1); cursor: pointer;
}
.upload-row input[type="file"] { display: none; }
.upload-row select { padding: 4px; border-radius: 6px; }

/* ---------------- Overlay documents plein écran ---------------- */
#documents-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
#documents-overlay.hidden { display: none; }
#documents-carousel { max-width: 85vw; max-height: 85vh; display: flex; align-items: center; justify-content: center; }
#documents-carousel img { max-width: 85vw; max-height: 85vh; border-radius: 6px; }
#documents-carousel iframe { width: 80vw; height: 85vh; border: none; background: white; }
#documents-carousel .doc-text { background: white; color: #111; padding: 24px; max-width: 700px; max-height: 80vh; overflow-y: auto; white-space: pre-wrap; border-radius: 6px; }

.carousel-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.1); border: none; color: white;
  font-size: 1.4rem; width: 56px; height: 56px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.carousel-prev { left: 24px; }
.carousel-next { right: 24px; }
#documents-close.overlay-close { z-index: 210; }

/* ---------------- Barre d'inactivité ---------------- */
#inactivity-bar-container {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 8px;
  background: rgba(255,255,255,0.05);
  z-index: 300;
}
#inactivity-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--color-accent-blue), var(--color-accent-purple));
  transition: width 0.25s linear;
}

/* Boutons génériques dans le formulaire natif EditTree, pour rester dans le thème */
#sidebar-form button, #sidebar-form input, #sidebar-form select {
  font-family: inherit;
}

/* ---------------- Carte personne personnalisée (Family Chart) ---------------- */
/* Carte strictement carrée : moitié supérieure = photo, moitié inférieure = texte.
   Fond opaque pour masquer totalement les liens SVG affichés derrière les cartes.
   NB : setCardInnerHtmlCreator() de Family Chart n'applique PAS le cardDim au
   conteneur (il n'ajoute aucun wrapper dimensionné), la taille doit donc être
   fixée explicitement ici et doit rester cohérente avec setCardDim() dans app.js. */
.fc-card-inner {
  width: 130px;
  height: 130px;
  display: flex;
  flex-direction: column;
  border-radius: 15px;
  overflow: hidden;
  background: rgb(45, 45, 45);
  border: 2px solid rgba(255,255,255,0.15);
}
.f3 .card-male .fc-card-inner { border-color: var(--color-accent-blue); }
.f3 .card-female .fc-card-inner { border-color: var(--color-accent-pink); }
.f3 .card-main .fc-card-inner { border-color: gold; border-width: 3px; }

.fc-card-photo-wrap {
  position: relative;
  flex: 0 0 50%;
  height: 50%;
  min-height: 0;
  background: rgb(20, 20, 20);
}
.fc-card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.fc-card-photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: rgba(255,255,255,0.3);
}
.fc-card-gender {
  position: absolute;
  bottom: 4px; left: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.fc-card-gender.fc-gender-M { background: var(--color-accent-blue); }
.fc-card-gender.fc-gender-F { background: var(--color-accent-pink); }

.fc-card-body {
  flex: 0 0 50%;
  height: 50%;
  min-height: 0;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgb(60, 60, 60);
}
/* .f3 .card-male .fc-card-body { background: var(--color-accent-blue); } */
/* .f3 .card-female .fc-card-body { background: var(--color-accent-pink); } */


.fc-card-name {
  width: 100%;
  font-size: 0.72rem;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fc-card-dates {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 0.62rem;
  opacity: 0.85;
  margin-top: 2px;
}
.fc-card-dates .fc-card-date { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
