/* header and nav layout */

html {
  overflow-y: scroll;
}

/* Accordion animation and arrow rotation */
.filters-accordion {
  transition: all 0.3s ease;
  overflow: hidden;
}

/* Only animate the accordion arrow, not the filter icon */
.filters-accordion summary .accordion-arrow svg {
  transition: transform 0.3s ease;
}

.filters-accordion[open] summary .accordion-arrow svg {
  transform: rotate(180deg);
}

/* Accordion content height animation */
.filters-accordion .filter-sections-wrapper {
  height: 0;
  overflow: hidden;
  transition: height 0.5s ease-out;
}

/* stylelint-disable-next-line empty-rule */


/* Modal fade in/out animation */
.modal dialog {
  position: sticky;
  top: 0;
  animation: fade-in 0.5s ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Modal fade out animation */
.modal dialog.closing {
  animation: fade-out 0.5s ease-in;
}

.modal dialog.closing::backdrop {
  animation: backdrop-fade-out 0.5s ease-in;
}

@keyframes fade-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes backdrop-fade-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* Backdrop fade animation */
.modal dialog::backdrop {
  background: rgb(0 0 0 / 50%);
  animation: backdrop-fade-in 0.5s ease-out;
}

@keyframes backdrop-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

header {
  position: sticky;
  top: 0;
  z-index: 100 !important;

  /* Ensure sticky positioning works even when body has overflow-y: hidden */
  transform: translateZ(0);
  will-change: transform;

  /* Create a new stacking context and ensure sticky behavior */
  isolation: isolate;
}

header .nav-wrapper {
  background-color: var(--cor-global-primaria);
  color: var(--light-color);
  width: 100%;
  z-index: 2;
  border-bottom: 1.5px solid white;
}



header nav {
  display: block;
  grid-template:
    'brand tools search hamburger' var(--nav-height)
    'sections sections sections section' auto / auto 1fr auto;
  max-height: 100px;

  /* Ensure proper positioning context for sticky children */
  position: relative;
}

header nav .nav-tools {
  display: none;

  /* Ensure nav-tools is hidden by default on mobile */
  visibility: hidden;
  opacity: 0;
  height: 0;
  overflow: hidden;
}

header nav .nav-sections ul {
  list-style: none;
  padding-left: 0;
}



header nav[aria-expanded="true"] .nav-tools {
  display: flex !important;
  text-align: center;
  flex-direction: column;
  max-height: 500px;
  background-color: var(--cor-global-azul-petroleo-80);
  position: sticky;
  top: 0;
  z-index: 101 !important;

  /* Ensure sticky positioning works with body overflow hidden */
  transform: translateZ(0);
  will-change: transform;

  /* Create a new stacking context for sticky behavior */
  isolation: isolate;

  /* Show nav-tools when expanded */
  visibility: visible;
  opacity: 1;
  height: auto;
  overflow: visible;

  /* Smooth transition for better UX */
  transition: visibility 0.3s ease, opacity 0.3s ease, height 0.3s ease;
}

header nav[aria-expanded="true"] .nav-tools ul {
  padding-inline: 0;
  padding-bottom: 0;
  padding-top: 0;
}


header nav .nav-brand {
  display: flex;
  align-items: center;
  justify-content: center;
}

header nav .nav-brand .default-content-wrapper {
  display: flex;
  align-items: center;
  justify-content: left;
  width: 100%;
}

header nav .nav-brand img {
  width: 300px;
  height: auto;
  margin: 0 auto;
  display: block;
  position: relative;
  top: -5px;
}


header nav[aria-expanded="true"] .nav-tools li {
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  align-items: center;

  p a.button {
    text-decoration: none;
  }
}



header nav p {
  display: flex;
  margin: 0;
  line-height: 1;
}

header nav a:any-link {
  color: currentcolor;
}

/* search */
header nav .nav-search {
  grid-area: search !important;
  position: absolute;
  top: 35px;
  right: 23%;
  
}



/* hamburger */
header nav .nav-hamburger {
  grid-area: hamburger;
  height: 7px;
  display: flex;
  align-items: center;
}

header nav .nav-hamburger button {
  height: 22px;
  position: absolute;
  right:15%;
  top:38px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background-color: var(--cor-global-acento);
}

header nav .nav-hamburger-icon,
header nav .nav-hamburger-icon::before,
header nav .nav-hamburger-icon::after {
  box-sizing: border-box;
  display: block;
  position: relative;
  width: 20px;
  background-color: var(--cor-global-primaria);
}

header nav .nav-hamburger-icon::before,
header nav .nav-hamburger-icon::after {
  content: '';
  position: absolute;
  background: currentcolor;
}

header nav[aria-expanded='false'] .nav-hamburger-icon,
header nav[aria-expanded='false'] .nav-hamburger-icon::before,
header nav[aria-expanded='false'] .nav-hamburger-icon::after {
  height: 2px;
  border-radius: 2px;
  background-color: var(--cor-global-primaria);
}

header nav[aria-expanded='false'] .nav-hamburger-icon::before {
  top: -6px;
}

header nav[aria-expanded='false'] .nav-hamburger-icon::after {
  top: 6px;
}

header nav[aria-expanded='true'] .nav-hamburger-icon {
  height: 22px;
}

header nav[aria-expanded='true'] .nav-hamburger-icon::before,
header nav[aria-expanded='true'] .nav-hamburger-icon::after {
  top: 3px;
  left: 1px;
  transform: rotate(45deg);
  transform-origin: 2px 1px;
  width: 24px;
  height: 2px;
  border-radius: 2px;
}

header nav[aria-expanded='true'] .nav-hamburger-icon::after {
  top: unset;
  bottom: 3px;
  transform: rotate(-45deg);
}

header nav[aria-expanded="true"] .nav-hamburger-icon {
  background: url('/icons/close-x.svg') center/contain no-repeat;
  background-color: var(--cor-global-primaria);
  color: var(--cor-global-verde-30);
}

/* sections */
header nav .nav-sections {
  display: none;
}

header nav[aria-expanded='true'] .nav-sections {
  display: none;
  align-self: center;
  justify-content: space-evenly;
}

header nav .nav-tools a {
  position: relative;
  text-decoration: none;
  color: currentcolor;
  display: inline-block;
}

header nav .nav-tools a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px; 
  width: 0%;
  height: 2px;
  background-color: var(--cor-global-acento);
  transition: width 0.3s ease;
}

