/* ============================================
   משפחת בוקשפן - עיצוב גלובלי
   Design System: "Modern Heritage" (שורשים מודרניים)
   ============================================ */


/* ============================================
   CSS Variables - Design System
   ============================================ */
:root {
  /* Color Palette - Modern Heritage */
  --primary: #5D7052;           /* Sage Green - buttons, primary actions */
  --secondary: #8C6A5D;         /* Warm Earth/Terracotta - highlights */
  --bg-body: #F9F7F2;           /* Off-white/Cream - never pure white */
  --bg-card: #FFFFFF;           /* Pure white for cards only */
  --text-main: #2C2C2C;         /* Soft Black - for readability */
  --text-muted: #666666;        /* For metadata */
  --border-light: #D1D5DB;      /* Light gray for connections */
  
  /* Spacing - Using REM (Responsive) */
  --spacing-xs: clamp(0.375rem, 0.5vw + 0.25rem, 0.5rem);      /* 6-8px */
  --spacing-sm: clamp(0.5rem, 0.75vw + 0.25rem, 0.75rem);      /* 8-12px */
  --spacing-md: clamp(0.75rem, 1vw + 0.5rem, 1rem);            /* 12-16px */
  --spacing-lg: clamp(1rem, 1.5vw + 0.5rem, 1.5rem);          /* 16-24px */
  --spacing-xl: clamp(1.5rem, 2vw + 0.5rem, 2rem);           /* 24-32px */
  --spacing-xxl: clamp(2rem, 3vw + 0.5rem, 3rem);             /* 32-48px */
  
  /* Border & Shadows - Soft & Rounded */
  --border-radius: clamp(0.75rem, 1vw + 0.5rem, 1rem);        /* 12-16px */
  --border-radius-pill: clamp(2.5rem, 3vw + 1rem, 3.125rem);  /* 40-50px */
  --box-shadow: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.06);
  --box-shadow-hover: 0 0.375rem 1.5rem rgba(0, 0, 0, 0.08);
  
  /* Typography - Fluid (Responsive) */
  --font-heading: 'Heebo', sans-serif;
  --font-body: 'Assistant', sans-serif;
  --font-size-base: clamp(14px, 1.5vw + 8px, 16px);            /* 14-16px */
  --font-size-sm: clamp(12px, 1.2vw + 6px, 14px);             /* 12-14px */
  --font-size-md: clamp(14px, 1.5vw + 8px, 16px);             /* 14-16px */
  --font-size-lg: clamp(18px, 2vw + 10px, 20px);             /* 18-20px */
  --font-size-xl: clamp(20px, 2.5vw + 12px, 24px);           /* 20-24px */
  --font-size-xxl: clamp(24px, 3vw + 16px, 32px);            /* 24-32px */
  --line-height-base: 1.6;
  
  /* Container Max Widths - Responsive */
  --container-sm: 100%;
  --container-md: min(90%, 768px);
  --container-lg: min(90%, 1200px);
  --container-xl: min(95%, 1400px);
  
  /* Transitions */
  --transition: 0.3s ease;
  
  /* Z-index layers */
  --z-overlay: 50;
  --z-modal: 100;
  --z-navbar: 1000;
  --z-error: 1001;
}

/* ============================================
   Google Fonts Import
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;600;700&family=Assistant:wght@400;500;600&display=swap');

/* ============================================
   Reset & Base Styles
   ============================================ */
html {
  text-align: center;
  direction: rtl;
  /* scroll-behavior: smooth; - commented out for Safari compatibility */
}

