@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Inter:wght@300;400;600;700&display=swap');

:root {
  --primary-gold: #d4af37;
  --primary-gold-light: #f4d160;
  --generation-silver: #c0c0c0;
  --generation-bronze: #cd7f32;
  --generation-steel: #a0b2c6;

  --bg-dark: #0a0e17;
  --bg-card: rgba(20, 30, 48, 0.85);
  --text-light: #f8fafc;
  --text-muted: #94a3b8;
  --line-color: rgba(212, 175, 55, 0.3);
  --glow-gold: rgba(212, 175, 55, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg-dark);
  background-image:
    radial-gradient(ellipse at top, rgba(212, 175, 55, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse at bottom, rgba(20, 30, 48, 0.9) 0%, transparent 60%);
  color: var(--text-light);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  overflow-x: auto;
  position: relative;
}

/* Animated Background Particles */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: var(--primary-gold);
  border-radius: 50%;
  opacity: 0.3;
  animation: float 15s infinite ease-in-out;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 0.3;
  }

  90% {
    opacity: 0.3;
  }

  100% {
    transform: translateY(-100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Logout Button */
.logout-btn-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(20, 30, 48, 0.9);
  border: 1px solid rgba(212, 175, 55, 0.5);
  color: #d4af37;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  cursor: pointer;
}

.logout-btn:hover {
  background: #d4af37;
  color: #0a0e17;
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
}

/* Header Styling */
.hero-header {
  position: relative;
  text-align: center;
  padding: 20px 30px;
  background: rgba(20, 30, 48, 0.85);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  max-width: 500px;
  margin: 0 auto 40px;
  box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
}

.family-crest {
  width: 60px;
  height: 60px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 2px solid var(--primary-gold);
  padding: 3px;
  background: var(--bg-card);
  box-shadow:
    0 0 20px var(--glow-gold),
    inset 0 0 15px rgba(212, 175, 55, 0.1);
  animation: pulse-glow 3s ease-in-out infinite;
}

.family-crest img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

@keyframes pulse-glow {

  0%,
  100% {
    box-shadow: 0 0 30px var(--glow-gold), inset 0 0 20px rgba(212, 175, 55, 0.1);
  }

  50% {
    box-shadow: 0 0 50px var(--glow-gold), inset 0 0 30px rgba(212, 175, 55, 0.2);
  }
}

.main-title {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 3px;
  margin-bottom: 5px;
  background: linear-gradient(135deg, #fff 0%, #d4af37 50%, #fff 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shine 5s linear infinite;
}

@keyframes shine {
  to {
    background-position: 200% center;
  }
}

.subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.decorative-line {
  width: 100px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary-gold), transparent);
  margin: 8px auto;
}

/* Stats Section */
.stats-container {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}

.stat-number {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-gold);
  display: block;
}

.stat-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Tree Container */
/* Zoom Controls Styling */
.tree-section {
  overflow: hidden;
  /* Taşmayı gizle, pan ile yöneteceğiz */
  cursor: grab;
  /* Sürükleme imleci */
  min-height: 100vh;
  /* Minimum yükseklik */
  border-top: 1px solid rgba(212, 175, 55, 0.1);
  border-bottom: 1px solid rgba(212, 175, 55, 0.1);
  position: relative;
  background: radial-gradient(circle at center, rgba(20, 30, 48, 0.4) 0%, transparent 70%);
}

.tree-section:active {
  cursor: grabbing;
  /* Tutma imleci */
}

.tree-container {
  transform-origin: 0 0;
  /* Hesaplamalar için sol üst köşe referans alınmalı */
  position: absolute;
  /* Tam kontrol için absolute */
  top: 0;
  left: 0;
  transition: transform 0.05s linear;
  /* Daha hızlı ve liner tepki */
  width: fit-content;
  touch-action: none;
  /* İlk yüklemede düzgün görünmesi için padding */
  padding: 50px;
}

/* Tree Structure */
.tree ul {
  padding-top: 40px;
  position: relative;
  display: flex;
  justify-content: center;
}

.tree li {
  float: left;
  text-align: center;
  list-style-type: none;
  position: relative;
  padding: 40px 10px 0 10px;
  transition: all 0.4s ease;
}

/* Enhanced Connectors */
.tree li::before,
.tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 2px solid var(--line-color);
  width: 50%;
  height: 40px;
  transition: all 0.3s ease;
}

.tree li::after {
  right: auto;
  left: 50%;
  border-left: 2px solid var(--line-color);
}

.tree li:only-child::after,
.tree li:only-child::before {
  display: none;
}

.tree li:only-child {
  padding-top: 0;
}

.tree li:first-child::before,
.tree li:last-child::after {
  border: 0 none;
}

.tree li:last-child::before {
  border-right: 2px solid var(--line-color);
  border-radius: 0 10px 0 0;
}

.tree li:first-child::after {
  border-radius: 10px 0 0 0;
}

.tree ul ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 2px solid var(--line-color);
  width: 0;
  height: 40px;
}

