@import url(https://fonts.bunny.net/css?family=barlow:100,200,300,300i,400,500,600,700&display=swap);

* {
  outline: none;
  box-sizing: border-box;
}

/* Performance optimizations */
* {
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root {
  /* Light mode (default) */
  --theme-bg-color: #F0E3E0;
  --theme-color: #2c3e50;
  --border-color: rgba(113, 119, 144, 0.25);
  --female-card-color: #ffc0cb;
  --male-card-color: #87ceeb;
  --female-card-text: #3e2028;
  --male-card-text: #0a3b56;
  --body-font: 'barlow', sans-serif;
  --semi-transparent-bg: rgba(245, 247, 250, 0.8);
  --full-transparent-bg: rgba(245, 247, 250, 0.1);
  --blur-size: 20px;
  --text-color: #2c3e50;
  --transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
  --border-color-light: rgba(0, 0, 0, 0.15);
  --border-color-medium: rgba(0, 0, 0, 0.3);
  --text-color-secondary: rgba(0, 0, 0, 0.6);
  --modal-bg: #F0E3E0;
  --modal-text: #2c3e50;
  --search-text: #2c3e50;
  --search-border: rgba(113, 119, 144, 0.5);
  --navbar-bg: #F0E3E0;
  --option-hover: #c5e1e6;
  --option-border: rgba(44, 62, 80, 0.2);
  --options-bg: #F0E3E0;
  --input-hover: #218c8d;
}

/* Dark mode styles */
@media (prefers-color-scheme: dark) {
  :root {
    --theme-bg-color: #2c3e50;
    --theme-color: #f9fafb;
    --border-color: rgba(113, 119, 144, 0.25);
    --female-card-color: #d46e84;
    --male-card-color: #5b9bd5;
    --female-card-text: #ffffff;
    --male-card-text: #ffffff;
    --semi-transparent-bg: rgba(44, 62, 80, 0.7);
    --full-transparent-bg: rgba(44, 62, 80, 0.1);
    --text-color: #f0e3e0;
    --border-color-light: rgba(255, 255, 255, 0.15);
    --border-color-medium: rgba(255, 255, 255, 0.3);
    --text-color-secondary: rgba(255, 255, 255, 0.7);
    --modal-bg: #34495e;
    --modal-text: #f9fafb;
    --search-text: #f9fafb;
    --search-border: rgba(255, 255, 255, 0.5);
    --navbar-bg: rgba(44, 62, 80, 0.8);
    --option-hover: #26a69a;
    --option-border: rgba(240, 234, 229, 0.3);
    --options-bg: rgba(44, 62, 80, 0.8);
    --input-hover: #218c8d;
  }
}

/* Base styles */
body {
  font-family: var(--body-font);
  background: var(--theme-bg-color);
  overflow: hidden;
  padding: 0;
  margin: 0;
}

img {
  max-width: 100%;
}

/* Typography */
h1 {
  font-weight: 700;
}

h2 {
  font-weight: 600;
}

h3 {
  font-weight: 500;
}

p {
  font-weight: 400;
}

p.thin {
  font-weight: 200;
}

p.ultralight {
  font-weight: 100;
}

/* Utility classes */
.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.flex-column {
  display: flex;
  flex-direction: column;
}

.flex-row {
  display: flex;
  flex-direction: row;
}

.shadow-sm {
  box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.5);
}

.shadow-md {
  box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
}

/* Family tree container */
.f3 {
  max-height: 100%;
  max-width: 100%;
  height: 100svh;
  height: 100vh;
  font-family: var(--body-font);
}

.f3 .cursor-pointer {
  cursor: pointer;
}

.f3 svg.main_svg {
  width: 100%;
  height: 100%;
  color: var(--theme-bg-color);
}

/* Card gender styling - Optimized for GPU acceleration */
.f3 rect.card-female,
.f3 .card-female .card-body-rect,
.f3 .card-female .text-overflow-mask {
  fill: var(--female-card-color);
  will-change: transform;
}

.f3 rect.card-male,
.f3 .card-male .card-body-rect,
.f3 .card-male .text-overflow-mask {
  fill: var(--male-card-color);
  will-change: transform;
}

.f3 .card_edit.pencil_icon {
  color: var(--theme-color);
  transition: color 0.3s ease;
  will-change: color;
}

.f3 .card_edit.pencil_icon:hover {
  color: var(--theme-bg-color);
}

/* Card text styling */
.f3 .card-male {
  fill: var(--male-card-text);
}

.f3 .card-female {
  fill: var(--female-card-text);
}

.f3 .card-genderless {
  fill: var(--text-color);
}

/* Navigation - Performance optimized */
.navbar {
  height: 4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--navbar-bg);
  backdrop-filter: blur(var(--blur-size));
  -webkit-backdrop-filter: blur(var(--blur-size));
  transform: translateZ(0);
  will-change: background-color;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  max-width: 100%;
  height: 4rem;
  white-space: nowrap;
}