body {
  font-family: var(--font-body);
  margin: 0;
  padding: 0;
  background-color: var(--bg-body);
  font-size: var(--font-size-base);
  color: var(--text-main);
  position: relative;
  min-height: 100vh;
  line-height: var(--line-height-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.bodyHeight {
  min-height: 100vh;
  padding-bottom: 4.375rem; /* 70px - Space for mobile bottom nav */
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: var(--spacing-md);
  line-height: 1.3;
}

h1 {
  font-size: var(--font-size-xxl); /* 32px */
  font-weight: 700;
}

h2 {
  font-size: var(--font-size-xl); /* 24px */
  font-weight: 600;
}

h3 {
  font-size: var(--font-size-lg); /* 20px */
  font-weight: 500;
}

p {
  margin-bottom: var(--spacing-md);
  line-height: var(--line-height-base);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: all var(--transition);
}

a:hover {
  color: var(--secondary);
}

/* ============================================
   Navigation - Mobile First
   ============================================ */

/* Mobile Bottom Navigation */
.nav-mobile {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4.375rem; /* 70px */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(93, 112, 82, 0.1);
  z-index: var(--z-navbar);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--spacing-xs);
  box-shadow: 0 -0.25rem 1.25rem rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
}

.nav-mobile ul {
  display: flex;
  list-style: none;
  width: 100%;
  justify-content: space-around;
  align-items: center;
  margin: 0;
  padding: 0;
  gap: 0.25rem;
}

.nav-mobile ul li {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.nav-mobile ul li a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.25rem;
  color: var(--text-muted);
  transition: all var(--transition);
  border-radius: var(--border-radius);
  min-width: 0;
  width: 100%;
  max-width: 100%;
  gap: 0.2rem;
  box-sizing: border-box;
}

.nav-mobile ul li a:hover,
.nav-mobile ul li a.active {
  color: var(--primary);
  background-color: rgba(93, 112, 82, 0.05);
}

.nav-mobile ul li a .nav-icon {
  font-size: clamp(1.2rem, 3vw + 0.5rem, 1.5rem);
  display: block;
  margin-bottom: 0;
  line-height: 1;
}

.nav-mobile ul li a .nav-label {
  font-size: clamp(0.65rem, 1.5vw + 0.3rem, 0.75rem);
  font-weight: 500;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Desktop Top Navigation */
.nav-desktop {
  display: none;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 4.375rem; /* 70px */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(93, 112, 82, 0.1);
  z-index: var(--z-navbar);
  box-shadow: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.05);
}

.nav-desktop nav {
  max-width: 75rem; /* 1200px */
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-lg);
}

.nav-desktop nav ul {
  display: flex;
  list-style: none;
  gap: var(--spacing-lg);
  align-items: center;
  margin: 0;
  padding: 0;
}

.nav-desktop nav ul li a {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--text-main);
  font-weight: 500;
  border-radius: var(--border-radius);
  transition: all var(--transition);
}

.nav-desktop nav ul li a:hover,
.nav-desktop nav ul li a.active {
  color: var(--primary);
  background-color: rgba(93, 112, 82, 0.05);
}

.nav-desktop nav ul li a .nav-icon {
  font-size: 1.25rem;
}

/* Desktop Navigation - Show on larger screens */
@media screen and (min-width: 768px) {
  .nav-mobile {
    display: none;
  }
  
  .nav-desktop {
    display: block;
  }
  
  .bodyHeight {
    padding-bottom: 0;
  }
}

/* ============================================
   Main Content
   ============================================ */
main {
  padding: var(--spacing-lg) var(--spacing-md);
  max-width: var(--container-lg);
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}



@media screen and (max-width: 767px) {
  main {
    padding: var(--spacing-md) var(--spacing-sm);
    padding-bottom: 5.5rem; /* Space for bottom nav */
  }
}

/* ============================================
   Footer
   ============================================ */
footer {
  background-color: var(--bg-card);
  padding: var(--spacing-lg);
  text-align: center;
  border-top: 1px solid rgba(93, 112, 82, 0.1);
  margin-top: var(--spacing-xl);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

@media screen and (max-width: 767px) {
  footer {
    margin-bottom: 4.375rem; /* Space for bottom nav */
  }
}

/* ============================================
   Buttons - Pill Shape
   ============================================ */
button,
.btn,
.addFamily {
  display: inline-block;
  border: none;
  background-color: var(--primary);
  font-family: var(--font-body);
  color: var(--bg-card);
  font-size: var(--font-size-md);
  font-weight: 500;
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--border-radius-pill);
  margin: var(--spacing-sm) auto;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--box-shadow);
  text-align: center;
  min-height: 3rem; /* 48px */
  line-height: 1.5;
}

button:hover,
.btn:hover,
.addFamily:hover {
  background-color: var(--secondary);
  transform: translateY(-0.125rem); /* -2px */
  box-shadow: var(--box-shadow-hover);
}

button:active,
.btn:active,
.addFamily:active {
  transform: translateY(0);
  box-shadow: var(--box-shadow);
}

button.secondary,
.btn.secondary {
  background-color: var(--secondary);
}

