/* =====================================================
   VARIÁVEIS GLOBAIS
   ===================================================== */
:root {
  --erasmus-dark:    #004494;
  --erasmus-blue:    #007FC7;
  --erasmus-yellow:  #FFED00;
  --erasmus-light:   #C7DFF4;
  --text-dark:       #1a1a1a;
  --bg-light:        #f8f9fa;
  --shadow-soft:     0 2px 8px rgba(0,0,0,0.12);
  --shadow-medium:   0 4px 12px rgba(0,0,0,0.15);
}

/* =====================================================
   RESET + BASE
   ===================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Roboto', Arial, Helvetica, sans-serif;
  color: var(--text-dark);
  background: white;
  line-height: 1.6;
}

/* =====================================================
   APENAS NA PÁGINA PRINCIPAL (index.html) → sem scroll
   ===================================================== */
body:has(main.container.main-content) {
  overflow: hidden;           /* só afeta index.html */
}

/* Font sizes fluid/responsivos */
body {
  font-size: clamp(15px, 2.8vw, 17px);
}

/* Imagens fluidas */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* =====================================================
   LOGO FIXO CANTO SUPERIOR ESQUERDO
   ===================================================== */
.logos {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 1100;
}

.logos img {
  height: clamp(60px, 12vw, 80px);
  transition: transform 0.25s ease;
}

.logos:hover img {
  transform: scale(1.1);
}

/* =====================================================
   NAVBAR
   ===================================================== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  height: 70px;
  background: linear-gradient(to bottom, var(--erasmus-light) 20%, white 100%);
  box-shadow: var(--shadow-soft);
  border-bottom: 1px solid #e0e0e0;
}

.nav-flex {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.8rem 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

.menu {
  display: flex;
  gap: 1.6rem;
  align-items: center;
}

.menu a,
.menu span {
  color: var(--erasmus-blue);
  text-decoration: none;
  font-weight: 500;
  font-size: clamp(0.95rem, 2.4vw, 1.05rem);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.menu a:hover,
.menu span:hover {
  background: var(--erasmus-yellow);
  color: var(--erasmus-dark);
}

/* Submenu */
.menu-item {
  position: relative;
}

.submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--erasmus-blue);
  min-width: 240px;
  border-radius: 0 0 6px 6px;
  box-shadow: var(--shadow-medium);
}

.menu-item:hover .submenu {
  display: block;
}

.submenu a {
  display: block;
  color: white;
  padding: 0.8rem 1.2rem;
  font-size: 0.97rem;
}

.submenu a:hover {
  background: var(--erasmus-yellow);
  color: var(--erasmus-dark);
}

/* Navbar do projeto (centralizado) */
.navbarproj .nav-flex {
  justify-content: center;
}

.navbarproj .menuproj {
  gap: 2.2rem;
}

/* =====================================================
   LAYOUT PRINCIPAL (index.html)
   ===================================================== */
main.container.main-content {
  height: calc(100vh - 70px - 70px);   /* navbar + footer */
  margin-top: 70px;
  margin-bottom: 0px;
  overflow: hidden;                    /* importante: sem scroll na janela principal */
  display: flex;
  justify-content: center;
  align-items: stretch;
}