header nav .nav-tools a:hover {
  color: var(--cor-global-acento); 
}

header nav .nav-tools a:hover::after {
  width: 100%;
}

header nav .nav-brand > div > p > a:hover {
    opacity: 1.0;
  }

/* Filter Modal Styles */
.modal dialog:has(.filter-modal-content) {
  background-color: var(--cor-global-primaria);
  color: var(--cor-global-acento);
  padding: 20px;
  width: 395px;
  max-width: 100%;
  box-sizing: border-box;
  max-height: 100%;
  height: 100%;
  overflow-y: visible;
  margin: unset;
  margin-left: auto;
}

.modal dialog:has(.filter-modal-content)::-webkit-scrollbar {
  display: none;
}

.modal dialog .modal-content:has(.filter-modal-content) {
  padding: 20px;
  width: 100%;
  height: 100vh;
  overflow-y: unset;
  margin-top: 0;
}

.filter-modal-title {
  color: var(--cor-global-acento);
  font-size: 24px;
  font-weight: 600;
  width: 350px;
  margin-bottom: 30px;
  text-transform: uppercase;
}

.filter-modal-content form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 400px;
  margin: 0 auto;
  border-top: 1px solid white;
  padding-top: 30px;
}

.filter-modal-content form > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
}

.filter-modal-content form select {
  padding: 12px;
  border: 2px solid var(--cor-global-primaria);
  border-radius: 6px;
  font-size: 16px;
  background-color: white;
  color: var(--cor-global-primaria);
}

.filter-modal-content form select:focus {
  outline: none;
  border-color: var(--cor-global-acento);
}

/* stylelint-disable-next-line no-descending-specificity */
.filter-modal-content form button {
  margin-top: 10px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
}

/* When modal is open, apply styles to main content */
body:has(.modal dialog) main > div {
  margin: 0;
}

/* Status Filter Styles */
.status-filter-section {
  margin-top: 0;
  text-align: left;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  border-bottom: 1px solid white;
  padding-bottom: 30px;
}