button.secondary:hover,
.btn.secondary:hover {
  background-color: var(--primary);
}

button.outline,
.btn.outline {
  background-color: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

button.outline:hover,
.btn.outline:hover {
  background-color: var(--primary);
  color: var(--bg-card);
}

.btn-primary {
  background-color: var(--primary);
  color: var(--bg-card);
}

.btn-primary:hover {
  background-color: var(--secondary);
}

.btn-secondary {
  background-color: var(--bg-body);
  color: var(--text-main);
  border: 1px solid rgba(93, 112, 82, 0.2);
}

.btn-secondary:hover {
  background-color: rgba(93, 112, 82, 0.1);
}

.btn-danger {
  background-color: #e74c3c;
  color: var(--bg-card);
}

.btn-danger:hover {
  background-color: #c0392b;
}

/* ============================================
   Cards - The Central Component
   ============================================ */
.card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius);
  padding: var(--spacing-lg); /* 24px */
  box-shadow: var(--box-shadow);
  transition: all var(--transition);
  margin-bottom: var(--spacing-md);
  border: none; /* No border, shadow defines the edge */
}

.card:hover {
  box-shadow: var(--box-shadow-hover);
  transform: translateY(-0.125rem); /* -2px */
}

.childDiv,
.parentsDiv {
  display: flex;
  justify-content: space-between;
  margin: 0 auto var(--spacing-md) auto;
  gap: var(--spacing-xl);
  padding: var(--spacing-lg);
  background-color: var(--bg-card);
  border: none;
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 50rem; /* 800px */
  position: relative;
  text-align: right;
  box-shadow: var(--box-shadow);
  transition: all var(--transition);
}

.childDiv:hover,
.parentsDiv:hover {
  box-shadow: var(--box-shadow-hover);
  transform: translateY(-0.125rem);
}

/* ============================================
   Print Family Tree Button
   ============================================ */
.print-controls {
  position: fixed;
  bottom: 2rem; /* Default for desktop */
  left: 2rem;
  z-index: calc(var(--z-navbar) - 1); /* Below navbar but above content */
  box-sizing: border-box;
}

