import { useState } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { FiChevronDown, FiChevronUp } from 'react-icons/fi';

function FAQ() {
  const [openSections, setOpenSections] = useState({});

  const faqSections = [
    {
      title: 'General Information',
      questions: [
        {
          question: "What is RoyalCity?",
          answer: "RoyalCity is an innovative investment project dedicated to real estate. We allow clients to invest as little as $10 in investment properties, with the aim of building up regular income and/or savings."
        },
        {
          question: "What are the conditions for investing on RoyalCity?",
          answer: "Any person of legal age can hold a RoyalCity NFT! Investing is simple - you merely need to have VeChain wallet and you are ready to buy one or more RoyalCity NFTs."
        },
        {
          question: "Can I invest with a company or SCI?",
          answer: "Of course you can! As for an individual you need the same things, i.e. to hold one or more RoyalCity NFTs."
        },
        {
          question: "How are the properties selected?",
      
          answer: "We select and negotiate the acquisition of rental or investment propertiess, and soon abroad. We do our utmost to guarantee a selection of quality rental projects and optimal risk control.  Each operation is rigorously evaluated by our real estate experts, according to strict criteria including:  i. the occupancy rate of the building and its net rental return on the day of acquisition ii. the general condition of the building and the common areas iii. the cost of maintenance and renovation work iv. the energy performance v. the quality of the neighbourhood vi. the geographical location of the building vii. the proximity of essential services (shops, schools, public transport, etc.) viii. key indicators such as demographics, rental pressure and the evolution of property prices in the area."
        },
        {
          question: "Do you become a homeowner by buying NFTs on RoyalCity?",
          answer: "When you buy NFTs on RoyalCity, you are not actually buying part of a property, nor do you become an owner. You hold royalties, which means that you are entitled to receive a royalty on the rents and capital gains generated by the property in which you invest. The amount of these royalties is paid to you every month, depending on the number of NFTs you own. The advantage: an immediate return on investment with income paid every month (linked to the rents collected), without the management, financing or tax constraints associated with traditional rental investment!"
        },
        {
          question: "When buying NFTs, do we benefit from the bank leverage effect?",
      
          answer: "Yes, most of the properties we offer on our platform do not have a bank loan but some are co-financed with a bank loan. Borrowing from the bank allows us to leverage the bank and increase the profitability of the investments."
        },
        {
          question: "Can buying NFTs reduce my borrowing capacity?",
      
          answer: "Absolutely not. The bank loans used to finance the projects are carried by our company. The purchase of NFTs therefore has no impact on your debt ratio or borrowing capacity."
        },
        {
      
          question: "How is the property revaluation carried out?",
      
          answer: "Because the value of a property can vary over time, each of our properties is revalued every year by an independent, TEGoVA-accredited property expert. These valuations take into account changes in the property market and any work carried out on the property. They allow the value of the NFTs to be revalued upwards or downwards. This ensures that your money is invested in property that is fairly valued."
        },
        {
      
          question: "I want to buy NFTs, what payment methods are accepted?",
      
          answer: "You can use various payment methods such as Metamask, Phantom wallet, OKX wallet, Trust wallet, etc."
        },
        {
      
          question: "Is it possible to cancel my NFT purchase?",
      
          answer: "At the moment it is not possible to get the NFT refunded after the purchase, but with time we will try to implement this function with a liquidity pool. After signing the deed of sale at the notary's office, you can sell your NFTs to other investors on our Marketplace (secondary market)."
        },
        {
      
          question: 'What is the difference between "Profitability" and "Return on investment"?',
      
          answer: 'The "Return on investment" corresponds to the excess part of the rents which will be paid to you after deduction of the amortization of the expenses, and, if necessary, the RoyalCityayment of credit. The "Profitability" corresponds to the returned income to which are added the real estate capital gain and the mechanical increase in the price of the NFT due to the amortization of the real estate loan present on the property in question.'
        }
      ]
    },
    {
      title: 'MarketPlace',
      questions: [
        {
          question: "What is the marketplace, or secondary market?",
          answer: "The RoyalCity Marketplace is our platform that allows RoyalCity community members to buy and sell NFTs among themselves.  It is the equivalent of a secondary market where investors can buy and sell NFTs among themselves. We may also cooperate with other marketplaces to allow anyone to choose their preferred marketplace."
        },
        {
          question: "How do I resell my NFTs on the marketplace?",
          answer: 'From your wallet, on the "Connect" page, in the "Marketplace" tab, you will find all the properties for which you own NFTs. You just have to click on the "Sell" button to sell one or more NFTs of your choice. Good to know: you cannot resell NFTs on the marketplace before the notary has signed the deed of sale for the property concerned.'
        },
        {
          question: "Is the resale of my NFTs on the marketplace guaranteed?",
          answer: "Given the current demand, liquidity is fast. However, it is not guaranteed. As with any transaction, there must be a seller and a buyer. To sell your NFTs, another investor must buy them. To sell quickly, we recommend that you sell your NFTs at the estimated price."
        },
        {
          question: "At what price can I sell my NFTs?",
          answer: "You can sell your NFTs at any price you wish."
        },
        {
          question: "I sell or buy NFTs during the month. Who receives the rental income for the current month?",
          answer: "The rental income is paid to the investor who owns the NFTs on the day the royalties are paid."
        },
        {
      
          question: "What are the advantages of buying NFTs on the marketplace?",
      
          answer: "Buying NFTs on the secondary market has two main advantages: i. You get an immediate return. ii. You can invest in the city or building of your choice. In contrast, on the primary market, you can only invest in available properties."
        },
        {
          question: "What are the fees on the marketplace?",
          answer: "We take a 10% fee on the secondary market. This fee allows us to cover our various costs, and to build up a reserve to facilitate instant liquidity on the marketplace. If we cooperate with other marketplaces, their platform fees must also be taken into account."
        },
        {
          question: "Can I cancel a purchase on the marketplace?",
      
          answer: "You cannot cancel an NFT purchase from the marketplace."
        }
      ]
    },
    {
      title: 'Property Management',
      questions: [
        {
          question: "Who does the property management?",
          answer: "We take care of the rental, technical, administrative and legal management of the properties.  As an investor, you have nothing to manage. Property search, financing, acquisition, maintenance or renovation work, management of tenants, payment of property tax: you can have peace of mind, RoyalCity takes care of everything."
        },
        {
          question: "How does RoyalCity finance work on properties?",
          answer: "At the time of each acquisition, we carry out an estimate of the work to be done. When financing properties on the platform, we set up a provision for future work. This cash reserve, set up at the time of the initial financing, allows us to finance any future works. At the same time, we set aside between 3 and 5% of the rental income each year to finance a security reserve for future works. In this respect, our operation is similar to that of a co-ownership. In the event of unforeseen circumstances, if major works were to be carried out on one of our buildings, we could consider suspending the payment of royalties for the time needed to finance these works. However, RoyalCity holders will never be asked to reinvest to finance any work on any of our buildings. Of course, we try to limit this type of risk as much as possible by selecting the properties we offer to finance according to strict criteria."
        },
        {
          question: "What will happen to the properties once they are purchased?",
          answer: "We maintain our properties in such a way as to ensure and maintain their rental value over time. Whenever necessary, we carry out maintenance and renovation work on our properties. Our investment strategy and the contract provide for a liquidity event, 7 to 10 years after the acquisition of the property. This will result in either the resale of the property or our liquidity pool to buy back your NFTs. This decision will be made on a case-by-case basis by RoyalCity, and in the interest of the investors."
        },
        {
          question: "What happens if a tenant does not pay his rent?",
          answer: "In the event of a vacancy, or in the event of a tenant defaulting on payment, the amount of royalties we pay to investors may be reduced, thus affecting the expected annual return. This risk is inherent in any rental investment, whether the property is rented directly or through an estate agent. In order to dilute the risk of non-payment, we buy mainly rental properties with several lots or flats. This limits the risk of losing all the rent in the event of a tenant defaulting. Finally, to further limit this risk, we will, as soon as possible, put in place a guarantee for unpaid rent (GLI) on each flat that we rent out. This allows us to transfer the risk of unpaid rent to the insurer."
        }
      ]
    },
    {
      title: 'Accounting',
      questions: [
        {
          question: "What accounting evidence will I receive as an investor?",
          answer: "We will provide the income assignment contract, which can be downloaded from the property sheet."
        }
      ]
    },
    {
      title: 'Financial',
      questions: [
        {
          question: "What profitability can I achieve?",
          answer: "Profitability depends on each property as it is a ratio between the price of the property, its rental income, any work effected on it, changes to its value, and whether or not it or part of it is financed by a mortgage. We do our utmost to offer opportunities with an estimated average profitability of 6% per year. This profitability is not guaranteed, it is an estimate. Nevertheless, we do our very best to secure the announced profitability. We select areas where rental demand is higher than supply, and we put in place a guarantee of unpaid rent (GLI) on the properties under our management as soon as this is possible. However, there is no such thing as zero risk and there may be rental vacancies, unpaid rent or periods of work that reduce overall profitability. To dilute this risk, we present buildings with multiple studios or apartments. For example, in a building with 40 lots, in the event of a rental vacancy in one flat, the overall profitability will not be significantly affected. We therefore recommend that you diversify your portfolio of properties."
        },
        {
          question: "What is the difference between gross and net rents?",
          answer: "Gross rents are the rents paid by tenants every month. Net rents are the gross rents minus charges, provisions and loan repayments. It is the net rents that are paid out each month as royalties to the NFT RoyalCity holders. The amount may fluctuate depending on the rents collected and the current charges."
        },
        {
          question: "How does RoyalCity pay itself?",
          answer: "RoyalCity takes no entry fees, no exit fees and no fees on capital gains. The fees applied are as follows: i. 10% of the purchase amount (in primary sales).  So you take an entry fee ii. 10% secondary market fee. So the person buying takes an entry fee iii. 1% rental management fee."
        }
      ]
    },
    {
      title: 'Legal',
      questions: [
        {
          question: "What is Royalty financing",
          answer: "When you invest in an asset through an NFT RoyalCity, you are bound by a royalty agreement. The royalty agreement is evidence that we are committed to paying you a percentage of our turnover at a constant frequency over the term of the agreement. The royalty regime is a contractual regime in addition to the regulated statutes (CIP, IFP), and based on common consumer and contract law. The financing operation is subject to neither a prospectus approved by the financial market authority nor to control by any other body responsible for the protection of savings. The royalty right does not constitute a financial instrument within the meaning of Article L.211-1 of the Monetary and Financial Code. The rules on direct marketing of banking and financial products do not apply."
        },
        {
          question: "What happens if the financing objective is not reached on a property?",
          answer: "For each property, the sums paid by investors are deposited in an escrow bank account. The funds are only credited to the transaction if the fundraising campaign is successful. In the event that the transaction is not fully funded at the time of collection, we may be able to carry out the transaction on a credit in order to use the bank leverage effect or, if this is not possible, the funds will be returned in full to the investors, and you will be reimbursed 100%."
        },
        {
          question: "How will my personal data be used?",
          answer: 'In accordance with the French law "Informatique et Libertés", RoyalCity is committed to respecting the regulatory and ethical provisions on the protection of personal data. The information you provide when you register is stored on the platform in a secure and encrypted manner. Under no circumstances will RoyalCity sell your personal information to third parties.'
        },
        {
          question: "Are transactions on the platform secure?",
      
          answer: "RoyalCity uses the most advanced technical means to ensure the confidentiality and security of transactions on the platform. "
        }
      ]
    }
  ];

  const toggleSection = (sectionTitle, questionIndex) => {
    setOpenSections(prev => ({
      ...prev,
      [`${sectionTitle}-${questionIndex}`]: !prev[`${sectionTitle}-${questionIndex}`]
    }));
  };
 

  return (
    <div className="min-h-screen bg-secondary-50 py-16">
      <div className="container">
        <motion.div
          initial={{ opacity: 0, y: 20 }}
          animate={{ opacity: 1, y: 0 }}
          className="max-w-3xl mx-auto"
        >
          <h1 className="text-4xl font-bold text-center mb-4">Frequently Asked Questions</h1>
          <p className="text-secondary-600 text-center mb-12">
            Find answers to common questions about our platform, cryptocurrency payments, and real estate investment.
          </p>

          <div className="space-y-8">
            {faqSections.map((section, sectionIndex) => (
              <div key={sectionIndex} className="bg-white rounded-lg shadow-md overflow-hidden">
                <h2 className="text-xl font-semibold p-6 bg-secondary-50">
                  {section.title}
                </h2>
                <div className="divide-y divide-secondary-100">
                  {section.questions.map((item, questionIndex) => (
                    <div key={questionIndex} className="p-6">
                      <button
                        className="w-full flex justify-between items-center text-left"
                        onClick={() => toggleSection(section.title, questionIndex)}
                      >
                        <span className="font-medium">{item.question}</span>
                        {openSections[`${section.title}-${questionIndex}`] ? (
                          <FiChevronUp className="flex-shrink-0 ml-4" />
                        ) : (
                          <FiChevronDown className="flex-shrink-0 ml-4" />
                        )}
                      </button>
                      <AnimatePresence>
                        {openSections[`${section.title}-${questionIndex}`] && (
                          <motion.div
                            initial={{ height: 0, opacity: 0 }}
                            animate={{ height: 'auto', opacity: 1 }}
                            exit={{ height: 0, opacity: 0 }}
                            transition={{ duration: 0.3 }}
                            className="overflow-hidden"
                          >
                            <p className="mt-4 text-secondary-600">
                              {item.answer}
                            </p>
                          </motion.div>
                        )}
                      </AnimatePresence>
                    </div>
                  ))}
                </div>
              </div>
            ))}
          </div>
        </motion.div>
      </div>
    </div>
  );
}

export default FAQ;