/* ==========================================================================
   Family Tree Master CSS Design System
   Implements dark glassmorphism, responsive grids, and visual animations.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --font-family: 'Outfit', sans-serif;
  
  /* Color Palette */
  --bg-primary: #08090d;
  --bg-secondary: #0f111a;
  --panel-bg: rgba(18, 20, 32, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.15);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  /* Accent Colors */
  --accent: #6366f1; /* Indigo Neon */
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.4);
  
  --male-color: #3b82f6;
  --male-bg: rgba(59, 130, 246, 0.1);
  --male-border: rgba(59, 130, 246, 0.3);
  --male-glow: rgba(59, 130, 246, 0.2);

  --female-color: #ec4899;
  --female-bg: rgba(236, 72, 153, 0.1);
  --female-border: rgba(236, 72, 153, 0.3);
  --female-glow: rgba(236, 72, 153, 0.2);

  --other-color: #8b5cf6;
  --other-bg: rgba(139, 92, 246, 0.1);
  --other-border: rgba(139, 92, 246, 0.3);
  --other-glow: rgba(139, 92, 246, 0.2);

  --danger: #ef4444;
  --danger-hover: #dc2626;

  /* Shadows & Blurs */
  --backdrop-blur: blur(16px);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Utility Classes & Buttons
   ========================================================================== */

.hidden {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}
.btn-primary:hover {
  background-color: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
}
.btn-danger:hover {
  background-color: var(--danger);
  color: #fff;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.btn-icon:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.08);
}

.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--glass-shadow);
}

/* ==========================================================================
   Authentication Screens (Login / Register)
   ========================================================================== */

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.12), transparent 45%),
              radial-gradient(circle at bottom left, rgba(236, 72, 153, 0.08), transparent 40%),
              #07080c;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  text-align: center;
  margin-bottom: 30px;
}

.auth-logo .icon-glow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #f43f5e);
  color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
  margin-bottom: 12px;
}

.auth-logo h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}
.auth-footer a:hover {
  color: #818cf8;
}

.auth-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #f87171;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
  display: none;
  align-items: center;
  gap: 8px;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.guest-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.guest-divider::before, .guest-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}
.guest-divider:not(:empty)::before { margin-right: .5em; }
.guest-divider:not(:empty)::after { margin-left: .5em; }

/* ==========================================================================
   Dashboard Main App Shell
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-rows: 68px 1fr;
  height: 100vh;
  width: 100vw;
  background: var(--bg-primary);
}

/* HEADER styling */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(15, 17, 26, 0.8);
  backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-color);
  z-index: 50;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #f43f5e);
  color: #fff;
}

.app-brand h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.app-header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tree-dropdown-wrapper {
  position: relative;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
}

.user-profile-btn .avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

/* ==========================================================================
   Three Panel Layout
   ========================================================================== */

.app-body {
  display: grid;
  grid-template-columns: 280px 1fr 340px;
  overflow: hidden;
  height: 100%;
}

/* SIDEBAR LEFT */
.sidebar-left {
  background: rgba(10, 11, 18, 0.4);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-section {
  padding: 18px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.7px;
  margin-bottom: 12px;
}

/* Stats view styling */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.stat-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.stat-lbl {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Search bar styling */
.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 10px 10px 36px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 13px;
}

/* Family Member List */
.members-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition-fast);
  margin-bottom: 6px;
  border: 1px solid transparent;
}

.member-row:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
}

.member-row.active {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
}

.member-row-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.member-row-info {
  flex: 1;
  min-width: 0;
}

.member-row-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-row-dates {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* ==========================================================================
   CENTER VIEWPORT (TREE CANVAS)
   ========================================================================== */

.viewport-center {
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
  outline: none;
  background-image: 
    radial-gradient(var(--border-color) 1.2px, transparent 1.2px), 
    radial-gradient(var(--border-color) 1.2px, transparent 1.2px);
  background-size: 32px 32px;
  background-position: 0 0, 16px 16px;
}

#tree-svg {
  width: 100%;
  height: 100%;
  user-select: none;
}