/* Search bar */
.search-bar {
  --search-bar-height: 3rem;
  --search-bar-bg: transparent;
  --search-btn-color: var(--text-color);
  --search-input-bg: transparent;
  --search-input-color: var(--text-color);
  --search-icon-color: var(--text-color);

  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  border-radius: calc(var(--search-bar-height) / 2);
  position: relative;
  background: var(--search-bar-bg);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  width: var(--search-bar-height);
  height: var(--search-bar-height);
  padding: 0.5rem;
  margin-right: 1rem;
}

.search-bar.expanded {
  width: 300px;
}

.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  color: var(--search-btn-color);
}

.search-icon {
  width: 1.5rem;
  height: 1.5rem;
  fill: var(--search-icon-color);
}

.search-input {
  display: none;
  flex: 1;
  border: 0;
  background: var(--search-input-bg);
  color: var(--search-input-color);
  font-size: 1rem;
  padding: 0 0.5rem;
  outline: none;
  width: 100%;
  border-bottom: 1px solid var(--search-border);
}

.search-bar.expanded .search-input {
  display: block;
}

.search-bar input::placeholder {
  font-family: var(--body-font);
  color: var(--inactive-color);
}

/* Profile header */
.header-profile {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-profile svg {
  width: 22px;
  color: #f9fafb;
  flex-shrink: 0;
}

.profile-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--theme-color);
  margin-left: 1rem;
  margin-right: 1rem;
}

/* Options dropdown - Performance optimized */
.options {
  list-style: none;
  padding: 0;
  position: absolute;
  z-index: 1;
  display: none;
  width: 100%;
  top: 100%;
  left: 0;
  backdrop-filter: blur(var(--blur-size));
  -webkit-backdrop-filter: blur(var(--blur-size));
  background: var(--options-bg);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  color: var(--text-color);
  transform: translateZ(0);
}

.option-item {
  width: 100%;
  transition: background-color 0.15s ease;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  position: relative;
  text-decoration: none;
  box-sizing: border-box;
  text-align: left;
  padding: 10px;
  cursor: pointer;
  border-radius: 4px;
  will-change: background-color;
}

.options .option-item:not(:last-child) {
  border-bottom: 0.5px solid var(--option-border);
}

@media screen and (min-width: 600px) {
  .options .option-item:not(:last-child) {
    border-bottom: 0.25px solid rgba(240, 234, 229, 0.5);
  }
}

.option-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 10px;
  border: white 1px solid;
}

.options li:hover {
  background-color: var(--option-hover);
}

.clickableDiv {
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  border-radius: 4px;
}

