/* TauBot — Chatbot visual */

:root {
  --bot-bg: #0f0f11;
  --bot-surface: #18181b;
  --bot-surface-2: #27272a;
  --bot-border: #3f3f47;
  --bot-text: #fafafa;
  --bot-muted: #a1a1aa;
  --bot-accent: #e4e4e7;
  --bot-user: #3f3f47;
  --bot-bot: #18181b;
  --bot-radius: 16px;
  --bot-shadow: 0 25px 50px -12px rgba(0,0,0,0.6);
}

/* Widget flotante */
.tau-bot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: 'Manrope', system-ui, sans-serif;
}

.tau-bot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid var(--bot-border);
  background: linear-gradient(135deg, #27272a, #18181b);
  color: var(--bot-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--bot-shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.tau-bot-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 25px 50px -8px rgba(255,255,255,0.08);
}

.tau-bot-toggle svg { width: 28px; height: 28px; }

.tau-bot-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: min(420px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 120px));
  background: var(--bot-bg);
  border: 1px solid var(--bot-border);
  border-radius: var(--bot-radius);
  box-shadow: var(--bot-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: botSlideUp 0.3s ease;
}

.tau-bot-panel.open { display: flex; }

@keyframes botSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Contenedor principal */
.tau-bot {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bot-bg);
  color: var(--bot-text);
  font-family: 'Manrope', system-ui, sans-serif;
}

.tau-bot--fullscreen {
  height: calc(100vh - 140px);
  max-width: 900px;
  margin: 0 auto;
  border: 1px solid var(--bot-border);
  border-radius: var(--bot-radius);
  overflow: hidden;
}

.tau-bot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bot-border);
  background: var(--bot-surface);
}

.tau-bot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #52525b, #3f3f47);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.tau-bot-header-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.tau-bot-header-info p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--bot-muted);
}

.tau-bot-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--bot-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
}

.tau-bot-close:hover { background: var(--bot-surface-2); color: var(--bot-text); }

.tau-bot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.tau-bot-messages::-webkit-scrollbar { width: 6px; }
.tau-bot-messages::-webkit-scrollbar-thumb { background: var(--bot-border); border-radius: 3px; }

.tau-bot-msg {
  display: flex;
  gap: 10px;
  max-width: 95%;
  animation: botFadeIn 0.3s ease;
}

@keyframes botFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.tau-bot-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.tau-bot-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.tau-bot-msg--bot .tau-bot-msg-bubble {
  background: var(--bot-surface);
  border: 1px solid var(--bot-border);
  border-bottom-left-radius: 4px;
}

.tau-bot-msg--user .tau-bot-msg-bubble {
  background: var(--bot-user);
  border-bottom-right-radius: 4px;
}

/* Cards de producto */
.tau-bot-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
  width: 100%;
}

.tau-bot-card {
  background: var(--bot-surface-2);
  border: 1px solid var(--bot-border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.tau-bot-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.3);
}

.tau-bot-card-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: #111;
}

.tau-bot-card-body { padding: 10px; }

.tau-bot-card-title {
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.3;
}

.tau-bot-card-sub {
  font-size: 11px;
  color: var(--bot-muted);
  margin: 0;
}

/* Navegación */
.tau-bot-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 18px;
  background: var(--bot-text);
  color: var(--bot-bg);
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
}

.tau-bot-nav-btn:hover { opacity: 0.9; }

/* Sugerencias */
.tau-bot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tau-bot-suggestion {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--bot-border);
  border-radius: 20px;
  color: var(--bot-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.tau-bot-suggestion:hover {
  border-color: var(--bot-accent);
  color: var(--bot-text);
}

/* Typing indicator */
.tau-bot-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.tau-bot-typing span {
  width: 8px;
  height: 8px;
  background: var(--bot-muted);
  border-radius: 50%;
  animation: botBounce 1.4s infinite ease-in-out both;
}

.tau-bot-typing span:nth-child(1) { animation-delay: -0.32s; }
.tau-bot-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes botBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input */
.tau-bot-input-area {
  padding: 16px;
  border-top: 1px solid var(--bot-border);
  background: var(--bot-surface);
}

.tau-bot-input-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.tau-bot-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bot-bg);
  border: 1px solid var(--bot-border);
  border-radius: 12px;
  color: var(--bot-text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 0.2s;
}

.tau-bot-input:focus {
  border-color: rgba(255,255,255,0.4);
}

.tau-bot-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: var(--bot-text);
  color: var(--bot-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.tau-bot-send:disabled { opacity: 0.4; cursor: not-allowed; }
.tau-bot-send:not(:disabled):hover { opacity: 0.85; }

/* Debug trace */
.tau-bot-debug-trace {
  margin-top: 10px;
  border: 1px solid var(--bot-border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 11px;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, monospace;
  overflow: hidden;
}

.tau-bot-debug-trace summary {
  padding: 8px 10px;
  cursor: pointer;
  color: var(--bot-muted);
  user-select: none;
  list-style: none;
}

.tau-bot-debug-trace summary::-webkit-details-marker { display: none; }

.tau-bot-debug-trace summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 0.15s;
}

.tau-bot-debug-trace[open] summary::before {
  transform: rotate(90deg);
}

.tau-bot-debug-trace summary:hover { color: var(--bot-text); }

.tau-bot-debug-meta {
  padding: 0 10px 6px;
  color: var(--bot-muted);
  font-size: 10px;
}

.tau-bot-debug-steps {
  padding: 0 10px 10px;
  max-height: 320px;
  overflow: auto;
}

.tau-bot-debug-step {
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 2px solid var(--bot-accent, #a78bfa);
}

.tau-bot-debug-step-name {
  font-weight: 600;
  color: var(--bot-accent, #a78bfa);
  margin-right: 8px;
}

.tau-bot-debug-step-ms {
  color: var(--bot-muted);
  font-size: 10px;
}

.tau-bot-debug-step-data {
  margin: 4px 0 0;
  padding: 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d4d4d8;
  max-height: 180px;
  overflow: auto;
}

/* Página fullscreen */
.bot-page {
  margin: 0;
  min-height: 100vh;
  background: var(--bot-bg);
  color: var(--bot-text);
  font-family: 'Manrope', system-ui, sans-serif;
}

.bot-page-bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 30% 0%, rgba(63,63,71,0.3), transparent 60%),
              radial-gradient(ellipse at 80% 100%, rgba(39,39,42,0.4), transparent 50%);
  pointer-events: none;
}

.bot-page-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--bot-border);
}

.bot-back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--bot-muted);
  text-decoration: none;
  font-size: 14px;
}

.bot-back-link:hover { color: var(--bot-text); }

.bot-page-logo { height: 32px; }
.bot-page-logo.logo-myth { height: 40px; }

.bot-page-title h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.bot-page-title p {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--bot-muted);
}

.bot-page-main {
  position: relative;
  padding: 24px;
  max-width: 960px;
  margin: 0 auto;
}

@media (max-width: 600px) {
  .tau-bot-widget { bottom: 16px; right: 16px; }
  .tau-bot-panel { width: calc(100vw - 32px); }
  .bot-page-header { flex-wrap: wrap; padding: 16px; }
  .tau-bot--fullscreen { height: calc(100vh - 180px); }
}
