body:has(.layered-modal:not(.hidden)) {
  overflow: hidden;
}

.layered-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 20px;
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  pointer-events: all;
  overflow: hidden;
  z-index: 9999;

  @media (width < 1024px) {
    padding: 0;
  }

  &.hidden {
    opacity: 0;
    pointer-events: none;

    @media (width < 1024px) {
      .modal-content {
        transform: translateY(100%);
      }
    }
  }

  .modal-content {
    background: #FFFFFF;
    border-radius: 20px;
    position: relative;
    transform: translateZ(0);
    /* Isolate from backdrop-filter */
    width: 100%;
    max-width: 960px;
    margin: auto;

    display: grid;

    @media (width >=1024px) {
      display: flex;
      flex-direction: column;
      max-height: 95vh;
      overflow: hidden;
    }

    @media (width < 1024px) {
      max-width: 100%;
      height: 100%;
      border-radius: 0;
      margin: 0;
      overflow-y: auto;
      /* Whole modal scrolls on mobile */
    }

    .modal-close {
      background: transparent;
      border: none;
      cursor: pointer;
      padding: 0;
      position: absolute;
      right: 12px;
      top: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.3s ease;
      outline: unset;
      z-index: 10;

      &:hover {
        transform: scale(1.1);
      }

      img {
        width: 24px;
        height: 24px;
      }

      @media (width < 1024px) {
        top: 0;
        right: 0;
        padding: 12px;
      }
    }

    .modal-container {
      padding: 38px 16px 24px;
      min-height: 0;

      @media (min-width: 1024px) {
        padding: 40px;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
    }

    .modal-grid {
      display: flex;
      flex-direction: column;
      flex: 1;
      min-height: 0;

      @media (width >=1024px) {
        display: grid;
        gap: 40px;
        grid-template-columns: 300px 1fr;
      }
    }

    /* Left Sidebar Information */
    .modal-info {
      background: #FFFFFF;
      display: flex;
      flex-direction: column;
      gap: 16px;
      position: relative;
      order: 2;

      margin-top: auto;
      margin-bottom: 24px;

      @media (min-width: 1024px) {
        margin: unset;
        order: unset;
      }

      p {
        font-family: var(--font-outfit);
        font-size: 14px;
        font-weight: 400;
        color: #001745B2;
        line-height: 20px;
        margin: 0;
        text-align: left;
      }

      .info-header {
        position: relative;

        span {
          display: none;

          @media (min-width: 1024px) {
            display: block;
            font-family: var(--font-outfit);
            font-size: 18px;
            line-height: 28px;
            font-weight: 600;
            color: var(--primary-color);
            margin: 0 0 20px;

            max-width: 300px;

            letter-spacing: -1%;
            text-transform: none;
            /* Reset uppercase if it was set globally */
          }
        }

        p:first-of-type {
          display: none;

          @media (width >=1024px) {
            display: block;
          }
        }
      }

      .contact-options {
        display: flex;
        flex-direction: column;
        gap: 8px;

        .contact-link {
          display: flex;
          align-items: center;
          gap: 8px;
          text-decoration: none;
          font-family: var(--font-outfit);
          font-size: 14px;
          font-weight: 600;
          color: var(--color-primary-mid);
          transition: opacity 0.2s;

          &:hover {
            opacity: 0.8;
          }

          img {
            width: 20px;
            height: 20px;
            filter: brightness(0) saturate(100%) invert(24%) sepia(61%) saturate(2993%) hue-rotate(216deg) brightness(98%) contrast(95%);
          }
        }

        .whatsapp {
          color: #103928;

          img {
            filter: brightness(0) saturate(100%) invert(15%) sepia(87%) saturate(352%) hue-rotate(103deg) brightness(96%) contrast(94%);
          }
        }
      }
    }

    /* Right Side Form */
    .modal-form-container {
      background: #FFFFFF;

      >span {
        display: block;

        font-family: var(--font-outfit);
        font-size: 18px;
        line-height: 28px;
        font-weight: 600;
        color: var(--primary-color);
        margin: 0 0 20px;

        max-width: 300px;

        letter-spacing: -1%;
        text-transform: none;
        /* Reset uppercase if it was set globally */

        @media (width >=1024px) {
          display: none;
        }
      }

      @media (width >=1024px) {
        height: 100%;
        overflow-y: auto;
        padding-right: 8px;

        &::-webkit-scrollbar {
          width: 6px;
        }

        &::-webkit-scrollbar-track {
          background: #00174526;
          border-radius: 4px;
        }

        &::-webkit-scrollbar-thumb {
          background: var(--primary-color);
          border-radius: 4px;
        }

        &::-webkit-scrollbar-thumb:hover {
          background: var(--color-primary-mid);
        }
      }

      form {
        display: flex;
        flex-direction: column;
        gap: 8px;

        .form-row {
          display: grid;
          grid-template-columns: 1fr 1fr;
          gap: 8px;
          margin: 0;

          @media (width < 640px) {
            grid-template-columns: 1fr;
          }
        }

        .phone-row {
          display: grid;
          grid-template-columns: 120px 1fr;
          gap: 8px;

          @media (min-width: 1024px) {
            grid-template-columns: 120px 1fr;
          }

          #group-email {
            flex: 1 1 100%;
            grid-column: span 2;

            @media (min-width: 1024px) {
              flex: 1 1 auto;
              grid-column: auto;
            }
          }

          #group-phone-code {
            flex: 0 0 120px;

            input {
              padding: 12px 16px;
            }
          }

          .form-group:last-child {
            flex: 1 1 auto;
          }

          .options-list {
            width: 150%;
          }
        }

        .form-group {
          position: relative;
          display: flex;
          flex-direction: column;
          margin-bottom: 0;

          label {
            position: absolute;
            top: 24px;
            transform: translate(0px, -50%);
            left: 17px;
            font-family: var(--font-outfit);
            font-size: 16px;
            font-weight: 400;
            margin: 0;
            color: #49597A;
            pointer-events: none;
            transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
            text-transform: none;
            letter-spacing: 0;
            z-index: 10;
            transform-origin: left top;
            will-change: transform;
            backface-visibility: hidden;
            text-rendering: optimizeLegibility;
            -webkit-font-smoothing: antialiased;
          }

          &.disabled {
            label {
              color: var(--color-content-low) !important;
            }

            select,
            .select-wrapper::after {
              opacity: 0.4 !important;
            }
          }

          &:not(.disabled):has(input:focus) label,
          &:not(.disabled):has(input:not(:placeholder-shown)) label {
            transform: translateY(-18px) scale(0.75) translateZ(0);
          }

          input,
          select {
            width: 100%;
            min-height: 48px;
            padding: 17px 16px 5px;
            /* Adjusted padding for floating label */
            background: #0017450D;
            border: 1px solid transparent;
            border-radius: 12px;
            font-family: var(--font-outfit);
            font-size: 16px;
            font-weight: 400;
            line-height: 24px;
            color: var(--primary-color);
            outline: none;
            transition: border-color 0.2s ease, background-color 0.2s ease;
            position: relative;
            z-index: 5;
            caret-color: var(--color-primary-mid);

            &::placeholder {
              color: transparent;
            }

            &:focus:not([readonly]):not([disabled]) {
              border-color: var(--color-primary-mid);
            }

            .form-group.disabled & {
              border-color: transparent !important;
              outline: none !important;
              cursor: default !important;
            }

            &.error {
              border-color: var(--color-danger-mid);
            }
          }

          select {
            appearance: none;
            cursor: pointer;
            background-image: url("/wp-content/themes/templatePLG/resources/assets/images/svg/rebranding/chevron-sheet-selector.svg");
            background-repeat: no-repeat;
            background-position: right 16px center;
            background-size: 20px;
          }

          .class-error {
            display: none;
            font-family: var(--font-outfit);
            font-size: 12px;
            font-weight: 400;
            line-height: 16px;

            color: #DD3222;

            margin-top: 8px;
            align-items: center;
            gap: 4px;

            &.show {
              display: flex;
            }

            img {
              display: inline-block;
              width: 16px;
              height: 16px;
              filter: brightness(0) saturate(100%) invert(25%) sepia(36%) saturate(5830%) hue-rotate(351deg) brightness(91%) contrast(90%);
            }

            span {
              display: block;
            }
          }
        }

        .privacy-box {
          position: relative;
          background: #0017450D;
          border-radius: 12px;
          max-height: 56px;
          overflow-y: auto;

          &::after {
            content: '';
            width: 100%;
            height: 16px;
            background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #FFFFFF 100%);
            position: absolute;
            bottom: 0;
            left: 0;
            pointer-events: none;
            opacity: 1;
            transition: opacity 0.3s ease;
          }

          &:has(.is-at-bottom) {
            &::after {
              opacity: 0;
            }
          }

          p {
            font-family: var(--font-outfit);
            font-size: 12px;
            line-height: 16px;
            color: #001745B2;

            padding: 8px 8px 8px 16px;
            margin: 0 16px 0 0;
            max-height: 56px;
            overflow-y: scroll;

            &::-webkit-scrollbar {
              width: 4px;
            }

            &::-webkit-scrollbar-track {
              background: #00174526;
              border-radius: 4px;
              margin: 8px 0;
            }

            &::-webkit-scrollbar-thumb {
              background: var(--primary-color);
              border-radius: 4px;
            }

            a {
              color: var(--color-primary-mid);
              text-decoration: underline;
            }
          }
        }

        .checkbox-group {
          display: flex;
          align-items: flex-start;
          gap: 10px;
          margin-top: 8px;

          input[type="checkbox"] {
            display: none;

            &:checked+.checkmark {
              background-color: var(--color-primary-mid);
              border-color: var(--color-primary-mid);

              &::after {
                content: '';
                display: block;
                border: solid white;
                border-width: 0 1px 1px 0;
                position: absolute;
                left: 5px;
                top: 1px;
                width: 5px;
                height: 9px;
                transform: rotate(45deg);
              }
            }
          }

          .checkmark {
            flex: 0 0 auto;
            display: block;
            position: relative;
            border: 1px solid var(--color-border-mid);
            border-radius: 4px;
            width: 16px;
            height: 16px;
            background-color: #0017450D;
            transition: background-color 0.2s ease;

            cursor: pointer;
          }

          label {
            font-family: var(--font-outfit);
            font-size: 12px;
            line-height: 16px;
            color: #001745B2;

            display: flex;
            gap: 8px;
            align-items: center;

            margin: 0;

            a {
              color: var(--color-primary-mid);
              text-decoration: underline;
            }
          }
        }

        .btn-azul {
          margin-top: 8px;
        }
      }
    }
  }
}

