/* ═══════════════════════════════════════════════════════════════════════════
   CryptoGenie — styles.css
   Dark glassmorphism aesthetic. All components defined here.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-base: #0a0a0a;
  --bg-surface: #111111;
  --bg-glass: rgba(17, 17, 17, 0.75);
  --border: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(6, 182, 212, 0.2);
  --accent: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.3);
  --accent-2: #14b8a6;
  --text: #f8fafc;
  --muted: #94a3b8;
  --green: #10b981;
  --red: #ef4444;
  --blue: #3b82f6;
  --purple: #1d7bc388;
  --radius: 16px;
  --radius-sm: 10px;
  font-family: 'Inter', system-ui, sans-serif;
}

body {
  background: var(--bg-base);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 15% 15%, rgba(6, 182, 212, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 85% 85%, rgba(20, 184, 166, 0.03) 0%, transparent 60%);
}

/* ── Glass Card ────────────────────────────────────────────────────────────── */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ══════════════════════════════════════════════════════════════════════════════
   TOP BAR
   ══════════════════════════════════════════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: 1rem 2rem;
  background: rgba(10, 10, 10, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.topbar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.topbar-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -.5px;
}

.topbar-tagline {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(6, 182, 212, 0.1);
  padding: .2rem .6rem;
  border-radius: 20px;
  border: 1px solid rgba(6, 182, 212, 0.2);
}

/* Coin selector */
.topbar-center {
  display: flex;
  align-items: center;
}

.coin-selector-wrap {
  display: flex;
  gap: .35rem;
  background: rgba(255, 255, 255, .04);
  border-radius: 40px;
  padding: .25rem;
}

.coin-btn {
  padding: .4rem .9rem;
  border-radius: 30px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--muted);
  transition: all .2s;
  white-space: nowrap;
}

.coin-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .08);
}

.coin-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000;
  box-shadow: 0 0 20px var(--accent-glow);
}

/* Live price */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.live-price-wrap {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.live-dot--active {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .4;
  }
}

.live-price-label {
  font-size: .72rem;
  color: var(--muted);
  font-weight: 500;
}

.live-price-value {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.02em;
  transition: color .3s;
}

.price-up {
  color: var(--green);
}

.price-down {
  color: var(--red);
}

.forecast-stamp {
  font-size: .75rem;
  color: var(--muted);
  background: rgba(255, 255, 255, .04);
  padding: .3rem .7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════════════
   MAIN LAYOUT
   ══════════════════════════════════════════════════════════════════════════════ */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

.left-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.right-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ══════════════════════════════════════════════════════════════════════════════
   CHART CARD
   ══════════════════════════════════════════════════════════════════════════════ */
.chart-card {
  padding: 1.4rem;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1rem;
}

.chart-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.chart-subtitle {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .2rem;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  color: var(--muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-band {
  width: 20px;
  height: 10px;
  flex-shrink: 0;
  background: rgba(6, 182, 212, .2);
  border-radius: 3px;
  border-top: 1px solid rgba(6, 182, 212, .5);
  border-bottom: 1px solid rgba(6, 182, 212, .5);
}

.chart-container {
  height: 420px;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, .2);
}

.chart-loading,
.chart-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  color: var(--muted);
  font-size: .9rem;
}

.chart-disclaimer {
  margin-top: .85rem;
  font-size: .72rem;
  color: var(--muted);
  padding: .5rem .75rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  line-height: 1.5;
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(6, 182, 212, .15);
  border-top-color: var(--accent);
  animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ══════════════════════════════════════════════════════════════════════════════
   INTELLIGENCE GRID
   ══════════════════════════════════════════════════════════════════════════════ */
.intel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

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

.span-2 {
  grid-column: span 2;
}

@media (max-width: 640px) {
  .span-2 {
    grid-column: span 1;
  }
}

.intel-card {
  padding: 1.3rem;
}

.intel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .85rem;
}

.intel-title {
  font-size: 1rem;
  font-weight: 700;
}

.intel-subtitle {
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: .85rem;
  color: var(--muted);
}

.intel-summary {
  font-size: .88rem;
  line-height: 1.65;
  color: var(--text);
}

/* Sentiment badge */
.sentiment-badge {
  font-size: .75rem;
  font-weight: 700;
  padding: .3rem .8rem;
  border-radius: 20px;
  letter-spacing: .06em;
}

.badge-bull {
  background: rgba(74, 222, 128, .15);
  color: var(--green);
  border: 1px solid rgba(74, 222, 128, .3);
}

.badge-bear {
  background: rgba(248, 113, 113, .15);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, .3);
}

.badge-neu {
  background: rgba(148, 163, 184, .1);
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, .2);
}

/* Confidence bar */
.confidence-wrap {
  margin-top: 1.1rem;
}

.confidence-label {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: .4rem;
}

.progress-track {
  background: rgba(255, 255, 255, .08);
  border-radius: 10px;
  height: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent), #fbbf24);
  transition: width .6s ease;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Stat Boxes */
.stat-box {
  padding: 1.4rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
}

.stat-icon {
  font-size: 1.6rem;
}

.stat-label {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.04em;
}

.stat-sub {
  font-size: .7rem;
  color: var(--muted);
}

/* Risk */
.risk-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .6rem;
}

.risk-label {
  font-size: .82rem;
  color: var(--muted);
}

.risk-badge {
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .6rem;
  border-radius: 20px;
  letter-spacing: .05em;
}

.risk-high {
  background: rgba(248, 113, 113, .15);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, .3);
}

.risk-medium {
  background: rgba(251, 191, 36, .15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, .3);
}

.risk-low {
  background: rgba(74, 222, 128, .15);
  color: var(--green);
  border: 1px solid rgba(74, 222, 128, .3);
}