.floating-print-btn {
  padding: clamp(var(--spacing-sm), 1.5vw + 0.5rem, 0.75rem) clamp(var(--spacing-md), 2vw + 0.75rem, 1.5rem);
  font-size: clamp(var(--font-size-sm), 1.5vw + 0.5rem, 1rem);
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  border-radius: var(--border-radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--box-shadow);
  background: linear-gradient(135deg, var(--primary) 0%, #4a5d42 100%);
  color: var(--bg-card);
  white-space: nowrap;
  min-height: clamp(2.5rem, 5vw + 1.5rem, 3rem);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
}

.floating-print-btn:hover {
  background: linear-gradient(135deg, #4a5d42 0%, var(--primary) 100%);
  transform: translateY(-0.125rem);
  box-shadow: var(--box-shadow-hover);
}

.floating-print-btn:active {
  transform: translateY(0);
}

/* Desktop - Position on left side */
@media screen and (min-width: 768px) {
  .print-controls {
    bottom: 2rem;
    left: 2rem;
  }
}

/* Mobile - Position above navigation */
@media screen and (max-width: 767px) {
  .print-controls {
    bottom: 5.5rem; /* Above mobile nav (70px + 16px spacing) */
    left: var(--spacing-md);
    right: var(--spacing-md);
    display: flex;
    justify-content: center;
  }

  .floating-print-btn {
    width: 100%;
    max-width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    min-height: 2.5rem;
  }
}

/* Small mobile */
@media screen and (max-width: 480px) {
  .print-controls {
    bottom: 5rem; /* Slightly closer to nav */
    left: var(--spacing-sm);
    right: var(--spacing-sm);
  }

  .floating-print-btn {
    font-size: 0.75rem;
    padding: 0.4rem var(--spacing-sm);
    min-height: 2.25rem;
  }
}

/* ============================================
   Back Button - Same styling as print button
   ============================================ */
.back-controls {
  position: fixed;
  bottom: 2rem; /* Default for desktop */
  left: 2rem;
  z-index: calc(var(--z-navbar) - 1);
  box-sizing: border-box;
}

.floating-back-button {
  padding: clamp(var(--spacing-sm), 1.5vw + 0.5rem, 0.75rem) clamp(var(--spacing-md), 2vw + 0.75rem, 1.5rem);
  font-size: clamp(var(--font-size-sm), 1.5vw + 0.5rem, 1rem);
  font-weight: 500;
  font-family: var(--font-body);
  border: 2px solid #a9b247;
  border-radius: var(--border-radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--box-shadow);
  background-color: #3C160F;
  color: #ffffff;
  white-space: nowrap;
  min-height: clamp(2.5rem, 5vw + 1.5rem, 3rem);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
}

.floating-back-button:hover {
  background-color: #5a5a5a;
  transform: translateY(-0.125rem);
  box-shadow: var(--box-shadow-hover);
}

.floating-back-button:active {
  transform: translateY(0);
}

/* Desktop - Position above print button */
@media screen and (min-width: 768px) {
  .back-controls {
    bottom: calc(2rem + clamp(2.5rem, 5vw + 1.5rem, 3rem) + 0.5rem); /* Above print button (2rem + button height + spacing) */
    left: 2rem;
  }
}

/* Mobile - Position above print button */
@media screen and (max-width: 767px) {
  .back-controls {
    bottom: 8.5rem; /* Above print button (5.5rem + 2.5rem + 0.5rem spacing) */
    left: var(--spacing-md);
    right: var(--spacing-md);
    display: flex;
    justify-content: center;
  }

  .floating-back-button {
    width: 100%;
    max-width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    min-height: 2.5rem;
  }
}

/* Small mobile */
@media screen and (max-width: 480px) {
  .back-controls {
    bottom: 7.75rem; /* Above print button (5rem + 2.25rem + 0.5rem spacing) */
    left: var(--spacing-sm);
    right: var(--spacing-sm);
  }

  .floating-back-button {
    font-size: 0.75rem;
    padding: 0.4rem var(--spacing-sm);
    min-height: 2.25rem;
  }
}

/* ============================================
   Forms & Inputs
   ============================================ */
.addForm {
  display: block;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--bg-card);
  padding: clamp(var(--spacing-lg), 3vw + var(--spacing-md), var(--spacing-xl));
  border-radius: var(--border-radius);
  z-index: var(--z-modal);
  box-shadow: 0 0.5rem 2.5rem rgba(0, 0, 0, 0.15);
  max-width: min(90%, 500px);
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
}

.addForm .close-form {
  position: absolute;
  left: 1rem;
  top: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.addForm .close-form:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--text-main);
}

.addForm h2 {
  font-size: clamp(var(--font-size-lg), 2vw + 0.5rem, var(--font-size-xl));
  font-weight: 600;
  margin: 0 0 var(--spacing-lg) 0;
  color: var(--text-main);
  text-align: right;
}

.addForm label {
  display: block;
  font-size: clamp(var(--font-size-sm), 1.2vw + 0.4rem, var(--font-size-sm));
  font-weight: 500;
  margin: var(--spacing-md) 0 var(--spacing-xs) 0;
  text-align: right;
  color: var(--text-main);
}

.addForm input,
.addForm select,
.addForm textarea {
  display: block;
  width: 100%;
  font-size: clamp(var(--font-size-sm), 1.5vw + 0.5rem, var(--font-size-md));
  font-family: var(--font-body);
  font-weight: 400;
  padding: clamp(var(--spacing-xs), 1.5vw + 0.25rem, var(--spacing-sm)) clamp(var(--spacing-sm), 2vw + 0.5rem, var(--spacing-md));
  margin: 0 0 var(--spacing-md) 0;
  border: none;
  border-radius: var(--border-radius);
  background-color: #f0f0f0;
  color: var(--text-main);
  transition: all var(--transition);
  text-align: right;
  direction: rtl;
  box-sizing: border-box;
}

.addForm input:focus,
.addForm select:focus,
.addForm textarea:focus {
  outline: none;
  background-color: #e8e8e8;
  box-shadow: 0 0 0 0.1875rem rgba(93, 112, 82, 0.1); /* 3px */
}

.addForm textarea {
  min-height: clamp(6rem, 8vw + 3rem, 7.5rem); /* 96-120px */
  resize: vertical;
}

.btns {
  display: flex;
  width: 100%;
  gap: clamp(var(--spacing-xs), 1.5vw + 0.25rem, var(--spacing-md));
  margin-top: var(--spacing-lg);
  flex-direction: row-reverse;
  flex-wrap: wrap;
}

