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

:root {
  /* Common */
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --secondary: #6366f1;
  --accent: #38bdf8;
  --radius: 1.25rem;
}

/* Light Theme Variables */
:root, [data-theme="light"] {
  --background: #f8fafc;
  --foreground: #020617;
  --muted: #64748b;
  --glass: linear-gradient(135deg, rgba(0,0,0,0.03) 0%, rgba(0,0,0,0.01) 100%);
  --glass-border: rgba(0, 0, 0, 0.1);
  --card-bg: rgba(255, 255, 255, 0.7);
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --background: #020617;
  --foreground: #f8fafc;
  --muted: #94a3b8;
  --glass: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.03) 100%);
  --glass-border: rgba(255, 255, 255, 0.1);
  --card-bg: rgba(15, 23, 42, 0.7);
}

/* Auto Theme (Dark preference) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #020617;
    --foreground: #f8fafc;
    --muted: #94a3b8;
    --glass: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.03) 100%);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(15, 23, 42, 0.7);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-color: var(--glass-border);
}


body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.bg-blur {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: -1;
}

.blur-1 {
  position: absolute;
  top: -10%;
  right: -5%;
  width: 60%;
  height: 60%;
  background: rgba(56, 189, 248, 0.07);
  border-radius: 50%;
  filter: blur(120px);
}

.blur-2 {
  position: absolute;
  bottom: -10%;
  left: -5%;
  width: 60%;
  height: 60%;
  background: rgba(99, 102, 241, 0.07);
  border-radius: 50%;
  filter: blur(120px);
}


/* Animations */
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes topProgress {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(-30%); }
  100% { transform: translateX(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-top-progress {
  animation: topProgress 0.4s ease-out forwards;
}

.animate-premium-entry {
  animation: fadeInScale 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.premium-glass {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

/* Tree Nodes */
.node-content {
  padding: 1rem;
  border-radius: 1.5rem;
  min-width: 140px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  z-index: 2;
  border: 1px solid var(--glass-border);
  background: var(--card-bg);
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}


.node-content:hover {
  transform: translateY(-5px) scale(1.04);
  border-color: var(--primary);
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.22);
}

.node-content.highlighted {
  border-color: var(--primary);
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.45);
  transform: scale(1.1);
  z-index: 10;
}

.node-photo {
  width: 60px;
  height: 60px;
  border-radius: 1.25rem;
  margin-bottom: 0.75rem;
  object-fit: cover;
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  margin-right: auto;
}

.node-name {
  font-weight: bold;
  font-size: 0.9rem;
  line-height: 1.2;
}

.node-age {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: bold;
}

.relation-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: bold;
  padding: 0.15rem 0.6rem;
  border-radius: 1rem;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.relation-badge.son {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.relation-badge.brother {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.4);
  color: #a855f7;
}

.relation-badge.father {
  background: rgba(251, 191, 36, 0.2);
  border-color: rgba(251, 191, 36, 0.4);
  color: #fbbf24;
}

.relation-badge.root {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

/* Tree Connectors */
.tree-container {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 5rem;
  display: flex;
  justify-content: center;
}

.tree {
  display: flex;
  justify-content: center;
  padding: 1rem;
  min-width: max-content;
}

.node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 0 1rem;
}

.node::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 2rem;
  background: var(--glass-border);
}

.tree > .node::before {
  display: none;
}

.children-container {
  display: flex;
  justify-content: center;
  position: relative;
  padding-top: 2rem;
}

.children-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 2rem;
  background: var(--glass-border);
}

.children-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--glass-border);
}

.node:only-child > .children-container::after {
  display: none;
}

.node:first-child > .children-container::after {
  left: 50%;
}

.node:last-child > .children-container::after {
  right: 50%;
}

/* UI Elements */
.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 1rem;
  border: none;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  color: white;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 0.5rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.fab {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
  z-index: 40;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(8px);
}

.modal.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2.5rem;
  border-radius: 2.5rem;
}

.modal-content::-webkit-scrollbar {
  width: 6px;
}
.modal-content::-webkit-scrollbar-track {
  background: transparent;
}
.modal-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.form-control {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  color: white;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

/* Detail Modal specific */
.detail-header {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.detail-photo {
  width: 90px;
  height: 90px;
  border-radius: 2rem;
  object-fit: cover;
  border: 2px solid var(--primary);
}

.detail-info {
  flex: 1;
  text-align: right;
}

.detail-name {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.detail-stats {
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-around;
  background: var(--card-bg);
  border-radius: 1.5rem;
  padding: 1.25rem;
  margin-bottom: 2rem;
  border: 1px solid var(--glass-border);
}


.stat-item {
  text-align: center;
}

.stat-val {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: bold;
}

.section-title {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: bold;
  margin-bottom: 1rem;
  text-align: right;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.5rem;
  text-transform: uppercase;
}

.relative-chip {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 1.25rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.relative-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
}

.chip-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chip-info {
  flex: 1;
  text-align: right;
}

.chip-name {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
}

.chip-label {
  font-size: 0.7rem;
  color: var(--primary);
}

/* Header & Navigation */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 1.5rem 1rem 1rem;
  width: 100%;
}

.header-container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  border-radius: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.logo-icon {
  background: rgba(56, 189, 248, 0.2);
  padding: 0.6rem;
  border-radius: 1.25rem;
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: bold;
  line-height: 1.2;
}

.logo-text p {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.search-container {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 1.25rem;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  color: white;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.neon-text {
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.neon-glow-primary {
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

/* Splash Screen */
.splash {
  min-height: 100vh;
  background: var(--background);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(56, 189, 248, 0.1);
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.spinner {
  width: 4rem;
  height: 4rem;
  border: 2px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Main Layout */
.main-content {
  flex: 1;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Tree Visualization Styles: Horizontal */
.tree-horizontal .tree {
  flex-direction: column;
  align-items: flex-start;
}

.tree-horizontal .node {
  flex-direction: row;
  align-items: center;
  padding: 1rem 0;
}

.tree-horizontal .node::before {
  top: 50%;
  left: -2rem;
  width: 2rem;
  height: 2px;
}

.tree-horizontal .children-container {
  flex-direction: column;
  padding-top: 0;
  padding-left: 2rem;
  align-items: flex-start;
}

.tree-horizontal .children-container::before {
  top: 50%;
  left: 0;
  width: 2px;
  height: 100%;
}

.tree-horizontal .children-container::after {
  left: 0;
  top: 0;
  width: 2px;
  height: 100%;
}

/* Compact View Styles */
.tree-compact .node-content {
  padding: 0.5rem;
  min-width: 100px;
}

.tree-compact .node-photo {
  width: 40px;
  height: 40px;
  margin-bottom: 0.25rem;
}

.tree-compact .node-name {
  font-size: 0.75rem;
}

.tree-compact .node-age {
  display: none;
}

.tree-compact .btn-icon {
  width: 20px;
  height: 20px;
}

footer {
  padding: 2.5rem;
  text-align: center;
  border-top: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.2);
  margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    padding: 1rem;
  }
  .search-container {
    max-width: 100%;
    width: 100%;
  }
}
