/* Satoshi IA Web Chat — estilo Cursor */

:root {
  --bg: #0a0a0f;
  --sidebar: #111118;
  --panel: #16161f;
  --border: #2a2a3a;
  --text: #ececf1;
  --muted: #8e8ea0;
  --accent: #f7931a;
  --accent-dim: rgba(247, 147, 26, 0.15);
  /* Azul cuántico — ref. EBIS / automatización (cian neón + eléctrico) */
  --cyan: #00f2ff;
  --cyan-bright: #00ffff;
  --cyan-electric: #007bff;
  --cyan-deep: #0051ff;
  --cyan-soft: #a8f7ff;
  --cyan-glow: rgba(0, 242, 255, 0.55);
  --cyan-neon: 0 0 8px #00f2ff, 0 0 18px rgba(0, 255, 255, 0.55), 0 0 36px rgba(0, 123, 255, 0.28);
  --user-bg: #2d2d3a;
  --assistant-bg: transparent;
  --hover: #1e1e2a;
  --input-bg: #1a1a24;
  --success: #3fb950;
  --error: #f85149;
  --sidebar-w: 260px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(247, 147, 26, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(0, 242, 255, 0.06) 0%, transparent 40%);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
}

.public-banner {
  grid-column: 1 / -1;
  grid-row: 1;
}

.sidebar {
  grid-column: 1;
  grid-row: 2;
}

.panel-chat {
  grid-column: 2;
  grid-row: 2;
}

.panel-wallet:not(.hidden) {
  grid-column: 1 / -1;
  grid-row: 2;
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar { display: none; }

  .panel-chat {
    grid-column: 1;
    grid-row: 2;
  }

  .panel-wallet:not(.hidden) {
    grid-column: 1;
  }
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.logo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-logo-link {
  flex: 1;
  min-width: 0;
  text-decoration: none;
}

.sidebar-logo {
  width: 100%;
  max-width: 200px;
  height: auto;
  display: block;
}

.logo-home {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  flex-shrink: 0;
  transition: all 0.15s;
}

.logo-home:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: block;
  flex-shrink: 0;
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo-tagline {
  font-size: 10px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  margin-top: 1px;
}

.mode-icon {
  opacity: 0.7;
  margin-right: 2px;
  font-size: 10px;
}

.mode-nav {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  background: var(--hover);
  border-radius: 8px;
  padding: 3px;
}

.mode-btn {
  flex: 1;
  padding: 8px 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn.active {
  background: var(--panel);
  color: var(--accent);
  font-weight: 600;
}

.hidden { display: none !important; }

.panel-wallet { background: var(--bg); }

.wallet-subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; }

.wallet-mode-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--accent-dim);
  color: var(--accent);
}

.wallet-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.wallet-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .wallet-grid { grid-template-columns: 1fr; }
}

.wallet-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.wallet-card h3 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wallet-card-main { border-color: rgba(247, 147, 26, 0.3); }

.balance-list { display: flex; flex-direction: column; gap: 8px; }

.balance-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--hover);
  border-radius: 8px;
  font-size: 13px;
}

.balance-code { font-weight: 600; color: var(--accent); }
.balance-amount { color: var(--text); font-family: monospace; }

.balance-empty { color: var(--muted); font-size: 13px; }

.wallet-auth { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }

.wallet-auth input, .wallet-password, .send-box input, .swap-row input, .send-box select {
  width: 100%;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}

.swap-box { display: flex; flex-direction: column; gap: 8px; }
.swap-box label { font-size: 11px; color: var(--muted); }

.swap-row {
  display: flex;
  gap: 8px;
}

.swap-row input { flex: 1; }
.swap-row select, .send-box select, #sendChain {
  padding: 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}

.swap-flip {
  align-self: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--hover);
  color: var(--accent);
  cursor: pointer;
  font-size: 16px;
}

.swap-rate { font-size: 11px; color: var(--muted); padding: 4px 0; }

.wallet-btn {
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  margin-top: 4px;
}