.risk-rationale {
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.5;
  margin-top: .5rem;
}

/* Key Levels */
.levels-section {
  margin-bottom: .75rem;
}

.levels-label {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: .4rem;
  font-weight: 500;
}

.levels-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.level-pill {
  font-size: .75rem;
  font-weight: 600;
  padding: .25rem .65rem;
  border-radius: 20px;
}

.support-pill {
  background: rgba(74, 222, 128, .12);
  color: var(--green);
  border: 1px solid rgba(74, 222, 128, .25);
}

.resist-pill {
  background: rgba(248, 113, 113, .12);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, .25);
}

/* Catalysts */
.catalysts-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.catalyst-item {
  font-size: .83rem;
  color: var(--text);
  padding: .55rem .75rem;
  background: rgba(255, 255, 255, .03);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  line-height: 1.5;
}

/* No Data */
.no-data-card {
  padding: 3rem 2rem;
  text-align: center;
}

.no-data-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.no-data-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: .5rem;
}

.no-data-sub {
  font-size: .85rem;
  color: var(--muted);
}

/* ══════════════════════════════════════════════════════════════════════════════
   HISTORY SIDEBAR
   ══════════════════════════════════════════════════════════════════════════════ */
.history-card {
  padding: 1.3rem;
  height: fit-content;
  position: sticky;
  top: 80px;
}

.history-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .2rem;
}

.history-sub {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  max-height: 70vh;
  overflow-y: auto;
}

.history-list::-webkit-scrollbar {
  width: 4px;
}

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

.history-empty {
  font-size: .82rem;
  color: var(--muted);
  text-align: center;
  padding: 1.5rem 0;
}

.history-entry {
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem;
  transition: border-color .2s;
}

.history-entry--latest {
  border-color: rgba(249, 115, 22, .3);
  background: rgba(249, 115, 22, .05);
}

.history-date {
  font-size: .72rem;
  color: var(--muted);
  margin-bottom: .3rem;
}

.history-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .2rem;
}

.history-sentiment {
  font-size: .78rem;
  font-weight: 700;
}

.history-conf {
  font-size: .72rem;
  color: var(--muted);
}

.history-price {
  font-size: .78rem;
  color: var(--text);
}

.history-upside {
  font-size: .78rem;
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════════════════════
   AI CHAT WIDGET
   ══════════════════════════════════════════════════════════════════════════════ */
.chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .75rem;
}

.chat-trigger {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: linear-gradient(135deg, #167d9f94, #195b85);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: .7rem 1.2rem;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 700;
  box-shadow: 0 4px 24px rgba(58, 150, 237, 0.5);
  transition: all .2s;
}

.chat-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(28, 100, 159, 0.6);
}

.chat-trigger-icon {
  font-size: 1.1rem;
}

.chat-drawer {
  width: 380px;
  height: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(58, 195, 237, 0.3);
  box-shadow: 0 8px 48px rgba(0, 0, 0, .6);
}

@media (max-width: 480px) {
  .chat-drawer {
    width: calc(100vw - 2rem);
  }
}

.chat-drawer-header {
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(124, 58, 237, .1);
  flex-shrink: 0;
}

.chat-drawer-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .9rem;
  font-weight: 700;
}

.chat-context-badge {
  font-size: .7rem;
  background: rgba(249, 115, 22, .15);
  color: var(--accent);
  border: 1px solid rgba(249, 115, 22, .3);
  padding: .2rem .55rem;
  border-radius: 12px;
}

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

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

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

.chat-msg {
  display: flex;
}

.chat-msg--user {
  justify-content: flex-end;
}

.chat-msg--assistant {
  justify-content: flex-start;
}

.chat-msg-bubble {
  max-width: 85%;
  padding: .6rem .85rem;
  border-radius: 12px;
  font-size: .84rem;
  line-height: 1.55;
}

.chat-msg--user .chat-msg-bubble {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.chat-msg--assistant .chat-msg-bubble {
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 3px;
}

/* Thinking dots */
.chat-thinking {
  display: flex;
  gap: .35rem;
  align-items: center;
  padding: .6rem .85rem;
}

.chat-thinking span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  animation: bounce-dot .9s ease-in-out infinite;
}

.chat-thinking span:nth-child(2) {
  animation-delay: .15s;
}

.chat-thinking span:nth-child(3) {
  animation-delay: .3s;
}

@keyframes bounce-dot {

  0%,
  80%,
  100% {
    transform: scale(.8);
    opacity: .4;
  }

  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: .84rem;
  padding: .55rem .75rem;
  font-family: inherit;
  resize: none;
  transition: border-color .2s;
}

.chat-input:focus {
  outline: none;
  border-color: rgba(124, 58, 237, .5);
}

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

.chat-send-btn {
  background: linear-gradient(135deg, #15658a9d, #175577);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
}

.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

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

.chat-footer-note {
  text-align: center;
  font-size: .65rem;
  color: var(--muted);
  padding: .3rem 0 .5rem;
  flex-shrink: 0;
}

/* Markdown Styles inside Chat Bubbles */
.markdown-body p {
  margin-bottom: 0.5rem;
}

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

.markdown-body strong {
  font-weight: 600;
  color: #e2e8f0;
}

.markdown-body ul {
  list-style-type: disc;
  margin-left: 1.25rem;
  margin-bottom: 0.5rem;
}

.markdown-body ol {
  list-style-type: decimal;
  margin-left: 1.25rem;
  margin-bottom: 0.5rem;
}

.markdown-body li {
  margin-bottom: 0.25rem;
}

.markdown-body em {
  font-style: italic;
  opacity: 0.9;
}