/* Create grid container for status checkboxes only */
.status-checkboxes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 15px;
}

.status-filter-title {
  color: var(--cor-global-acento);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 15px;
  text-transform: uppercase;
}

.status-checkbox-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--cor-global-acento);
  cursor: pointer;
  vertical-align: middle;
}

.status-label {
  font-size: 13px;
  color: var(--cor-global-branco);
  cursor: pointer;
  user-select: none;
  line-height: 1;
  vertical-align: middle;
  padding-left: 10px;
}

.status-checkbox:checked + .status-label {
  font-weight: 600;
}

/* Price Filter Styles */
.price-filter-section {
  margin-top: 30px;
  text-align: left;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  border-bottom: 1px solid white;
  padding-bottom: 30px;
}

.price-filter-title {
  color: var(--cor-global-acento);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 15px;
  text-transform: uppercase;
}

.price-range-container {
  display: flex;
  flex-direction: row;
  gap: 15px;
  justify-content: space-evenly;
}

.price-dropdown-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.price-label {
  font-size: 13px;
  color: var(--cor-global-acento);
  font-weight: 500;
}

.price-select {
  padding: 8px 12px;
  border: 1px solid var(--cor-global-acento);
  border-radius: 4px;
  background-color: var(--cor-global-branco);
  color: var(--cor-global-primaria);
  font-size: 13px;
  cursor: pointer;
}

.price-select:focus {
  outline: none;
  border-color: var(--cor-global-primaria);
}

.price-select option {
  background-color: var(--cor-global-azul-petroleo-80);
  color: var(--cor-global-branco);
}

/* Amenities Filter Styles */
.amenities-filter-section {
  margin-top: 30px;
  text-align: left;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  border-bottom: 1px solid white;
  padding-bottom: 30px;
}

.amenities-filter-title {
  color: var(--cor-global-acento);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 15px;
  text-transform: uppercase;
}

.amenities-checkbox-container {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}

.amenities-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--cor-global-acento);
  cursor: pointer;
}

.amenities-label {
  font-size: 13px;
  color: var(--cor-global-branco);
  cursor: pointer;
  user-select: none;
}

.amenities-checkbox:checked + .amenities-label {
  font-weight: 600;
}

/* Tipologia filter styles */
.tipologia-filter-section {
  margin-top: 30px;
  text-align: left;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
}

.tipologia-filter-title {
  color: var(--cor-global-acento);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 15px;
  text-transform: uppercase;
}

.tipologia-checkbox-container {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}

/* Arrange tipologia checkboxes in one row */
.tipologia-checkboxes-row {
  display: flex;
  flex-direction: row;
  gap: 20px;
  justify-content: space-between;
}

.tipologia-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--cor-global-acento);
  cursor: pointer;
}

.tipologia-label {
  font-size: 13px;
  color: var(--cor-global-branco);
  cursor: pointer;
  user-select: none;
}

.tipologia-checkbox:checked + .tipologia-label {
  font-weight: 600;
}