/* Enhanced Member Card */
.member-card {
  position: relative;
  display: inline-block;
  padding: 18px 20px;
  min-width: 150px;
  background: var(--bg-card);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 12px;
  backdrop-filter: blur(15px);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  overflow: visible;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}


.member-card:hover {
  transform: translateY(-8px) scale(1.03);
  border-color: var(--primary-gold);
  box-shadow:
    0 15px 35px rgba(0, 0, 0, 0.4),
    0 0 25px rgba(212, 175, 55, 0.15);
  z-index: 10;
}

/* Photo Styling & Generation Variations */
.member-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 12px;
  border: 2px solid var(--primary-gold);
  padding: 3px;
  background: var(--bg-dark);
  overflow: hidden;
  position: relative;
  transition: all 0.3s ease;
}

.member-photo img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  transition: all 0.5s ease;
}

/* Generation Color Coding & Filters */

/* Gen 3: Silver - Mirror Effect (Looks Left) */
.member-photo.gen-silver {
  border-color: var(--generation-silver);
}

.member-photo.gen-silver img {
  filter: grayscale(100%) sepia(20%) hue-rotate(180deg) brightness(1.1);
  transform: scaleX(-1);
  /* Yüzü sola çevir */
}

.member-card:hover .member-photo.gen-silver {
  box-shadow: 0 0 15px rgba(192, 192, 192, 0.4);
}

/* Gen 4: Bronze - Standard (Looks Right) */
.member-photo.gen-bronze {
  border-color: var(--generation-bronze);
}

.member-photo.gen-bronze img {
  filter: sepia(80%) hue-rotate(-30deg) saturate(1.2);
  /* Orijinal yön */
}

.member-card:hover .member-photo.gen-bronze {
  box-shadow: 0 0 15px rgba(205, 127, 50, 0.4);
}

/* Gen 5: Steel/Blue - Mirror Effect (Looks Left) */
.member-photo.gen-steel {
  border-color: var(--generation-steel);
}

.member-photo.gen-steel img {
  filter: grayscale(100%) sepia(30%) hue-rotate(190deg) saturate(2);
  transform: scaleX(-1);
  /* Yüzü sola çevir */
}

.member-card:hover .member-photo.gen-steel {
  box-shadow: 0 0 15px rgba(160, 178, 198, 0.4);
}

/* Hover Effects on Photo */
.member-card:hover .member-photo img {
  transform: scaleX(1);
  /* Hoverda orijinal haline dönsün */
  filter: brightness(1.15) !important;
}

/* Specific overwrite for mirrored classes on hover to keep mirror but remove filter? 
   No, let's reset to pure Gold patriarch state on hover for uniform magic */
.member-card:hover .member-photo.gen-silver img,
.member-card:hover .member-photo.gen-steel img {
  transform: scale(1.1) scaleX(-1);
  /* Yönünü koruyarak büyüt */
}

/* Text Styling */
.member-title {
  display: block;
  font-size: 0.65rem;
  color: var(--primary-gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  opacity: 0.8;
}

.member-name {
  display: block;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.3;
}

.original-name-small {
  display: block;
  font-size: 0.65rem;
  color: var(--primary-gold-light);
  margin-top: 4px;
  opacity: 0.9;
  font-style: italic;
}

/* Add Member Handles */
.add-handle {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.member-card:hover .add-handle {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Kartın hover alanını genişlet ki handle'lara ulaşılabilsin */
.member-card::after {
  content: '';
  position: absolute;
  top: -60px;
  left: -60px;
  right: -60px;
  bottom: -60px;
  z-index: -1;
  pointer-events: auto;
}

/* Üst çizgi + buton (Baba ekle) */
.add-handle-parent {
  top: 0;
  left: 50%;
  transform: translate(-50%, -100%);
  flex-direction: column-reverse;
  padding-bottom: 10px;
  padding-top: 10px;
}

.add-handle-parent .add-line {
  width: 2px;
  height: 30px;
  background: linear-gradient(to top, var(--primary-gold), rgba(212, 175, 55, 0.3));
}

/* Handle'ın kendisi hover olunca da görünsün */
.add-handle:hover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Alt çizgi + buton (Çocuk ekle) */
.add-handle-child {
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  flex-direction: column;
}

.add-handle-child .add-line {
  width: 2px;
  height: 30px;
  background: linear-gradient(to bottom, var(--primary-gold), rgba(212, 175, 55, 0.3));
}

/* Yan çizgi + buton (Kardeş ekle) */
.add-handle-sibling {
  top: 50%;
  right: 0;
  transform: translate(100%, -50%);
  flex-direction: row;
}

.add-handle-sibling .add-line {
  width: 30px;
  height: 2px;
  background: linear-gradient(to right, var(--primary-gold), rgba(212, 175, 55, 0.3));
}

.add-handle .add-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(20, 30, 48, 0.95);
  color: var(--primary-gold);
  border: 1.5px solid var(--primary-gold);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: all 0.3s ease;
}

.add-handle .add-btn:hover {
  background: var(--primary-gold);
  color: var(--bg-dark);
  transform: scale(1.3);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.6);
}

/* Delete Button */
.delete-member-btn {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(20, 30, 48, 0.95);
  color: #ef4444;
  border: 1.5px solid #ef4444;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;
}

.member-card:hover .delete-member-btn {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.delete-member-btn:hover {
  background: #ef4444;
  color: #fff;
  transform: scale(1.3);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

/* Root Node Special Styling */
.root-node>.member-card {
  min-width: 220px;
  border-width: 2px;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(20, 30, 48, 0.95));
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(212, 175, 55, 0.15);
}

.root-node>.member-card .member-photo {
  width: 100px;
  height: 100px;
  border-width: 3px;
  box-shadow: 0 0 20px var(--glow-gold);
}

.root-node>.member-card .member-name {
  font-size: 1.3rem;
}

/* Footer */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 30px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.2);
  margin-top: auto;
}