.wallet-btn.primary { background: var(--accent); color: #000; }
.wallet-btn.secondary { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.wallet-btn:hover { opacity: 0.9; }

.send-box { display: flex; flex-direction: column; gap: 8px; }

.wallet-note {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin: 20px auto 0;
  max-width: 600px;
  line-height: 1.5;
}

.wallet-subscribe {
  max-width: 1100px;
  margin: 20px auto 0;
  background: var(--panel);
  border: 1px solid rgba(247, 147, 26, 0.35);
  border-radius: 12px;
  padding: 20px;
}

.subscribe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.subscribe-header h3 {
  font-size: 14px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.subscribe-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--accent-dim);
  color: var(--accent);
}

.subscribe-genesis {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 14px;
}

.subscribe-row {
  margin-bottom: 10px;
}

.subscribe-row label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.subscribe-row select {
  width: 100%;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}

.subscribe-row select option.genesis {
  font-weight: 600;
}

.subscribe-quote {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  padding: 10px 0;
  min-height: 1.5em;
}

.balance-item.genesis .balance-code {
  color: var(--accent);
  font-weight: 700;
}

.balance-item.genesis::before {
  content: '₿ ';
  color: var(--accent);
  font-size: 11px;
}

.wallet-result {
  max-width: 600px;
  margin: 12px auto 0;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}

.wallet-result.success { background: rgba(63, 185, 80, 0.1); color: var(--success); }
.wallet-result.error { background: rgba(248, 81, 73, 0.1); color: var(--error); }

.new-chat-btn {
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}

.new-chat-btn:hover { background: rgba(247, 147, 26, 0.25); }

.conversations {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conv-item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.conv-item:hover { background: var(--hover); color: var(--text); }
.conv-item.active { background: var(--hover); color: var(--text); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

.plan-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 6px;
}

.usage-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.usage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ── Main chat ── */
.main {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
}

.chat-title { font-size: 14px; font-weight: 500; }

.chat-header-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wallet-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid rgba(0, 255, 255, 0.45);
  background: rgba(0, 242, 255, 0.12);
  box-shadow: var(--cyan-neon);
  color: var(--cyan);
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all 0.15s;
}

.wallet-pill:hover {
  background: rgba(0, 242, 255, 0.2);
  box-shadow: var(--cyan-neon);
}

.wallet-pill-icon { font-size: 12px; }

.wallet-fab {
  position: absolute;
  left: 20px;
  bottom: 120px;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 1px solid rgba(0, 255, 255, 0.5);
  background: linear-gradient(135deg, rgba(0, 242, 255, 0.28), rgba(0, 123, 255, 0.32));
  color: var(--cyan);
  font-size: 22px;
  cursor: pointer;
  z-index: 40;
  box-shadow: var(--cyan-neon);
  transition: transform 0.15s;
}

.wallet-fab:hover { transform: scale(1.05); }

.panel-chat { position: relative; }

.wallet-shortcuts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 16px;
}

.wallet-shortcut {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.wallet-shortcut:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.wallet-shortcut.accent {
  border-color: rgba(247, 147, 26, 0.4);
  color: var(--accent);
}

.public-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(247,147,26,0.12), rgba(0,212,255,0.08));
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.public-banner.hidden { display: none; }

.public-banner strong { color: var(--text); }

.public-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }

.public-share-btn,
.public-banner-close {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
}

.public-banner-close { width: 28px; padding: 4px; }

.message-wallet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.message-wallet-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0, 255, 255, 0.45);
  background: rgba(0, 242, 255, 0.12);
  box-shadow: var(--cyan-neon);
  color: var(--cyan);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.message-wallet-btn:hover {
  background: rgba(0, 242, 255, 0.2);
}

.message-wallet-btn.btc {
  border-color: rgba(247, 147, 26, 0.4);
  color: var(--accent);
  background: rgba(247, 147, 26, 0.08);
}

.chat-status { font-size: 11px; color: var(--muted); }

