* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: manipulation; /* Melhora interação em mobile */
}

body {
  font-family: 'Segoe UI', sans-serif;
  background: #f9fafb;
  color: #1f2937;
  line-height: 1.6;
}

header {
  background: linear-gradient(90deg, #4f46e5, #3b82f6);
  color: white;
  padding: 1.5rem 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  font-family: 'Courier New', Courier, monospace;
  letter-spacing: 5px; /* Ajuste o valor conforme necessário */
}

nav {
  display: flex;
  gap: 0.75rem;
}

nav button {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

nav button.active {
  background: white;
  color: #3b82f6;
}

main {
  padding: 1.5rem;
  max-width: 100vw;
}

#funilWrapper {
  position: relative;
  width: 100%;
  height: 70vh;
  max-height: 700px;
  overflow: hidden;
  margin-bottom: 1rem;
}

#funilArea {
  position: relative;
  border: 2px dashed #e5e7eb;
  border-radius: 0.75rem;
  width: 100%;
  height: 100%;
  background: white;
  overflow: hidden;
}

#linhasConexao {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ---- BOLHAS ---- */
.bolha {
  position: absolute;
  background: white;
  border: 2px solid #3b82f6;
  border-radius: 0.75rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  min-width: 200px;
  min-height: 150px;
  resize: both;
  overflow: hidden;
  z-index: 2;
  display: flex;
  flex-direction: column;
  touch-action: none; /* Permite arrastar no mobile */
}

.drag-handle {
  width: 100%;
  padding: 2px;
  cursor: grab;
  text-align: center;
  position: relative;
  background: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease-in-out;
  touch-action: none; /* Melhora arraste no mobile */
}

.drag-handle::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 6px;
  background: #3b82f6;
  border-radius: 6px 6px 0 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.drag-handle:hover::before {
  opacity: 1;
}

.drag-handle:active {
  cursor: grabbing;
  background-color: #ffd000;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transform: scale(0.98);
}

.conexao-handles {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 0.5rem;
}

.conexao-handle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: transform 0.2s;
  touch-action: none; /* Permite interação no mobile */
}

.conexao-handle:hover {
  transform: scale(1.1);
}

.conexao-handle.verde {
  background: #10b981;
}

.conexao-handle.vermelho {
  background: #ef4444;
}

.bolha textarea {
  width: 100%;
  height: 100%;
  min-height: 100px;
  padding: 0.4rem;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 1rem;
  text-align: center;
  line-height: 1.5;
  color: #111827;
  flex-grow: 1;
}

.btn-excluir {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: #6b7280;
  font-size: 1.1rem;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-excluir:hover {
  color: #ef4444;
}

#addStep {
  display: block;
  margin: 1.5rem auto 0;
  background: #4f46e5;
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.3s;
}

#addStep:hover {
  background: #4338ca;
}

.theme-control {
  display: flex;
  gap: 0.5rem;
}

.theme-control button {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 35px;
  height: 35px;
  border-radius: 45%;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1rem;
}

/* ===== MODO ESCURO ===== */
body.dark-mode {
  background: #111827;
  color: #f3f4f6;
}
body.dark-mode #funilArea {
  background: #1f2937;
  border-color: #4b5563;
}
body.dark-mode .bolha {
  background: #374151;
  border-color: #4b5563;
  color: white;
}
body.dark-mode textarea {
  color: white !important;
}
body.dark-mode .drag-handle {
  background: #4b5563;
  border-color: #6b7280;
}
body.dark-mode .conexao-handle {
  border-color: #374151;
}

.footer {
  text-align: center;
  padding: 1rem;
  background-color: #333;
  font-size: 1em;
  color: #aaa;
  margin-top: 20px;
}



/* Botão de Conexão para Mobile */
.btn-conectar {
  display: none;
  position: absolute;
  top: 5px;
  right: 5px;
  background: #4f46e5;
  color: white;
  border: none;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 10px;
  cursor: pointer;
  z-index: 10;
}



/* Ajustes para mobile */
@media (max-width: 990px) {
  .conexao-handles {
    display: none !important;
  }
  
  .bolha:hover .btn-conectar {
    display: block;
  }
  
  .btn-conectar {
    display: block;
  }
}
/* Mensagem de instruções */
.instrucao-conexao {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0,0,0,0.2);
  z-index: 1000;
  max-width: 300px;
  text-align: center;
  display: none;
}
.instrucao-conexao button {
  margin-top: 15px;
  background: #4f46e5;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 4px;
  cursor: pointer;
}



/* ---- RESPONSIVO ---- */
@media (max-width: 768px) {
  header {
    padding: 1rem;
    gap: 0.75rem;
  }

  .bolha {
    min-width: 180px;
    min-height: 130px;
    resize: none; /* Remove redimensionamento em mobile */
  }

  main {
    padding: .5rem;
    max-width: 100vw;
  }
}

@media (max-width: 480px) {
  header {
    flex-direction: column;
  }

  nav {
    width: 100%;
    justify-content: center;
  }

  .bolha {
    min-width: 160px;
    min-height: 120px;
  }

  main {
    padding: .5rem;
    max-width: 100vw;
  }



  .footer {
    font-size: 0.7em;
  }
}