/* ─── ask.css — Asistente IA ───────────────────────────────────────────
   Usa las variables de theme.css. Solo agrega lo necesario para esta vista.
   ────────────────────────────────────────────────────────────────────────── */

/* ── Reset body para esta página (sin sidebar) ─── */
.ask-page {
  background: var(--bg-sidebar);
  min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────── */
.ask-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.ask-topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

/* ── Layout principal ───────────────────────────── */
/* .tool-nav es fixed y esta página no usa .layout: el margin-top le deja su
   alto, si no el badge del hero queda pegado bajo la barra. */
.ask-main {
  max-width: 680px;
  margin: var(--header-h) auto 0;
  padding: 48px 20px 80px;
}

.calculadora-page .ask-main {
  max-width: 900px;
  margin: var(--header-h) auto 0;
  padding: 48px 20px 80px;
}

/* ── Hero ───────────────────────────────────────── */
.ask-hero {
  text-align: center;
  margin-bottom: 32px;
}

.ask-assist-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  border-radius: 99px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  font-size: 12px;
  font-weight: 600;
  color: #16a34a;
  letter-spacing: 0.02em;
  margin-bottom: 20px;
}

.ask-assist-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse-dot 2s ease-in-out infinite;
}

.ask-assist-badge.is-unconfigured {
  color: #a16207;
  background: #fffbeb;
  border-color: #fde68a;
}

.ask-assist-badge.is-unconfigured .ask-assist-dot {
  background: #d97706;
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

.ask-hero-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.ask-hero-sub {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0;
}

/* ── Caja principal ────────────────────────────── */
.ask-box-wrap {
  margin-bottom: 28px;
}

.ask-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* ── Input area ─────────────────────────────────── */
.ask-input-area {
  padding: 16px;
}

.ask-textarea {
  width: 100%;
  min-height: 100px;
  max-height: 200px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg-sidebar);
  font-family: var(--font), sans-serif;
  font-size: 15px;
  color: var(--text);
  line-height: 1.55;
  resize: none;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  box-sizing: border-box;
  display: block;
}

.ask-textarea::placeholder {
  color: var(--text-3);
}

.ask-textarea:focus {
  border-color: var(--accent);
  background: var(--bg);
}

.ask-input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.ask-char-count {
  font-size: 12px;
  color: var(--text-3);
}

.ask-send-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font), sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.ask-send-btn:hover:not(:disabled) {
  background: #e07b35;
}

.ask-send-btn:active:not(:disabled) {
  transform: scale(0.97);
}

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

.ask-send-btn i {
  font-size: 16px;
}

/* ── Loading ────────────────────────────────────── */
.ask-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  gap: 14px;
}

.ask-loading-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ask-loading-dots {
  display: flex;
  gap: 6px;
}

.ask-loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.3;
  animation: bounce-dot 1.2s ease-in-out infinite;
}

.ask-loading-dots span:nth-child(1) { animation-delay: 0s; }
.ask-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.ask-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce-dot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40%            { opacity: 1;   transform: translateY(-5px); }
}

.ask-loading-text {
  font-size: 14px;
  color: var(--text-3);
  margin: 0;
}

/* ── Answer area ────────────────────────────────── */
.ask-answer-area {
  padding: 24px;
}

.ask-answer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.ask-answer-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ask-answer-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ask-answer-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.ask-answer-label {
  font-size: 12px;
  color: var(--text-3);
}

.ask-question-echo {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 16px;
  line-height: 1.5;
}

.ask-question-echo::before {
  content: '"';
  color: var(--accent);
  font-weight: 700;
}

.ask-question-echo::after {
  content: '"';
  color: var(--accent);
  font-weight: 700;
}

.ask-answer-body {
  font-size: 15px;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 24px;
}

.ask-answer-body p {
  margin: 0 0 12px;
}

.ask-answer-body p:last-child {
  margin-bottom: 0;
}