.sync-badge {
  font-size: 10px;
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
  margin-left: 8px;
}
.sync-badge.on {
  color: #00f2ff;
  border-color: rgba(0, 242, 255, 0.35);
  box-shadow: 0 0 10px rgba(0, 242, 255, 0.12);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.online { background: var(--success); }
.status-dot.bitacora { background: var(--accent); }
.status-dot.offline { background: var(--error); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.messages-inner {
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Welcome screen */
.welcome {
  text-align: center;
  padding: 60px 20px;
  max-width: 600px;
  margin: auto;
}

.welcome h2 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--text);
}

.welcome p { color: var(--muted); font-size: 14px; margin-bottom: 32px; }

.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.suggestion {
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, color 0.15s;
}

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

.mystery-bridge {
  margin-bottom: 20px; padding: 14px 16px; text-align: left;
  background: rgba(247, 147, 26, 0.06);
  border: 1px solid rgba(247, 147, 26, 0.28);
  border-radius: 14px;
}
.mystery-bridge strong { color: var(--accent); font-size: 12px; display: block; margin-bottom: 8px; }
.mystery-bridge .mystery-q { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.mystery-bridge .mystery-a { font-size: 12px; color: var(--text); margin-bottom: 10px; font-style: italic; }
.mystery-bridge .mystery-stage {
  font-size: 10px; color: var(--cyan); letter-spacing: 0.08em; margin-bottom: 10px;
}
.suggestions.mystery-fed { margin-top: 4px; }

/* Message bubbles */
.message {
  display: flex;
  gap: 14px;
  line-height: 1.65;
  font-size: 14px;
  max-width: 100%;
}

.message.user {
  flex-direction: row-reverse;
  margin-left: 15%;
}

.message.user .message-content {
  background: var(--user-bg);
  border: 1px solid var(--border);
  border-radius: 14px 14px 4px 14px;
  padding: 12px 14px;
}

.message.assistant .message-content {
  padding: 0 4px;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.user .message-avatar.user-dot { background: var(--user-bg); }
.message.assistant .message-avatar { background: transparent; }

.message-content { flex: 1; min-width: 0; }
.message-role { font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.message.user .message-role { color: var(--text); }

.message-text { white-space: pre-wrap; word-break: break-word; }
.message-text.streaming::after {
  content: '▋';
  animation: blink 1s infinite;
  color: var(--accent);
  margin-left: 1px;
}

@keyframes blink { 50% { opacity: 0; } }

.message-sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

.source-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--hover);
  border-radius: 4px;
  margin: 2px 4px 2px 0;
  font-size: 10px;
}

/* ── Input area ── */
.input-area {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.input-box {
  max-width: 768px;
  margin: 0 auto;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  transition: border-color 0.15s;
  width: 100%;
  min-width: 0;
}

.input-box:focus-within { border-color: var(--accent); }

#input {
  flex: 1;
  min-width: 0;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 160px;
  line-height: 1.5;
  outline: none;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

#input::placeholder { color: var(--muted); }

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.send-btn:hover { opacity: 0.85; }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.send-btn svg { width: 18px; height: 18px; fill: #000; }

.input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

.global-footer {
  padding: 8px 24px 12px;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.6;
  border-top: 1px solid transparent;
  font-family: 'JetBrains Mono', monospace;
}

.balance-amount { font-family: 'JetBrains Mono', monospace; }
.swap-rate { font-family: 'JetBrains Mono', monospace; }

.welcome .welcome-logo {
  width: min(320px, 90%);
  height: auto;
  margin: 0 auto 12px;
  display: block;
}

.welcome .welcome-homage {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.welcome .welcome-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border-radius: 14px;
  display: block;
}

.welcome .welcome-quote {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  opacity: 0.8;
  margin-bottom: 24px;
}

/* ── Access modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 420px;
  width: 90%;
  text-align: center;
}

.modal-logo {
  width: min(280px, 90%);
  height: auto;
  margin: 0 auto 16px;
  display: block;
}

.modal-homage {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal p { font-size: 13px; color: var(--muted); margin-bottom: 16px; line-height: 1.5; }

.modal input {
  width: 100%;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
}

.modal button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

/* Mobile */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--sidebar);
  border-top: 1px solid var(--border);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  gap: 8px;
  z-index: 70;
}

.mobile-nav-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.mobile-nav-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(247, 147, 26, 0.3);
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .suggestions { grid-template-columns: 1fr; }
  .mobile-nav { display: flex; }
  .main { padding-bottom: 64px; }
  .message.user { margin-left: 5%; }
  .wallet-fab { bottom: calc(88px + env(safe-area-inset-bottom)); left: 16px; }
}