/* Forms */
.edit-form {
  width: 95%;
  margin-top: 3%;
  margin-bottom: 3%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Avatar upload - Performance optimized */
.avatar-upload {
  position: relative;
  max-width: 205px;
  margin: 50px auto;
  transform: translateZ(0);
}

.avatar-upload .avatar-edit {
  position: absolute;
  right: 13%;
  z-index: 1;
  top: 3%;
}

.avatar-upload .avatar-edit input {
  display: none;
}

.avatar-upload .avatar-edit input+label {
  display: inline-block;
  width: 34px;
  height: 34px;
  margin-bottom: 0;
  border-radius: 100%;
  background: #ffffff;
  border: 1px solid transparent;
  box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  font-weight: normal;
  transition: all 0.2s ease-in-out;
  will-change: transform, background-color, border-color;
}

.avatar-upload .avatar-edit input+label:hover {
  background: #f1f1f1;
  border-color: #d6d6d6;
}

.avatar-upload .avatar-edit input+label:after {
  content: url(/pencil-icon.svg);
  color: #2c3e50;
  position: absolute;
  top: 24%;
  left: 0;
  right: 0;
  text-align: center;
  margin: auto;
}

.avatar-upload .avatar-edit input+label:hover:after {
  transform: scale(0.9);
}

.avatar-upload .avatar-preview {
  width: 192px;
  height: 192px;
  position: relative;
  border-radius: 100%;
  border: 6px solid #f8f8f8;
  box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
}

.avatar-upload .avatar-preview>div {
  width: 100%;
  height: 100%;
  border-radius: 100%;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

.container2 .btn-i {
  position: absolute;
  top: 90%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 16px;
  border: none;
  cursor: pointer;
  border-radius: 5px;
  text-align: center;
}

.node-name {
  font-weight: 600;
  font-size: 1.2rem;
  margin: 0;
  text-transform: capitalize;
}

/* Modal styling - Performance optimized */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  animation: modal-fade 0.3s ease-in-out;
  transition: opacity 0.3s ease-in-out;
  transform: translateZ(0);
  will-change: opacity, transform;
}

.modal-content {
  position: relative;
  margin: 5% auto;
  background-color: var(--modal-bg);
  color: var(--modal-text);
  width: 60%;
  max-height: 70%;
  overflow-y: auto;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
  transform: translateZ(0);
}

.modal-close {
  cursor: pointer;
  position: absolute;
  right: 8px;
  top: 8px;
  width: 20px;
  height: 20px;
  opacity: 0.5;
}

.modal-close:hover {
  opacity: 1;
}

.modal-close:before,
.modal-close:after {
  background-color: var(--theme-color);
}

.modal-close:before,
.modal-close:after {
  content: '';
  position: absolute;
  width: 2px;
  height: 24px;
  background-color: var(--theme-bg-color);
}

.modal-close:before {
  transform: rotate(45deg);
}

.modal-close:after {
  transform: rotate(-45deg);
}

.modal-footer {
  display: flex;
  justify-content: space-between;
}

/* Preloader animation */
.preloader-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--theme-bg-color);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1000px;
}