.ask-answer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.ask-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-family: var(--font), sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ask-new-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.ask-new-btn i {
  font-size: 15px;
}

.ask-answer-docs-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  transition: gap 0.15s;
}

.ask-answer-docs-link:hover {
  gap: 8px;
}

/* ── Error area ─────────────────────────────────── */
.ask-error-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  gap: 12px;
  text-align: center;
}

.ask-error-icon {
  font-size: 36px;
  color: #ef4444;
}

.ask-error-msg {
  font-size: 14px;
  color: var(--text-2);
  margin: 0;
  max-width: 320px;
}

/* ── Sugerencias ────────────────────────────────── */
.ask-suggestions {
  margin-bottom: 28px;
}

.ask-suggestions-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 12px;
}

.ask-suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

.ask-suggestion-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font), sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ask-suggestion-chip:hover {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}

.ask-suggestion-chip i {
  font-size: 15px;
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0.7;
}

.ask-suggestion-chip:hover i {
  opacity: 1;
}

/* ── Disclaimer ─────────────────────────────────── */
.ask-disclaimer {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.6;
  margin: 0;
}

.ask-disclaimer a {
  color: var(--accent);
  text-decoration: none;
}

.ask-disclaimer a:hover {
  text-decoration: underline;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  .ask-main {
    padding: 32px 16px 60px;
  }

  .ask-hero-title {
    font-size: 26px;
  }

  .ask-hero-sub {
    font-size: 14px;
  }

  .ask-topbar {
    padding: 0 16px;
  }

.ask-suggestions-grid {
    grid-template-columns: 1fr 1fr;
  }

  .ask-answer-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 400px) {
  .ask-suggestions-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Fix: hidden attribute debe ganar sobre cualquier display ── */
[hidden] { display: none !important; }

/* ── Rich text — contenido Markdown renderizado ────────────────────────────── */
.ask-answer-body h1,
.ask-answer-body h2,
.ask-answer-body h3 {
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 8px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.ask-answer-body h1 { font-size: 18px; }
.ask-answer-body h2 { font-size: 16px; }
.ask-answer-body h3 { font-size: 14px; }

.ask-answer-body h2:first-child,
.ask-answer-body h3:first-child {
  margin-top: 0;
}

.ask-answer-body p {
  margin: 0 0 12px;
  line-height: 1.7;
}

.ask-answer-body p:last-child { margin-bottom: 0; }

.ask-answer-body strong {
  font-weight: 600;
  color: var(--text);
}

.ask-answer-body em {
  font-style: italic;
  color: var(--text-2);
}

.ask-answer-body ul,
.ask-answer-body ol {
  margin: 0 0 12px;
  padding-left: 20px;
}

.ask-answer-body li {
  margin-bottom: 5px;
  line-height: 1.6;
}

.ask-answer-body li:last-child { margin-bottom: 0; }

/* Blockquote — para tips y aclaraciones */
.ask-answer-body blockquote {
  margin: 14px 0;
  padding: 10px 14px;
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
}

.ask-answer-body blockquote p { margin: 0; }

/* Tablas */
.ask-answer-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13.5px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.ask-answer-body thead tr {
  background: var(--bg-sidebar);
}

.ask-answer-body th {
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-2);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.ask-answer-body td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}

.ask-answer-body tbody tr:last-child td {
  border-bottom: none;
}

.ask-answer-body tbody tr:hover td {
  background: var(--bg-sidebar);
}

/* Código inline */
.ask-answer-body code {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--accent);
}

/* Links */
.ask-answer-body a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.ask-answer-body a:hover {
  text-decoration: underline;
}

/* Separador */
.ask-answer-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── Mejoras visuales answer area ──────────────────────────────────────────── */

/* Más aire en la caja de respuesta */
.ask-answer-area {
  padding: 28px 28px 24px !important;
}

/* Separador visual entre header y contenido */
.ask-answer-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 20px !important;
}