/* --- Custom Searchable Selects --- */
.layered-modal .hidden-select {
  display: none !important;
}

.layered-modal .custom-select-group {
  position: relative !important;
}

.layered-modal .select-wrapper {
  width: 100%;
  height: 48px;
  position: relative;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  cursor: pointer;
  z-index: 5;
}

.layered-modal .select-wrapper.error {
  border-color: #DD3222;
}

.layered-modal .custom-select-group.disabled .select-wrapper {
  cursor: default !important;
  border-color: transparent !important;
}

.layered-modal .select-wrapper::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background-image: url("/wp-content/themes/templatePLG/resources/assets/images/svg/rebranding/chevron-sheet-selector.svg");
  background-repeat: no-repeat;
  background-size: contain;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 1;
  will-change: transform;
}

.layered-modal .select-wrapper.open::after {
  transform: translateY(-50%) rotate(180deg) translateZ(0);
}

.layered-modal .findOptionInput {
  width: 100%;
  height: 100%;
  padding: 12px 16px;
  padding-right: 40px;
  background: transparent;
  border: none;
  margin: 0;
  outline: none;
  font-family: var(--font-outfit);
  font-size: 16px;
  color: var(--primary-color);
  cursor: pointer;
  z-index: 6;
  transition: color 0.3s ease;
}

.layered-modal .options-list {
  position: absolute;
  top: calc(48px + 4px);
  left: 0;
  width: 100%;
  max-height: 250px;
  background: #FFFFFF;
  border: 1px solid #E6E8ED;
  border-radius: 12px;
  padding: 4px;
  margin: 0;
  list-style: none;
  overflow-y: auto;
  display: none;
  z-index: 1000;

  &::-webkit-scrollbar {
    width: 4px;
  }

  &::-webkit-scrollbar-track {
    background: #FFFFFF;
    margin: 16px 0;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
  }
}

.layered-modal .options-list.show {
  display: block !important;
}

.layered-modal .options-list li {
  padding: 10px 12px;
  border-radius: 8px;
  font-family: var(--font-outfit);
  font-size: 14px;
  color: #475569;
  cursor: pointer;
  transition: background 0.2s;
  list-style: none !important;
}

.layered-modal .options-list li:hover,
.layered-modal .options-list li.focused {
  background: #F2F3F5;
}

.layered-modal .options-list li.zeroResults {
  color: #94A3B8;
  font-style: italic;
  pointer-events: none;
}