.lds-heart,
.lds-heart div,
.lds-heart div:after,
.lds-heart div:before {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

.lds-heart {
  display: inline-block;
  position: relative;
  width: 80px;
  height: 80px;
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
  -webkit-transform-origin: 40px 40px;
  -ms-transform-origin: 40px 40px;
  transform-origin: 40px 40px;
  color: var(--theme-color);
}

.lds-heart div {
  top: 28px;
  left: 28px;
  position: absolute;
  width: 32px;
  height: 32px;
  background: currentColor;
  -webkit-animation: lds-heart 1.2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
  animation: lds-heart 1.2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}

.lds-heart div:after,
.lds-heart div:before {
  content: " ";
  position: absolute;
  display: block;
  width: 32px;
  height: 32px;
  background: currentColor;
}

.lds-heart div:before {
  left: -24px;
  -webkit-border-radius: 50% 0 0 50%;
  border-radius: 50% 0 0 50%;
}

.lds-heart div:after {
  top: -24px;
  -webkit-border-radius: 50% 50% 0 0;
  border-radius: 50% 50% 0 0;
}

@-webkit-keyframes lds-heart {
  0% {
    -webkit-transform: scale(0.95);
    transform: scale(0.95);
  }
  5% {
    -webkit-transform: scale(1.1);
    transform: scale(1.1);
  }
  39% {
    -webkit-transform: scale(0.85);
    transform: scale(0.85);
  }
  45% {
    -webkit-transform: scale(1);
    transform: scale(1);
  }
  60% {
    -webkit-transform: scale(0.95);
    transform: scale(0.95);
  }
  100% {
    -webkit-transform: scale(0.9);
    transform: scale(0.9);
  }
}

@keyframes lds-heart {
  0% {
    -webkit-transform: scale(0.95);
    transform: scale(0.95);
  }
  5% {
    -webkit-transform: scale(1.1);
    transform: scale(1.1);
  }
  39% {
    -webkit-transform: scale(0.85);
    transform: scale(0.85);
  }
  45% {
    -webkit-transform: scale(1);
    transform: scale(1);
  }
  60% {
    -webkit-transform: scale(0.95);
    transform: scale(0.95);
  }
  100% {
    -webkit-transform: scale(0.9);
    transform: scale(0.9);
  }
}

/* Button styling - Performance optimized */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font: 500 1rem/1.5 var(--body-font);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  transition: background-color 0.3s ease-out, box-shadow 0.3s ease-out;
  background-color: var(--option-hover);
  color: var(--text-color);
  border: none;
  border-radius: 0.5rem;
  box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
  will-change: background-color, box-shadow;
  transform: translateZ(0);
}

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

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(38, 166, 154, 0.5);
}

.btn:active {
  background-color: var(--input-hover);
}

.btn.disabled,
.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Clock input */
.clock-input {
  position: relative;
  font-family: 'Roboto', sans-serif;
  width: 100%;
}

.clock-input input[type='date'] {
  width: 100%;
  height: 2rem;
  font-size: 1rem;
  color: var(--text-color);
  border: none;
  border-bottom: 1px solid var(--border-color-light);
  outline: none;
  background-color: transparent;
  transition: border-color 0.2s var(--transition-timing);
}

.clock-input input[type='date']:focus {
  border-bottom-color: var(--input-hover);
}

.clock-input label {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-color);
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  transition: 0.2s var(--transition-timing);
}

.clock-input input[type='date']:focus+label,
.clock-input input[type='date']:valid+label {
  top: -1.2rem;
  font-size: 0.8rem;
  color: var(--text-color);
}

.calendar-icon {
  position: absolute;
  right: 0;
  top: 5px;
  z-index: 1;
  pointer-events: none;
}

/* Error container */
.error-container {
  display: none;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  background-color: var(--theme-bg-color);
  text-align: center;
  flex-direction: column;
  color: var(--text-color);
}

.error-text {
  color: var(--text-color);
}

/* Input fields */
.input-field {
  position: relative;
  margin: 20px 0;
  font-family: var(--body-font) !important;
}

/* Group common input styling */
.input-field input[type='text'],
.input-field input[type='tel'],
.input-field input[type='date'],
.input-field textarea,
.input-field .materialize-textarea {
  width: 100%;
  height: 2rem;
  font-size: 1rem;
  color: var(--text-color);
  border: none;
  border-bottom: 1px solid var(--border-color-light);
  outline: none;
  background-color: transparent;
  transition: border-color 0.2s var(--transition-timing);
}

.input-field input[type='search'] {
  width: 100%;
  height: 3rem;
  font-size: 1rem;
  border: none;
  outline: none;
  background: transparent;
  transition: border-color 0.2s var(--transition-timing);
  color: var(--search-text);
  border-bottom: 1px solid var(--border-color-medium);
}

.input-field input[type='text']:hover,
.input-field input[type='tel']:hover,
.input-field input[type='date']:hover,
.input-field textarea:hover {
  border-bottom: 1px solid var(--input-hover);
}

.input-field input[type='text']:focus,
.input-field input[type='tel']:focus,
.input-field input[type='date']:focus,
.input-field input[type='search']:focus,
.input-field textarea:focus,
.input-field .materialize-textarea:focus {
  border-bottom: 2px solid var(--input-hover);
}