/* Avatar más llamativo */
.ask-answer-avatar {
  width: 40px !important;
  height: 40px !important;
  font-size: 17px !important;
  box-shadow: 0 2px 8px rgba(245, 146, 74, 0.35);
}

/* Question echo más sutil */
.ask-question-echo {
  font-size: 18px !important;
  color: var(--text-3) !important;
  background: transparent !important;
  border: none !important;
  border-left: 2px solid var(--border) !important;
  border-radius: 0 !important;
  padding: 4px 10px !important;
  margin-bottom: 20px !important;
}

/* Body con más espacio */
.ask-answer-body {
  font-size: 14.5px !important;
  line-height: 1.75 !important;
  color: var(--text) !important;
}

/* Listas con bullet personalizado */
.ask-answer-body ul {
  padding-left: 0 !important;
  list-style: none !important;
}

.ask-answer-body ul li {
  padding-left: 18px;
  position: relative;
  margin-bottom: 7px !important;
}

.ask-answer-body ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
}

/* Listas numeradas con estilo */
.ask-answer-body ol {
  padding-left: 0 !important;
  list-style: none !important;
  counter-reset: assist-counter;
}

.ask-answer-body ol li {
  counter-increment: assist-counter;
  padding-left: 28px;
  position: relative;
  margin-bottom: 8px !important;
}

.ask-answer-body ol li::before {
  content: counter(assist-counter);
  position: absolute;
  left: 0;
  top: 1px;
  width: 19px;
  height: 19px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* H2 con línea decorativa */
.ask-answer-body h2 {
  font-size: 13.5px !important;
  font-weight: 700 !important;
  color: var(--text-2) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  margin: 22px 0 10px !important;
}

.ask-answer-body h2:first-child { margin-top: 0 !important; }

/* Strong con color accent sutil */
.ask-answer-body strong {
  color: var(--text) !important;
  font-weight: 600 !important;
}

/* Blockquote más estiloso */
.ask-answer-body blockquote {
  background: var(--accent-bg) !important;
  border-left: 3px solid var(--accent) !important;
  border-radius: 0 8px 8px 0 !important;
  padding: 12px 16px !important;
  margin: 16px 0 !important;
}

/* Footer con más aire */
.ask-answer-footer {
  margin-top: 8px;
  padding-top: 20px !important;
}

.ask-loading-tip-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  margin-top: 2px;
}

.ask-loading-tip {
  text-align: center;  /* ← esto */
}


/* ── Menú de herramientas en topbar ─────────────────────── */

/* Toggle — oculto en desktop, visible en mobile */
.ask-topbar-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.ask-topbar-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--accent-border);
}
.ask-topbar-toggle .ph-wrench {
  font-size: 15px;
  color: var(--accent);
}
.ask-topbar-caret {
  font-size: 12px;
  color: var(--text-3);
  transition: transform 0.2s;
}
.ask-topbar-toggle[aria-expanded="true"] .ask-topbar-caret {
  transform: rotate(180deg);
}

/* Links — horizontal en desktop */
.ask-topbar-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

.topbar-tools-nav {
  position: relative;
  z-index: 500;
}

.ask-topbar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.ask-topbar-link i {
  font-size: 15px;
}
.ask-topbar-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.ask-topbar-link.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent-border);
}

/* Mobile — botón comprimido + dropdown */
@media (max-width: 768px) {
  .ask-topbar-toggle {
    display: flex;
  }

  .ask-topbar-links {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
    padding: 8px;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    z-index: 500;
    min-width: 260px;
  }
  .ask-topbar-links.open {
    display: grid;
  }

  .ask-topbar-link {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
  }
  .ask-topbar-link i {
    font-size: 16px;
  }
  .ask-topbar-link:hover {
    border-color: var(--border);
  }
}

@media (max-width: 480px) {
  .ask-topbar-toggle-label {
    display: none;
  }
  .ask-topbar-links {
    right: -8px;
    min-width: 220px;
  }
}