.btns button {
  flex: 1;
  margin: 0;
  min-width: 0;
  min-height: clamp(2.5rem, 5vw + 1.5rem, 3rem);
  font-size: clamp(var(--font-size-sm), 1.5vw + 0.5rem, var(--font-size-md));
  padding: clamp(var(--spacing-xs), 1.5vw + 0.25rem, var(--spacing-sm)) clamp(var(--spacing-md), 2vw + 0.5rem, var(--spacing-lg));
  box-sizing: border-box;
}

/* Form Fields - Global */
.form-field,
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-field label,
.form-group label {
  display: block;
  font-size: clamp(var(--font-size-sm), 1.2vw + 0.4rem, var(--font-size-sm));
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: var(--spacing-xs);
  text-align: right;
}

.form-field input,
.form-field textarea,
.form-field select,
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: clamp(var(--spacing-xs), 1.5vw + 0.25rem, var(--spacing-sm)) clamp(var(--spacing-sm), 2vw + 0.5rem, var(--spacing-md));
  font-size: clamp(var(--font-size-sm), 1.5vw + 0.5rem, var(--font-size-md));
  font-family: var(--font-body);
  border: none;
  border-radius: var(--border-radius);
  background-color: #f0f0f0;
  color: var(--text-main);
  transition: all var(--transition);
  text-align: right;
  direction: rtl;
  box-sizing: border-box;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus,
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  background-color: #e8e8e8;
  box-shadow: 0 0 0 0.1875rem rgba(93, 112, 82, 0.1);
}

.form-actions {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-lg);
  flex-wrap: wrap;
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mb-sm {
  margin-bottom: var(--spacing-sm);
}

.mb-md {
  margin-bottom: var(--spacing-md);
}

.mb-lg {
  margin-bottom: var(--spacing-lg);
}

.mt-sm {
  margin-top: var(--spacing-sm);
}

.mt-md {
  margin-top: var(--spacing-md);
}

.mt-lg {
  margin-top: var(--spacing-lg);
}

/* ============================================
   Animations - Subtle & Smooth
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.3s ease-out;
}

/* ============================================
   Loading Spinner
   ============================================ */
.spinner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(249, 247, 242, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: var(--z-overlay);
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  z-index: var(--z-overlay);
  display: none;
}

/* ============================================
   Error Messages
   ============================================ */
.error-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  left: auto;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  pointer-events: none;
  max-width: 500px;
  width: auto;
}

/* Mobile adjustments */
@media screen and (max-width: 767px) {
  .error-container {
    top: 0.5rem;
    right: 0.5rem;
    left: 0.5rem;
    max-width: calc(100% - 1rem);
    width: auto;
  }
}

.error-message {
  background-color: #fee;
  color: #c33;
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  margin: 0;
  border-right: 0.25rem solid #c33;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.error-message.show {
  opacity: 1;
  transform: translateX(0);
}

.error-message.error-warning {
  background-color: #fff3cd;
  color: #856404;
  border-right-color: #ffc107;
}

.error-message.error-info {
  background-color: #d1ecf1;
  color: #0c5460;
  border-right-color: #17a2b8;
}

.error-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.error-text {
  flex: 1;
}

.error-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: inherit;
  cursor: pointer;
  padding: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.error-close:hover {
  opacity: 1;
}

.success-message {
  background-color: #efe;
  color: #3c3;
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  margin: var(--spacing-md) 0;
  border-right: 0.25rem solid #3c3;
}

/* ============================================
   Responsive Design - Mobile First Approach
   ============================================ */

