:root {
  /* Paleta de Cores Modernas (Light Mode Padrão) */
  --primary: #4f46e5;
  --secondary: #1e293b;
  --accent: #818cf8;
  --bg-light: #f8fafc;
  --white: #ffffff;
  --text-main: #334155;
  --text-light: #64748b;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --header-bg: rgba(255, 255, 255, 0.9);
  --btn-text: #ffffff;
}

/* Variáveis para o Dark Mode */
body.dark-mode {
  --bg-light: #0f172a;      /* Fundo escuro (Slate 900) */
  --white: #1e293b;         /* Cards escuros (Slate 800) */
  --text-main: #e2e8f0;     /* Texto claro */
  --text-light: #cbd5e1;    /* Texto secundário mais claro para melhor leitura */
  --secondary: #f8fafc;     /* Títulos claros */
  --primary: #818cf8;       /* Indigo 400: Mais claro para contraste em fundo escuro */
  --accent: #6366f1;        /* Indigo 500 */
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --header-bg: rgba(15, 23, 42, 0.9);
  --btn-text: #0f172a;      /* Texto escuro no botão claro do modo dark */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Poppins', sans-serif;
  background-color: var(--bg-light);
  color: var(--text-main);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Barra de Rolagem Personalizada */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
  background: var(--text-light);
  border-radius: 5px;
}

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

.container {
  max-width: 1100px;
  margin: auto;
  padding: 0 20px;
}

/* Header Estilizado com Efeito Glass */
header {
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  padding: 1rem 0;
  transition: background-color 0.3s ease;
}

.header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

/* Botão Menu Mobile */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--primary);
  cursor: pointer;
}

nav ul {
  display: flex;
  list-style: none;
  gap: 2rem;
  align-items: center;
}

nav ul li a {
  color: var(--secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

nav ul li a:hover {
  color: var(--primary);
}

/* Botão de Tema */
.theme-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.5rem;
  border-radius: 50%;
  transition: transform 0.3s ease, background-color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-btn:hover {
  transform: scale(1.1);
  background-color: rgba(129, 140, 248, 0.1);
}

/* Seções */
section {
  padding: 100px 0;
}

h2 {
  font-size: 2.5rem;
  margin-bottom: 40px;
  text-align: center;
  color: var(--secondary);
}

/* Hero / Sobre */
#sobre {
  text-align: center;
  padding: 100px 20px;
}

#sobre p {
  font-size: 1.25rem;
  color: var(--text-light);
  max-width: 700px;
  margin: 0 auto;
}