iframe[name="content-frame"] {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* =====================================================
   PÁGINAS DENTRO DO IFRAME (p1.html, p2.html, etc.)
   ===================================================== */
body:not(:has(main.container.main-content)) {
  overflow-y: auto;           /* permite scroll vertical normal */
  min-height: 100vh;          /* garante que ocupa pelo menos a tela toda */
  padding-top: 10px;          /* espaço para a navbar fixa do index */
  padding-bottom: 90px;       /* espaço para o footer fixo */
}

/* Conteúdo das páginas secundárias */
.page-wrapper,
.secondary-content,
.projects,
.project-intro-table {
  max-width: 1200px;
  margin: 0 auto;
  
}

/* Garantir que tabelas e imagens não quebrem o layout */
img, table, .project-intro-table {
  max-width: 100%;
  height: auto;
}

/* =====================================================
   Footer e Navbar (mantêm-se fixos no index)
   ===================================================== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 70px;
  z-index: 1000;
  background: linear-gradient(to bottom, var(--erasmus-light) 20%, white 100%);
  box-shadow: var(--shadow-soft);
}

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 70px;
  z-index: 900;
  background: linear-gradient(to top, var(--erasmus-light) 20%, white 100%);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.footer iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Tabelas de introdução */
.project-intro-table {
  width: 100%;
  margin: 1.8rem 0;
  background: #fafbfc;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.project-intro-table td {
  padding: 1.4rem;
}

.icon-cell {
  width: 120px;
  text-align: center;
  background: var(--erasmus-light);
}

/* =====================================================
   PÁGINAS SECUNDÁRIAS – RECUPERAR SCROLLBAR
   ===================================================== */
body.project-page {
  overflow-y: auto !important;     /* força scroll vertical quando necessário */
  height: auto !important;
  min-height: 100vh;
  padding-bottom: 80px;            /* evita que o conteúdo fique tapado pelo footer fixo */
}

/* Garante que o conteúdo não fique por baixo do header fixo */
.project-page .page-wrapper,
.project-page .secondary-content {
  margin-top: 90px;                /* espaço para a navbar fixa */
}

/* =====================================================
   RESPONSIVIDADE – MOBILE FIRST
   ===================================================== */

/* Tablets e ecrãs médios */
@media (max-width: 1024px) {
  .sidebar-wrapper {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    box-shadow: none;
    border-bottom: 1px solid #e0e0e0;
  }
  
  .secondary-content {
    padding: 1.5rem;
  }
}

/* Telemóveis – menu vira stack vertical */
@media (max-width: 768px) {
  .navbar {
    height: 60px;               /* pode reduzir um pouco em mobile */
  }
  
  main.container.main-content {
    height: calc(100dvh - 60px - 70px);
    margin-top: 60px;
  }
  
  /* Se o rodapé também encolher em mobile (opcional) */
  .footer {
    height: 60px;
  }
  
  .nav-flex {
    flex-direction: column;
    padding: 1rem;
  }
  
  .menu {
    flex-direction: column;
    gap: 0.8rem;
    width: 100%;
    text-align: center;
  }
  
  .menu a, .menu span {
    padding: 0.9rem;
    width: 100%;
  }
  
  .submenu {
    position: static;
    box-shadow: none;
    background: var(--erasmus-light);
  }
  
  .submenu a {
    color: var(--erasmus-dark);
  }
  
  .logos {
    left: 50%;
    transform: translateX(-50%);
    top: 4px;
  }
  
  .logos img {
    height: 60px;
  }
  
  .navbarproj .menuproj {
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* Muito pequenos (ex: iPhone SE) */
@media (max-width: 480px) {
  body {
    font-size: clamp(14px, 3.2vw, 16px);
  }
  
  .project-intro-table td {
    padding: 1rem;
    display: block;
  }
  
  .icon-cell {
    width: 100%;
    padding-bottom: 0.5rem;
  }
  
  .secondary-content {
    padding: 1rem 1.2rem;
  }
}

/* =====================================================
   TÍTULOS DAS PÁGINAS SECUNDÁRIAS
   ===================================================== */

/* Container do cabeçalho da página */
.page-header {
  margin: 1.5rem 0 2.5rem;
  text-align: center;
  padding-bottom: 1.5rem;
  position: relative;
}

/* Linha decorativa abaixo do título (opcional mas dá um toque bonito) */
.page-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 4px;
  background: linear-gradient(to right, var(--erasmus-blue), var(--erasmus-yellow));
  border-radius: 2px;
}

/* Título principal (h1) */
.page-title {
  font-size: clamp(1.8rem, 5.5vw, 2.8rem);
  font-weight: 700;
  color: var(--erasmus-dark);
  margin: 0 0 0.6rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Subtítulo / código do projeto */
.page-subtitle {
  font-size: clamp(1rem, 3vw, 1.25rem);
  font-weight: 500;
  color: var(--erasmus-blue);
  margin: 0;
  opacity: 0.95;
}

/* Variante mais pequena (caso uses h2 ou h3 nalgumas páginas) */
.secondary-content h2,
.secondary-content h3 {
  font-size: clamp(1.5rem, 4.2vw, 2.1rem);
  font-weight: 600;
  color: var(--erasmus-dark);
  margin: 2rem 0 1.2rem;
  position: relative;
  padding-left: 0;
}

.secondary-content h2::before,
.secondary-content h3::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: var(--erasmus-yellow);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 237, 0, 0.25);
}

/* Destaque no título quando está na secção de projetos */
.projects h2 {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  color: var(--erasmus-blue);
  text-align: center;
  margin: 1.5rem 0 2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* Efeito hover suave (opcional – fica bonito em desktop) */
.page-title:hover,
.projects h2:hover {
  color: var(--erasmus-blue);
  transition: color 0.3s ease;
}

/* =====================================================
   RESPONSIVIDADE dos títulos
   ===================================================== */

@media (max-width: 768px) {
  .page-header {
    margin: 1.2rem 0 2rem;
    padding-bottom: 1.2rem;
  }

  .page-title {
    font-size: clamp(1.6rem, 6.5vw, 2.2rem);
  }

  .page-subtitle {
    font-size: clamp(0.95rem, 3.8vw, 1.1rem);
  }

  .secondary-content h2,
  .secondary-content h3 {
    font-size: clamp(1.4rem, 5vw, 1.9rem);
  }
}

@media (max-width: 480px) {
  .page-header::after {
    width: 80px;
  }

  .page-title {
    font-size: clamp(1.5rem, 7vw, 2rem);
  }
}

/* =====================================================
   SLIDESHOW – GALERIA NAS PÁGINAS SECUNDÁRIAS
   ===================================================== */

.gallery-section {
  margin: 2.5rem 0 3.5rem;
  padding: 0 1rem;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

.gallery-title {
  text-align: center;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  color: var(--erasmus-blue);
  margin-bottom: 1.8rem;
  font-weight: 600;
  position: relative;
}

.gallery-title::after {
  content: '';
  display: block;
  width: 80px;
  height: 3px;
  background: var(--erasmus-yellow);
  margin: 0.6rem auto 0;
  border-radius: 2px;
}

.slideshow-container {
  position: relative;
  max-width: 65%;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.mySlides {
  display: none;
}

.mySlides img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  aspect-ratio: 16 / 9;          /* proporção recomendada – ajusta se necessário */
}

.text {
  color: white;
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  padding: 12px 20px;
  position: absolute;
  bottom: 0;
  width: 100%;
  text-align: center;
  background: linear-gradient(to top, rgba(0,68,148,0.75), transparent);
  font-weight: 500;
}

.prev, .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: 48px;
  height: 48px;
  margin-top: -24px;
  padding: 12px;
  color: white;
  font-weight: bold;
  font-size: 22px;
  transition: all 0.3s ease;
  border-radius: 50%;
  background: rgba(0, 127, 199, 0.75);
  user-select: none;
}

.next { right: 15px; }
.prev  { left:  15px; }

.prev:hover, .next:hover {
  background: var(--erasmus-yellow);
  color: var(--erasmus-dark);
}

.dots-container {
  text-align: center;
  padding: 1.2rem 0;
}

.dot {
  cursor: pointer;
  height: 12px;
  width: 12px;
  margin: 0 8px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.35s ease;
}

.active, .dot:hover {
  background-color: var(--erasmus-blue);
}

/* Responsividade */
@media (max-width: 768px) {
  .prev, .next {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }
  .text {
    font-size: 1.05rem;
    padding: 10px 14px;
  }
}

/* =====================================================
   VÍDEOS LOCAIS RESPONSIVOS
   ===================================================== */

.videos-section {
  margin: 1.5rem 0 2rem;
  padding: 0 1rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  /* Altura máxima total da secção = espaço livre entre navbar e footer */
  max-height: calc(100vh - 140px);     /* 100vh - 70px navbar - 70px footer */
  
  display: flex;
  flex-direction: column;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem 1.5rem;
}

.video-wrapper {
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

video {
  width: 100vh*70%;
  height: auto;
  display: block;
}

/* Legenda abaixo de cada vídeo */
.video-caption {
  text-align: center;
  padding: 0.8rem;
  margin: 0;
  background: var(--erasmus-light);
  color: var(--erasmus-dark);
  font-size: 0.95rem;
  font-weight: 500;
}

/* Título da secção (igual ao do slideshow) */
.videos-section .gallery-title {
  text-align: center;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  color: var(--erasmus-blue);
  margin-bottom: 1.8rem;
  font-weight: 600;
}

.videos-section .gallery-title::after {
  content: '';
  display: block;
  width: 80px;
  height: 3px;
  background: var(--erasmus-yellow);
  margin: 0.7rem auto 0;
  border-radius: 2px;
}

/* Mobile */
@media (max-width: 768px) {
  .video-grid {
    gap: 1.6rem;
  }
  .videos-section {
    margin: 2rem 0;
  }
}