/* Desktop view */
@media (width >= 900px) {
  header nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 130px;
  }

  header nav .nav-tools {
    margin-left: auto;
  }

  header nav .nav-sections {
    display: flex;
    flex: 1 1 auto;
    visibility: visible;
    white-space: nowrap;
  }

  header nav .nav-sections form select {
    max-width: 100%;
    width: 130px;
    background-position-y: calc(50% + 3px);
    padding: 6px 9px;
    border-radius: 5px;
    color: #585858;
    margin-left: 10px;
  }

  header nav .nav-sections form select:first-of-type {
    margin-left: 24px;
  }

  header nav .nav-sections form button {
    margin: 0 0 0 10px;
    padding: 9px 20px 8px;
    border-radius: 5px;
    font-size: 15px;
  }

  header nav[aria-expanded='true'] .nav-tools ul li {
  display: flex;
  flex-direction: column;
  align-items: center; 
  margin: 0 10px;
  }

  header nav .nav-hamburger {
    display: none;
  }

  header nav .nav-brand {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  header nav .nav-brand .default-content-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  header nav .nav-brand img {
    padding-left: 0;
    width: 300px;
    max-width: 300px;
    margin: 0 auto;
    display: block;
    position: static;
  }

  header nav[aria-expanded='true'] .nav-tools {
    font-size: 16px;
    font-weight: 600;
    background-color: var(--cor-global-primaria);

    /* Keep sticky positioning for mobile, static only for desktop */
    position: sticky;
    top: 0;
    margin-right: 5%;
  }  

  header nav[aria-expanded='true'] .nav-sections {
    display: flex;
    flex-direction: row;
  }

  header nav,
  header nav .nav-tools ul {
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
  }

  header nav .nav-tools ul {
    display: flex;
    flex-direction: row !important;
  }

  header nav .nav-tools ul > *:nth-child(2),
  header nav .nav-tools ul > *:nth-child(3) {
    display: none !important;
  }

  header nav[aria-expanded="true"] .nav-search {
    width: auto;
    position: sticky;
    right: 20px;
    top: 48px;
    z-index: 102;
    padding-right: 25px;
  }

  .filter-modal-content form {
    flex-direction: row;
    align-items: end;
    gap: 15px;
  }

  .filter-modal-content form > div {
    flex: 1;
  }

  /* stylelint-disable-next-line no-descending-specificity */
  .filter-modal-content form button {
    margin-top: 0;
    white-space: nowrap;
  }

  .status-filter-section {
    max-width: 600px;
  }

  .status-checkbox-container {
    display: inline-block;
  }

  dialog:has(.filter-modal-content) .status-checkboxes-container {
    margin-right: 2px;
  }
}

@media (900px <= width <= 1300px) {
  header .nav-wrapper {
    font-size: 14px;
  }

  header nav[aria-expanded='true'] .nav-tools {
    /* Keep sticky positioning for mobile, static only for desktop */
    position: sticky;
    top: 0;
    box-sizing: border-box;
    overflow: visible;
    margin-right: 35px;
    margin-left: 10px;
  }

  header nav[aria-expanded='true'] .nav-tools li {
    padding: 5px 0;
  }

  header nav .nav-tools ul {
    flex-wrap: wrap;
    white-space: normal;
    width: 100%;
    box-sizing: border-box;
    justify-content: right;
    padding-left: 0;
  }

  header .nav-wrapper,
  header nav {
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
  }
  
  header nav .nav-brand img {
    padding-left: 0;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    display: block;
    position: static;
  }
}

/* Ensure header stays sticky even when body has overflow-y: hidden */
body[style*="overflow-y: hidden"] header {
  position: sticky !important;
  top: 0 !important;

  /* Force sticky behavior even with body overflow hidden */
  transform: translateZ(0) !important;
  will-change: transform !important;
  isolation: isolate !important;
}

/* Ensure mobile menu stays sticky even when body has overflow-y: hidden */
body[style*="overflow-y: hidden"] header nav[aria-expanded="true"] .nav-tools {
  position: sticky !important;
  top: 0 !important;

  /* Force sticky behavior even with body overflow hidden */
  transform: translateZ(0) !important;
  will-change: transform !important;
  isolation: isolate !important;
}

/* Ensure header stays above scroll wrapper */
#scroll-wrapper {
  z-index: 50;
}

/* Simplified header - hides navigation and centers brand */
#simples ~ .nav-sections,
#simples ~ .nav-tools,
#simples ~ .nav-search,
header:has(#simples) nav .nav-hamburger {
  display: none !important;
}

/* Remove border when simples id is present */
header .nav-wrapper:has(#simples) {
  border-bottom: none !important;
}

/* Center the nav-brand when it has id="simples" */
header #simples.nav-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--nav-height);
  text-align: center;
  padding: 0;
}

/* Update header nav min-height when simples id is present */
header .nav-wrapper:has(#simples) nav {
  min-height: var(--nav-height);
}

/* Unset position sticky when simples id is present */
header:has(#simples) {
  position: static;
}

header #simples.nav-brand img {
  width: auto;
  height: 33px;
  max-width: 300px;
  object-fit: contain;
  margin-top: 0;
}

/* Responsive adjustments for simplified header */
@media (width >= 900px) {
  header:has(#simples) {
    height: 131px;
  }
  
  header #simples.nav-brand img {
    height: 86px;
    margin: 0 auto;
  }
}