/* Seção de Habilidades */
.skills-grid {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.skill-card {
  background: var(--white);
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  min-width: 120px;
  transition: transform 0.3s ease;
  position: relative; /* Necessário para z-index funcionar bem */
}

.skill-card:hover {
  transform: translateY(-5px);
  z-index: 10; /* Garante que o tooltip fique por cima dos outros cards */
}

.skill-icon.html { color: #E34F26; }
.skill-icon.css { color: #1572B6; }
.skill-icon.js { color: #F7DF1E; }
.skill-icon.react { color: #61DAFB; }
.skill-icon.tailwind { color: #38B2AC; }

.skill-bar {
  width: 100%;
  height: 6px;
  background-color: var(--bg-light); /* Cria um efeito de profundidade */
  border-radius: 3px;
  margin-top: 0.5rem;
  overflow: visible; /* Permite que o tooltip apareça fora da barra */
  position: relative;
}

.skill-progress {
  height: 100%;
  border-radius: 3px;
  background-color: var(--primary); /* Cor padrão */
  transition: width 1s ease-in-out;
  position: relative;
}

/* Tooltip (Texto) */
.skill-progress::after {
  content: attr(data-width);
  position: absolute;
  right: 0;
  top: -30px;
  background: var(--secondary);
  color: var(--bg-light);
  padding: 2px 6px;
  font-size: 0.75rem;
  border-radius: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(50%) translateY(5px); /* Centraliza na ponta da barra */
  transition: all 0.3s ease;
  white-space: nowrap;
}

/* Tooltip (Setinha) */
.skill-progress::before {
  content: '';
  position: absolute;
  right: 0;
  top: -10px;
  border: 5px solid transparent;
  border-top-color: var(--secondary);
  opacity: 0;
  visibility: hidden;
  transform: translateX(50%) translateY(5px);
  transition: all 0.3s ease;
}

/* Mostrar Tooltip ao passar o mouse na barra inteira */
.skill-bar:hover .skill-progress::after,
.skill-bar:hover .skill-progress::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(50%) translateY(0);
}

.skill-progress.html { background-color: #E34F26; }
.skill-progress.css { background-color: #1572B6; }
.skill-progress.js { background-color: #F7DF1E; }
.skill-progress.react { background-color: #61DAFB; }
.skill-progress.tailwind { background-color: #38B2AC; }

.skill-card i {
  font-size: 2.5rem;
}

/* Grid de Projetos */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

/* Ajuste específico para dar mais ar ao final da lista de projetos */
#projetos {
  padding-bottom: 120px;
  margin-top: 2rem;
}

/* Filtros de Projetos */
.filter-container {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 3rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 0.5rem 1.5rem;
  border-radius: 2rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.3s ease;
}

.filter-btn.active, .filter-btn:hover {
  background: var(--primary);
  color: var(--bg-light);
}

.projeto {
  background: var(--white);
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
  border: 1px solid rgba(226, 232, 240, 0.1); /* Borda sutil para dark mode */
}

.projeto:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.projeto h3 {
  margin-bottom: 1rem;
  color: var(--secondary);
}

.projeto p {
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

.projeto img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(0,0,0,0.05);
  cursor: pointer; /* Indica que é clicável */
}

/* Ícones de Tecnologia */
.tech-stack {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

.tech-stack i {
  color: var(--text-light);
  transition: color 0.3s ease, transform 0.3s ease;
}

.tech-stack i:hover {
  color: var(--primary);
  transform: translateY(-3px);
}

.btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--btn-text);
  padding: 0.6rem 1.5rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.3s ease;
}

.btn:hover {
  opacity: 0.9;
}

.btn-full {
  width: 100%;
  border: none;
  cursor: pointer;
}

/* Contato e Footer */
#contato {
  background: var(--white);
  text-align: center;
  border-top: 1px solid rgba(226, 232, 240, 0.1);
  transition: background-color 0.3s ease;
}

.contact-intro {
  text-align: center;
  margin-bottom: 2rem;
}

.social-links {
  margin-bottom: 1rem;
}

.social-links a {
  color: var(--bg-light);
  font-size: 1.5rem;
  margin: 0 10px;
  transition: color 0.3s ease;
}

.social-links a:hover {
  color: var(--accent);
}

footer {
  text-align: center;
  padding: 2rem;
  background: var(--secondary);
  color: var(--bg-light); /* Texto do footer adaptável */
  font-size: 0.9rem;
  transition: background-color 0.3s ease;
}

/* Animações de Scroll */
.hidden {
  opacity: 0;
  transform: translateY(30px); /* Começa um pouco mais para baixo */
  transition: all 0.8s ease-out;
}

.show {
  opacity: 1;
  transform: translateY(0);
}

/* Cursor do efeito de digitação */
.cursor {
  display: inline-block;
  width: 3px;
  background-color: var(--primary);
  animation: blink 1s infinite;
  margin-left: 4px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Botão Voltar ao Topo */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--primary);
  color: white;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 999;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--accent);
  transform: translateY(-5px);
}

/* Modal de Imagem (Lightbox) */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.open {
  display: flex;
  opacity: 1;
}

.modal-content {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 5px;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  transform: scale(0.8);
  transition: transform 0.3s ease;
}

.modal.open .modal-content {
  transform: scale(1);
}

.close-modal {
  position: absolute;
  top: 20px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.3s;
  z-index: 2001;
  background: none;
  border: none;
}

.close-modal:hover,
.close-modal:focus {
  color: var(--primary);
  text-decoration: none;
}

/* Formulário de Contato */
.contact-form {
  max-width: 600px;
  margin: 2rem auto 0;
  text-align: left;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-main);
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid rgba(226, 232, 240, 0.5);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  background-color: var(--bg-light);
  color: var(--text-main);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.error-message {
  color: #ef4444; /* Vermelho para erro */
  font-size: 0.85rem;
  display: block;
  opacity: 0;
  transform: translateY(-10px);
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

.error-message.visible {
  opacity: 1;
  transform: translateY(0);
  max-height: 50px; /* Altura suficiente para a mensagem */
  margin-top: 0.25rem;
}

/* Responsividade (Mobile) */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: block;
  }

  .nav-menu {
    position: fixed;
    top: 70px; /* Altura do header */
    left: -100%;
    width: 100%;
    height: calc(100vh - 70px);
    background: var(--bg-light);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: left 0.3s ease;
    border-top: 1px solid rgba(0,0,0,0.05);
  }

  .nav-menu.active {
    left: 0;
  }

  nav ul {
    flex-direction: column;
    gap: 3rem;
  }

  nav ul li a {
    font-size: 1.5rem;
  }

  /* Ajustes de Espaçamento para Mobile */
  section {
    padding: 60px 0;
  }

  #projetos {
    padding-bottom: 80px;
  }

  h2 {
    font-size: 2rem;
    margin-bottom: 30px;
  }

  .projects-grid,
  .skills-grid {
    gap: 1.5rem;
  }

  #sobre {
    padding: 60px 20px;
  }
}