/* Mobile (up to 767px) */
@media screen and (max-width: 767px) {
  h1 {
    font-size: var(--font-size-xl);
  }
  
  h2 {
    font-size: var(--font-size-lg);
  }
  
  h3 {
    font-size: var(--font-size-md);
  }
  
  main {
    padding: var(--spacing-md) var(--spacing-sm);
    padding-bottom: clamp(4.5rem, 10vw + 3rem, 5.5rem); /* Responsive space for bottom nav */
  }
  
  .nav-mobile {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: var(--z-navbar);
    width: 100%;
    height: clamp(3.5rem, 8vw + 2rem, 4.375rem); /* Responsive height */
    padding: 0 clamp(0.25rem, 1vw + 0.25rem, 0.75rem);
  }

  .nav-mobile ul li a {
    padding: 0.3rem 0.15rem;
  }

  .nav-mobile ul li a .nav-icon {
    font-size: clamp(1rem, 3vw + 0.5rem, 1.3rem);
  }

  .nav-mobile ul li a .nav-label {
    font-size: clamp(0.6rem, 1.5vw + 0.3rem, 0.7rem);
  }
  
  /* SVG Family Tree - Mobile */
  .familyTree,
  #familyTree {
    max-width: 100%;
    height: auto;
  }
  
  /* Cards - Smaller padding on mobile */
  .card {
    padding: var(--spacing-md);
  }
  
  /* Forms - Full width on mobile */
  .addForm {
    width: 95%;
    max-width: 95%;
    padding: clamp(var(--spacing-md), 2vw + 0.5rem, var(--spacing-lg));
    max-height: 95vh;
  }

  .addForm h2 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-md);
  }

  .addForm label {
    font-size: var(--font-size-sm);
    margin: var(--spacing-sm) 0 var(--spacing-xs) 0;
  }

  .addForm input,
  .addForm select,
  .addForm textarea {
    font-size: var(--font-size-sm);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
  }

  .addForm textarea {
    min-height: 5rem;
  }

  .btns {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .btns button {
    width: 100%;
    min-height: 2.5rem;
    font-size: var(--font-size-sm);
  }

  .form-group input,
  .form-group textarea,
  .form-group select {
    font-size: var(--font-size-sm);
    padding: var(--spacing-sm);
  }
}

/* Tablet (768px - 1023px) */
@media screen and (min-width: 768px) and (max-width: 1023px) {
  main {
    padding: var(--spacing-xl) var(--spacing-lg);
    max-width: var(--container-md);
  }
  
  /* SVG Family Tree - Tablet */
  .familyTree,
  #familyTree {
    max-width: 85%;
    height: auto;
    margin: 0 auto;
  }
  
  /* Cards - Medium padding on tablet */
  .card {
    padding: var(--spacing-lg);
  }
}

/* Desktop (1024px and up) */
@media screen and (min-width: 1024px) {
  main {
    padding: var(--spacing-xl) var(--spacing-xl);
    max-width: var(--container-lg);
  }
  
  /* SVG Family Tree - Desktop */
  .familyTree,
  #familyTree {
    max-width: 75%;
    height: auto;
    margin: 0 auto;
  }
  
  /* Cards - Full padding on desktop */
  .card {
    padding: var(--spacing-lg);
  }
}

/* Large Desktop (1400px and up) */
@media screen and (min-width: 1400px) {
  main {
    max-width: var(--container-xl);
  }
  
  /* SVG Family Tree - Large Desktop */
  .familyTree,
  #familyTree {
    max-width: 65%;
  }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  body * {
    visibility: hidden;
  }
  
  .printModal,
  .printModal * {
    visibility: visible;
  }
  
  .printModal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    transform: none;
    box-shadow: none;
    padding: 1rem;
  }
  
  .no-print,
  .printModal .no-print {
    display: none !important;
  }
  
  .tree-toggle {
    cursor: default !important;
  }
  
  .tree-item-children {
    display: block !important;
  }
  
  .tree-item-children > div {
    display: block !important;
  }
}

/* ============================================
   Print Tree Styles - Flow Chart
   ============================================ */
#printTreeContainer {
  direction: rtl;
  text-align: right;
}

.generation-level {
  margin-bottom: 3rem;
  page-break-inside: avoid;
}

.people-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  page-break-inside: avoid;
}

.people-row > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  page-break-inside: avoid;
}

.people-row > div > div:first-child {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.people-row > div > div:first-child > div {
  padding: 0.5rem;
  border: 1px solid #000;
  min-width: 180px;
  text-align: center;
  background: #fff;
  page-break-inside: avoid;
}

@media print {
  .generation-level {
    page-break-inside: avoid;
    margin-bottom: 2rem;
  }
  
  .people-row {
    page-break-inside: avoid;
  }
  
  .people-row > div {
    page-break-inside: avoid;
  }
  
  body {
    font-size: 10pt;
  }
  
  .people-row > div > div:first-child > div {
    min-width: 150px;
    padding: 0.4rem;
    font-size: 9pt;
  }
}
