/* ================================================
   Sistema Socrático — Diseño para profundidad,
   no para retención de atención.
   ================================================ */

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

:root {
  --bg: #0e0e0f;
  --surface: #161618;
  --border: #2a2a2e;
  --text-primary: #e8e8ea;
  --text-secondary: #888890;
  --text-dim: #505058;
  --accent: #c8c8d0;
  --input-bg: #1c1c1f;
  --code-bg: #1a1a1d;
  --font: 'Georgia', 'Times New Roman', serif;
  --font-mono: 'Courier New', Courier, monospace;
  --radius: 6px;
  --max-width: 680px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ── Pantallas ── */
.screen {
  display: none;
  height: 100vh;
  width: 100%;
}

.screen.active {
  display: flex;
}

/* ── Pantalla de entrada ── */
#screen-entry {
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.entry-content {
  max-width: 520px;
  text-align: center;
}

.entry-question {
  font-size: 1.15rem;
  color: var(--text-primary);
  line-height: 1.8;
  margin-bottom: 2.5rem;
  font-weight: 400;
}

.entry-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn-primary {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.6rem 2rem;
  font-family: var(--font);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.2s, color 0.2s;
}

.btn-primary:hover {
  background: var(--accent);
  color: var(--bg);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.6rem 2rem;
  font-family: var(--font);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: var(--radius);
  transition: border-color 0.2s, color 0.2s;
}

.btn-secondary:hover {
  border-color: var(--text-secondary);
  color: var(--text-secondary);
}

/* ── Pantalla de conversación ── */
#screen-conversation {
  flex-direction: column;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
  width: 4px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.message {
  max-width: var(--max-width);
  width: 100%;
}

/* Mensajes del sistema alineados a la izquierda */
.message.system {
  align-self: flex-start;
  margin-left: auto;
  margin-right: auto;
}

.message.system .bubble {
  background: transparent;
  color: var(--text-primary);
  border-left: 2px solid var(--border);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  line-height: 1.7;
}

/* Mensajes del usuario: mismo peso visual */
.message.user {
  align-self: flex-end;
  margin-left: auto;
  margin-right: auto;
}

.message.user .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 1rem;
  line-height: 1.7;
}

/* Indicador de escritura */
.typing-indicator .bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.75rem 1rem;
  border-left: 2px solid var(--border);
  background: transparent;
}

.typing-indicator .dot {
  width: 5px;
  height: 5px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: pulse 1.2s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.2); }
}

/* ── Área de input ── */
.input-area {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 1rem 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  max-width: calc(var(--max-width) + 2rem);
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

#user-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

#user-input:focus {
  border-color: var(--text-dim);
}

#user-input::placeholder {
  color: var(--text-dim);
}

.btn-send {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Pantalla de código ── */
#screen-code {
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.code-content {
  max-width: 540px;
  width: 100%;
}

.code-intro {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 2rem;
}

.code-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

#access-code-display {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  word-break: break-all;
}

.btn-copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.4rem;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.btn-copy:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn-copy.copied {
  color: #7a9f7a;
  border-color: #7a9f7a;
}

.code-warning {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 2rem;
  font-family: sans-serif;
}

.code-instructions {
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-family: sans-serif;
  line-height: 1.7;
}

.code-instructions p {
  margin-bottom: 0.5rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.code-instructions ol {
  padding-left: 1.25rem;
}

.code-instructions li {
  margin-bottom: 0.4rem;
}

.code-instructions code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  color: var(--accent);
}

.code-label {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  font-family: sans-serif;
}

.code-instructions {
  list-style: none;
  padding: 0;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.85rem;
  font-family: sans-serif;
  line-height: 1.9;
  margin-bottom: 1.75rem;
}

.code-link {
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
}

.code-link:hover {
  color: rgba(255, 255, 255, 0.85);
}

.code-footer {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.3);
  font-family: sans-serif;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.code-already {
  color: rgba(255, 255, 255, 0.3);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .entry-question {
    font-size: 1rem;
  }

  .messages {
    padding: 1.25rem 0.75rem;
  }

  .input-area {
    padding: 0.75rem 0.75rem 1.25rem;
  }
}
