/* ═══════════════════════════════════════════
   DIAGNÓSTICO OTLI — Página propia
   diagnostico.css · Layout two-column
   ═══════════════════════════════════════════ */

/* ─── Navbar: siempre sólido en esta página ─── */
/* El navbar global arranca transparente y añade fondo solo al hacer scroll (clase .scrolled).
   En la página de diagnóstico necesitamos que sea siempre opaco para que nada lo atraviese. */
#navbar {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 20px rgba(0,0,0,0.06);
}

/* ─── Layout de página ─── */
.diag-page {
  min-height: 100vh;
  padding-top: 70px; /* logo 48px + padding navbar ≈ 61px + buffer */
  padding-bottom: 3rem;
  /* Gradiente 50/50: columna jade izquierda siempre sólida, evita fondo roto al hacer scroll */
  background: linear-gradient(to right, var(--jade) 50%, var(--bg-alt) 50%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  align-items: start;
}

/* ─── Columna izquierda ─── */
.diag-aside {
  background: var(--jade);
  min-height: calc(100vh - 70px);
  display: flex;
  align-items: center;
  padding: 4rem 3rem;
  position: sticky;
  top: 70px;
  z-index: 1; /* por debajo del navbar (z-index: 1000) */
}

.diag-aside-inner {
  max-width: 420px;
}

.diag-aside .section-tag {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.2);
}

.diag-aside-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  margin: 1rem 0 1.25rem;
}

.diag-aside-body {
  font-size: 1rem;
  color: rgba(255,255,255,0.85);
  line-height: 1.7;
  margin-bottom: 2rem;
}

.diag-aside-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.diag-aside-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: rgba(255,255,255,0.9);
  font-size: 0.95rem;
  font-weight: 500;
}

.diag-check {
  width: 22px;
  height: 22px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.diag-aside-note {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 1.25rem;
  line-height: 1.5;
}

/* ─── Columna derecha ─── */
.diag-main {
  padding: 3rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ─── Cards ─── */
.diag-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-md);
}

.diag-hidden { display: none !important; }

/* ─── Formulario registro ─── */
.diag-form-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.diag-form-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.diag-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.diag-form-group label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
}

.diag-input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.diag-input:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 3px var(--jade-glow);
}

.diag-input--error {
  border-color: #dc3545;
  box-shadow: 0 0 0 3px rgba(220,53,69,0.1);
}

.diag-field-error {
  font-size: 0.77rem;
  color: #dc3545;
  display: none;
}

.diag-field-error.visible { display: block; }

.form-honeypot { display: none !important; }

.diag-form-error {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: 0.83rem;
  color: #664d03;
  margin-bottom: 1rem;
  display: none;
}

.diag-form-error.visible { display: block; }

/* ─── Chat ─── */
#diag-chat {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.chat-header {
  background: var(--jade);
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-header-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  padding: 3px;
  object-fit: contain;
  flex-shrink: 0;
}

.chat-header-info { flex: 1; }

.chat-header-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.chat-header-status {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.75);
}

.chat-progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-progress-label {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
}

.chat-progress-track {
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 9999px;
  overflow: hidden;
}

.chat-progress-fill {
  height: 100%;
  background: rgba(255,255,255,0.9);
  border-radius: 9999px;
  width: 0%;
  transition: width 0.5s ease;
}

.chat-messages {
  min-height: 340px;
  max-height: 420px;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #F9FAFB;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9999px; }

.bubble-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.bubble-row--agent { justify-content: flex-start; }
.bubble-row--user  { justify-content: flex-end; }

.bubble-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--jade-glow);
  padding: 2px;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bubble-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
}

.bubble {
  max-width: 76%;
  padding: 0.6rem 0.9rem;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
}

.bubble--agent {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.bubble--user {
  background: var(--jade);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing */
.bubble--typing {
  background: #fff;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.65rem 0.85rem;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--jade-light);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

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

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1;   }
}

/* Input */
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 0.75rem 0.9rem;
  background: var(--bg);
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
}

#chat-textarea {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  resize: none;
  max-height: 100px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.2s;
}

#chat-textarea:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 3px var(--jade-glow);
}

.char-count {
  font-size: 0.68rem;
  color: var(--text-light);
  white-space: nowrap;
  align-self: flex-end;
}

.char-count--limit { color: #dc3545; }

#chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--jade);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

#chat-send-btn:hover    { background: var(--jade-light); transform: scale(1.05); }
#chat-send-btn:disabled { background: var(--border); cursor: not-allowed; transform: none; }
#chat-send-btn svg      { width: 16px; height: 16px; }

/* ─── Cierre ─── */
#diag-close {
  text-align: center;
}

/* Ícono check animado */
.diag-check-circle {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.diag-check-svg {
  width: 64px;
  height: 64px;
}

.diag-check-circle-bg {
  stroke: var(--jade);
  stroke-width: 3;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: circle-draw 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.diag-check-mark {
  stroke: var(--jade);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: check-draw 0.35s 0.55s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

@keyframes circle-draw {
  to { stroke-dashoffset: 0; }
}
@keyframes check-draw {
  to { stroke-dashoffset: 0; }
}

.diag-close-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.diag-close-body {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.65;
  max-width: 400px;
  margin: 0 auto 1.75rem;
}

/* Mensaje post-envío */
.diag-sent-msg {
  background: #f0faf7;
  border: 1px solid var(--jade-border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  text-align: left;
  animation: fadeInUp 0.3s ease both;
}

.diag-sent-msg strong { color: var(--jade); }

.diag-close-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

/* Botón principal jade */
.btn-enviar-diag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--jade);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.8rem 2rem;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: var(--shadow-jade);
}

.btn-enviar-diag:hover:not(:disabled) {
  background: var(--jade-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(34,184,150,0.35);
}

.btn-enviar-diag:disabled {
  background: #a8d5c8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Botón volver outline */
.btn-volver {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.55rem 1.4rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-volver:hover {
  border-color: var(--jade);
  color: var(--jade);
}

/* ─── Footer ─── */
.diag-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 1.25rem 2rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.diag-footer a {
  color: var(--jade);
  text-decoration: none;
}

.diag-footer a:hover { text-decoration: underline; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .diag-page {
    grid-template-columns: 1fr;
    background: var(--bg-alt); /* en móvil es una sola columna, sin gradiente */
  }

  .diag-aside {
    min-height: auto;
    position: static;
    padding: 3rem 1.5rem 2.5rem;
  }

  .diag-aside-inner { max-width: 100%; }

  .diag-aside-title { font-size: 1.6rem; }

  .diag-main { padding: 2rem 1.25rem; }
}

@media (max-width: 480px) {
  .diag-aside { padding: 2.5rem 1.25rem 2rem; }
  .diag-card  { padding: 1.5rem 1.1rem; }
  .chat-messages { min-height: 260px; max-height: 320px; }
  .chat-progress-track { width: 55px; }
}