/* SVG CONNECTIONS LAYOUT styling */
.tree-connection {
  stroke-dasharray: none;
  transition: stroke var(--transition-normal), stroke-width var(--transition-normal);
}

.spouse-connection {
  stroke: var(--accent);
  stroke-dasharray: 4, 4;
}

.parent-connection {
  stroke: rgba(255, 255, 255, 0.2);
}

.descending-connection, .child-connection, .sibling-connection {
  stroke: rgba(255, 255, 255, 0.15);
}

/* Interactive connection path hover highlights */
.node-card-wrapper:hover ~ .connections-layer path {
  opacity: 0.3;
}

/* SVG NODES - Dynamic HTML Cards styling */
.node-card-wrapper {
  overflow: visible; /* Allows glows to expand outside foreignObject */
}

.family-node-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel-bg);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1.5px solid var(--border-color);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  width: 100%;
  height: 100%;
  cursor: grab;
  position: relative;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  user-select: none;
}

.family-node-card:active {
  cursor: grabbing;
}

.family-node-card:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Genders styling classes */
.gender-male {
  border-left: 4px solid var(--male-color);
}
.gender-male:hover {
  border-color: var(--male-border);
  box-shadow: 0 4px 20px var(--male-glow);
}

.gender-female {
  border-left: 4px solid var(--female-color);
}
.gender-female:hover {
  border-color: var(--female-border);
  box-shadow: 0 4px 20px var(--female-glow);
}

.gender-other {
  border-left: 4px solid var(--other-color);
}
.gender-other:hover {
  border-color: var(--other-border);
  box-shadow: 0 4px 20px var(--other-glow);
}

/* Selected state border */
.family-node-card.active-selected {
  border: 2px solid var(--accent);
  box-shadow: 0 0 16px var(--accent-glow) !important;
}

/* Focus Node pulsing glow */
.family-node-card.focus-glow {
  border-color: var(--accent);
  box-shadow: 0 0 18px var(--accent-glow);
  animation: pulseGlow 3s infinite alternate;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 10px rgba(99, 102, 241, 0.2); }
  100% { box-shadow: 0 0 24px rgba(99, 102, 241, 0.5); }
}

.avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.node-details {
  flex: 1;
  min-width: 0;
}

.node-fullname {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-lifespan {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
}

.node-lifespan svg {
  color: var(--text-muted);
}

.node-occupation {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mini Label tags inside cards */
.node-tag {
  position: absolute;
  top: -8px;
  right: 12px;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}

.focus-tag {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 5px var(--accent-glow);
}

.spouse-tag {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* Floating Navigation Controls on Canvas */
.canvas-controls {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 40;
}

.canvas-controls-horizontal {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  gap: 8px;
  z-index: 40;
}

/* ==========================================================================
   SIDEBAR RIGHT (RICH FORM EDITOR)
   ========================================================================== */

.sidebar-right {
  background: rgba(10, 11, 18, 0.4);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

.editor-header {
  padding: 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.editor-section-divider {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 22px 0 12px 0;
  display: flex;
  align-items: center;
}
.editor-section-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
  margin-left: 10px;
}

.editor-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* Custom switch checkbox styling */
.switch-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

.switch-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.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.1);
  transition: .3s;
  border-radius: 24px;
  border: 1px solid var(--border-color);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent);
  border-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: #fff;
}

/* Quick relatives action grid */
.quick-add-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.editor-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(15, 17, 26, 0.4);
}

.editor-footer .btn {
  flex: 1;
}

/* ==========================================================================
   MODALS AND DIALOGS styling
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(4, 5, 8, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  padding: 30px;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
  animation: modalEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalEnter {
  from { transform: scale(0.9) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-card.active {
  transform: scale(1);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Tooltip & info banner */
.empty-state-card {
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-secondary);
}

.empty-state-card svg {
  color: var(--text-muted);
  margin-bottom: 14px;
}

.empty-state-card h4 {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.empty-state-card p {
  font-size: 12px;
  max-width: 220px;
  line-height: 1.5;
}
