<template>
  <footer class="page-footer">
    <div class="footer-section">
      <span class="footer-label">Presented By</span>
      <div class="logos-row">
        <div v-for="(logo, i) in presentedBy" :key="'p-' + i" class="logo-item">
          <img :src="logo.src" :alt="logo.name" class="logo-image" />
        </div>
      </div>
    </div>

    <div class="footer-section">
      <span class="footer-label">Academic Collaborators</span>
      <div class="logos-row">
        <div v-for="(logo, i) in collaborators" :key="'c-' + i" class="logo-item">
          <img :src="logo.src" :alt="logo.name" class="logo-image" />
        </div>
      </div>
    </div>

    <!-- Bottom right: copyright and updates -->
    <div class="footer-bottom-right">
      <span class="copyright">© 2025 Agent Market Arena</span>
      <span class="divider">|</span>
      <span class="updates-link" @click="showUpdates = true">Updates</span>
    </div>

  </footer>

  <!-- Updates Modal - Teleport to body so it's not constrained by footer -->
  <Teleport to="body">
    <div v-if="showUpdates" class="modal-overlay" @click.self="showUpdates = false">
      <div class="modal-content">
        <div class="modal-header">
          <span class="modal-title">📋 Major Updates</span>
          <span class="modal-close" @click="showUpdates = false">✕</span>
        </div>
        <div class="modal-body">
          <div v-for="(update, idx) in updates" :key="idx" class="update-item">
            <div class="update-date">{{ update.date }}</div>
            <ul class="update-list">
              <li v-for="(item, i) in update.items" :key="i" v-html="item"></li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </Teleport>
</template>

<script>
export default {
  name: "PageFooter",
  data() {
    return {
      showUpdates: false,
      presentedBy: [
        { name: "DeepKin", src: new URL("../assets/images/companies_images/deepkin_logo.png", import.meta.url).href },
        { name: "The Fin AI", src: new URL("../assets/images/companies_images/logofinai.png", import.meta.url).href },
        { name: "NaCTeM", src: new URL("../assets/images/companies_images/nactemlogo.png", import.meta.url).href },
        { name: "PAAL AI", src: new URL("../assets/images/companies_images/paalai_logo.png", import.meta.url).href },
      ],
      collaborators: [
        { name: "Stevens Institute of Technology", src: new URL("../assets/images/companies_images/stevens.png", import.meta.url).href },
        { name: "University of Florida", src: new URL("../assets/images/companies_images/florida.png", import.meta.url).href },
        { name: "Columbia University", src: new URL("../assets/images/companies_images/columbia.png", import.meta.url).href },
        { name: "Harvard University", src: new URL("../assets/images/companies_images/harvard.png", import.meta.url).href },
        { name: "Université de Montréal", src: new URL("../assets/images/companies_images/montreal.png", import.meta.url).href },
        { name: "Georgia Institute of Technology", src: new URL("../assets/images/companies_images/georgia.png", import.meta.url).href },
      ],
      updates: [
        {
          date: '2025-12-05',
          items: [
            '<strong>Trading Fee:</strong> Updated from 0.05% to <strong>0.06%</strong>',
            '<strong>Slippage Fee:</strong> Added <strong>0.1%</strong> slippage<br/>&nbsp;&nbsp;• Buy orders: price × 1.001<br/>&nbsp;&nbsp;• Sell orders: price × 0.999',
          ]
        },
      ],
    };
  },
};
</script>

<style scoped>
.page-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fb 100%);
  border-top: 2px solid rgba(0, 0, 0, 0.05);
  z-index: 100;
  backdrop-filter: blur(6px);
}

.footer-section {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.footer-label {
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, rgb(0, 0, 185), rgb(240, 0, 15));
  -webkit-background-clip: text;
  color: transparent;
}

.logos-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.logo-item {
  width: 72px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease;
}

.logo-item:hover {
  transform: translateY(-2px) scale(1.03);
}

.logo-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.2));
}

/* Bottom right section */
.footer-bottom-right {
  position: absolute;
  bottom: 0.5rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #6b7280;
}

.copyright {
  font-weight: 500;
}

.divider {
  color: #d1d5db;
}

.updates-link {
  cursor: pointer;
  color: #4f46e5;
  font-weight: 600;
  transition: color 0.2s ease;
}

.updates-link:hover {
  color: #3730a3;
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
  .page-footer {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }

  .logo-item {
    width: 60px;
    height: 20px;
  }

  .footer-bottom-right {
    position: static;
    margin-top: 0.5rem;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .footer-label {
    font-size: 0.8rem;
  }

  .logos-row {
    gap: 0.75rem;
  }

  .logo-item {
    width: 52px;
    height: 18px;
  }

  .footer-bottom-right {
    font-size: 0.7rem;
  }
}
</style>

<!-- Global styles for Teleported modal -->
<style>
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  cursor: pointer;
  font-size: 1.25rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}

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

.modal-body {
  padding: 1.25rem;
  max-height: 60vh;
  overflow-y: auto;
}

.update-item {
  margin-bottom: 1.25rem;
}

.update-item:last-child {
  margin-bottom: 0;
}

.update-date {
  font-size: 0.9rem;
  font-weight: 700;
  color: #4f46e5;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid #e5e7eb;
}

.update-list {
  margin: 0;
  padding-left: 1.25rem;
  color: #374151;
  font-size: 0.875rem;
  line-height: 1.6;
}

.update-list li {
  margin-bottom: 0.5rem;
}

.update-list li:last-child {
  margin-bottom: 0;
}
</style>