.footer-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-text .highlight {
  color: var(--primary-gold);
  font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
  .main-title {
    font-size: 2rem;
  }

  .member-card {
    min-width: 120px;
    padding: 15px 10px;
  }

  .member-photo {
    width: 60px;
    height: 60px;
  }

  .member-name {
    font-size: 0.8rem;
  }
}

/* Scroll indicator */
.scroll-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: bounce 2s infinite;
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 15px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
}

@keyframes bounce {

  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateX(-50%) translateY(0);
  }

  40% {
    transform: translateX(-50%) translateY(-10px);
  }

  60% {
    transform: translateX(-50%) translateY(-5px);
  }
}

.zoom-controls {
  position: fixed;
  bottom: 30px;
  right: 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}

.zoom-btn {
  width: 45px;
  height: 45px;
  border-radius: 50% !important;
  background: rgba(20, 30, 48, 0.9) !important;
  border: 1px solid var(--primary-gold) !important;
  color: var(--primary-gold) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease !important;
}

.zoom-btn:hover {
  background: var(--primary-gold) !important;
  color: var(--bg-dark) !important;
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
}

/* Photo Upload Modal */
.photo-upload-modal {
  background: var(--bg-card);
  border: 1px solid rgba(212, 175, 55, 0.3);
  backdrop-filter: blur(15px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.photo-upload-modal .modal-header {
  background: rgba(212, 175, 55, 0.05);
  border-color: var(--primary-gold) !important;
  flex-shrink: 0;
}

.photo-upload-modal .modal-body {
  color: var(--text-light);
  overflow-y: auto;
  flex: 1;
}

.upload-area {
  border: 2px dashed rgba(212, 175, 55, 0.4);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: rgba(212, 175, 55, 0.02);
}

.upload-area:hover {
  border-color: var(--primary-gold);
  background: rgba(212, 175, 55, 0.05);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.1);
}

.upload-area i {
  font-size: 3rem;
  color: var(--primary-gold);
  margin-bottom: 10px;
  display: block;
}

.upload-area p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.95rem;
}

#preview-container {
  text-align: center;
}

#preview-container img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  margin-top: 10px;
}

.photo-upload-modal .modal-footer {
  border-color: var(--primary-gold) !important;
  background: rgba(212, 175, 55, 0.02);
}

.photo-upload-modal .btn-warning {
  background: var(--primary-gold) !important;
  color: var(--bg-dark) !important;
  border-color: var(--primary-gold) !important;
}

.photo-upload-modal .btn-warning:hover {
  background: var(--primary-gold-light) !important;
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

/* Photo Lightbox */
.photo-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  cursor: pointer;
}

.lightbox-content {
  position: relative;
  z-index: 1001;
  max-width: 90%;
  max-height: 90%;
  animation: zoomIn 0.3s ease;
}

.lightbox-image {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 8px;
  box-shadow: 0 0 50px rgba(212, 175, 55, 0.3);
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: #d4af37;
  font-size: 3rem;
  cursor: pointer;
  transition: color 0.3s ease;
  z-index: 1002;
}

.lightbox-close:hover {
  color: #f4d160;
}

@keyframes zoomIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Crop Container */
.crop-container {
  max-height: 300px;
  overflow: auto;
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#cropperImage {
  max-height: 280px !important;
  width: auto;
}

.crop-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.crop-controls .btn {
  border-color: var(--primary-gold) !important;
  color: var(--primary-gold) !important;
}

.crop-controls .btn:hover {
  background: var(--primary-gold) !important;
  color: var(--bg-dark) !important;
}

.original-name-section {
  background: rgba(212, 175, 55, 0.05);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.2);
}

.original-name-section .form-label {
  color: var(--text-light);
  font-weight: 500;
  margin-bottom: 8px;
}

.original-name-section .form-control {
  background: rgba(20, 30, 48, 0.6);
  border-color: rgba(212, 175, 55, 0.3);
  color: var(--text-light);
}

.original-name-section .form-control:focus {
  background: rgba(20, 30, 48, 0.8);
  border-color: var(--primary-gold);
  color: var(--text-light);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}