/* 1. Reset and Base */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #111;
  color: #eee;
  margin: 0;
  /* dvh ayuda a que el teclado móvil no rompa el diseño */
  height: 100vh;
  height: 100dvh; 
  display: flex;
  flex-direction: column;
  overflow: hidden; 
}

/* 2. Login View (Para tu pantalla de acceso) */
body.login {
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #222 0%, #111 100%);
}

.card {
  background: #1e1e1e;
  padding: 2.5rem;
  border-radius: 16px;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.7);
  border: 1px solid #333;
  text-align: center;
}

/* 3. Inputs Universales */
input, textarea {
  display: block;
  width: 100%;
  background: #2b2b2b;
  color: white;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 14px;
  font-size: 16px; 
  margin-bottom: 1rem;
  transition: border-color 0.2s;
  font-family: inherit;
}

input:focus, textarea:focus {
  border-color: #007bff;
  outline: none;
}

/* 4. Interfaz de Chat */
#chat {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  background: #111;
  /* Margen inferior para que los mensajes no queden tapados por la barra fija */
  padding-bottom: 130px; 
}

#chat div {
  max-width: 85%;
  line-height: 1.4;
  word-wrap: break-word;
}

/* 5. Área de Entrada (FIX: Elevada y Fija) */
.input-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  background: #1e1e1e;
  border-top: 1px solid #333;
  align-items: flex-end;
  gap: 10px;
  padding: 15px;
  /* FIX: 40px + el área segura suben el input para que no esté "muy abajo" */
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 15px)); 
  box-shadow: 0 -8px 20px rgba(0,0,0,0.6);
}

textarea {
  margin-bottom: 0; 
  resize: none;
  min-height: 48px;
  max-height: 150px;
}

/* 6. Botones */
button {
  padding: 12px 20px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  min-height: 48px;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

button:active {
  transform: scale(0.96);
}

/* 7. Ajustes para Pantallas Pequeñas */
@media (max-width: 480px) {
  #chat {
    padding: 1rem;
    padding-bottom: 160px;
  }
  
  .input-area {
    padding: 12px;
    /* Subida extra para smartphones Android/iOS con barras de gestos */
    padding-bottom: calc(45px + env(safe-area-inset-bottom, 20px));
  }
}