.input-field label {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-color-secondary);
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  transition: 0.2s var(--transition-timing);
}

/* Consolidated placeholder styling */
.input-field input[type='text']:not(:placeholder-shown)+label,
.input-field input[type='tel']:not(:placeholder-shown)+label,
.input-field input[type='date']:not(:placeholder-shown)+label,
.input-field input[type='search']:not(:placeholder-shown)+label,
.input-field textarea:not(:placeholder-shown)+label,
.input-field input[type='text']:focus+label,
.input-field input[type='tel']:focus+label,
.input-field input[type='date']:focus+label,
.input-field input[type='search']:focus+label,
.input-field textarea:focus+label {
  top: -1.2rem;
  font-size: 0.8rem;
  color: var(--text-color);
}

.material-input {
  border-bottom: 1px solid grey !important;
}

/* Container styling */
.container {
  height: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 3px;
  overflow: hidden;
}

.header {
  width: 100%;
  flex: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.5);
}

#profile-picture {
  height: 20%;
  border-radius: 50%;
  width: 20%;
  overflow: hidden;
  object-fit: cover;
  padding: 2%;
}

.header-text {
  color: var(--text-color);
  font-size: 1.7em;
  font-family: var(--body-font);
  line-height: 1.6em;
}

.male-header-color {
  background-color: var(--male-card-color);
}

.female-header-color {
  background-color: var(--female-card-color);
}

/* Card family tree - Performance optimized */
.card_family_tree rect {
  transition: transform 0.3s ease;
  will-change: transform;
}

.card_family_tree:hover rect {
  transform: scale(1.1);
}

.card-image-border {
  fill: none;
  stroke: white;
  stroke-width: 2px;
  transition: stroke-width 0.3s ease;
  will-change: stroke-width;
}

/* Animations - Performance optimized */
@keyframes rotate-one {
  0% {
    transform: rotateX(35deg) rotateY(-45deg) rotateZ(0deg) translate3d(0, 0, 0);
  }

  100% {
    transform: rotateX(35deg) rotateY(-45deg) rotateZ(360deg) translate3d(0, 0, 0);
  }
}

@keyframes rotate-two {
  0% {
    transform: rotateX(50deg) rotateY(10deg) rotateZ(0deg) translate3d(0, 0, 0);
  }

  100% {
    transform: rotateX(50deg) rotateY(10deg) rotateZ(360deg) translate3d(0, 0, 0);
  }
}

@keyframes rotate-three {
  0% {
    transform: rotateX(35deg) rotateY(55deg) rotateZ(0deg) translate3d(0, 0, 0);
  }

  100% {
    transform: rotateX(35deg) rotateY(55deg) rotateZ(360deg) translate3d(0, 0, 0);
  }
}

@keyframes modal-fade {
  from {
    opacity: 0;
    transform: translateY(-10px) translateZ(0);
  }

  to {
    opacity: 1;
    transform: translateY(0) translateZ(0);
  }
}

/* Responsive styles - consolidated media queries */
/* Mobile devices */
@media only screen and (max-width: 480px) {
  .search-bar {
    width: auto;
  }

  .modal-content {
    width: 90%;
  }

  .header {
    padding: 0 16px;
  }
}

/* Tablets */
@media only screen and (min-width: 481px) and (max-width: 768px) {
  .search-bar {
    width: 100%;
    max-width: 50%;
  }

  .modal-content {
    width: 85%;
  }
}

/* Small laptops */
@media only screen and (min-width: 769px) and (max-width: 1024px) {
  .search-bar {
    width: 30%;
    max-width: 50%;
  }
}

/* Desktops */
@media only screen and (min-width: 1025px) {
  .search-bar {
    width: 30%;
    max-width: 50%;
  }
}

/* Large desktops */
@media only screen and (min-width: 1440px) {
  .search-bar {
    width: 20%;
    max-width: 50%;
  }
}
