/* ============================================================
   MagicHub AI — Mini App Styles
   Color scheme: bg #040b14, accent #4a90f5, text #ffffff
   ============================================================ */

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

:root {
  --bg: #040b14;
  --bg-card: #0d1a2d;
  --bg-card-hover: #132240;
  --bg-input: #0a1628;
  --accent: #4a90f5;
  --accent-hover: #5da0ff;
  --accent-dim: rgba(74, 144, 245, .15);
  --text: #ffffff;
  --text-secondary: #8b9dc3;
  --text-muted: #4a5f82;
  --green: #2ecc71;
  --red: #e74c3c;
  --orange: #f39c12;
  --purple: #9b59b6;
  --gold: #f1c40f;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,.35);
  --tab-height: 64px;
  --header-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

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

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* ── Light theme ── */
body.light {
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-card-hover: #f8f9fa;
  --bg-input: #e8ecf1;
  --text: #1a1a2e;
  --text-secondary: #5a6785;
  --text-muted: #9aa5b4;
  --shadow: 0 4px 24px rgba(0,0,0,.08);
}

/* ══════════════════ Header ══════════════════ */
.header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: rgba(4, 11, 20, .92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 100;
  border-bottom: 1px solid rgba(74,144,245,.1);
}
body.light .header { background: rgba(240,242,245,.92); border-bottom-color: rgba(0,0,0,.06); }

.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.header-title { font-size: 16px; font-weight: 700; }
.header-subtitle { font-size: 10px; color: var(--text-secondary); margin-top: -2px; }

.header-balance {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: var(--accent-dim);
  border: 1px solid rgba(74,144,245,.25);
  border-radius: 20px;
  font-size: 14px; font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition: all .2s;
}
.header-balance:active { transform: scale(.95); }
.header-balance .coin-icon { font-size: 16px; }

/* ══════════════════ Content Area ══════════════════ */
.app-content {
  position: fixed;
  top: var(--header-height);
  left: 0; right: 0;
  bottom: calc(var(--tab-height) + var(--safe-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.tab-page {
  display: none;
  padding: 16px;
  padding-bottom: 24px;
  animation: fadeIn .25s ease;
}
.tab-page.active { display: block; }

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

/* ══════════════════ Tab Bar ══════════════════ */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--tab-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; align-items: center; justify-content: space-around;
  background: rgba(4, 11, 20, .95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(74,144,245,.1);
  z-index: 100;
}
body.light .tab-bar { background: rgba(255,255,255,.95); border-top-color: rgba(0,0,0,.06); }

.tab-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0;
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .2s;
  -webkit-tap-highlight-color: transparent;
}
.tab-item .tab-icon { font-size: 22px; transition: transform .2s; }
.tab-item.active { color: var(--accent); }
.tab-item.active .tab-icon { transform: scale(1.15); }

/* ══════════════════ Canvas Neural Animation ══════════════════ */
.canvas-wrap {
  position: relative;
  width: 100%;
  height: 220px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
#neural-canvas {
  width: 100%; height: 100%;
  display: block;
}
.canvas-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  pointer-events: none;
}
.canvas-overlay h2 {
  font-size: 22px; font-weight: 700;
  text-shadow: 0 2px 16px rgba(0,0,0,.6);
}
.canvas-overlay p {
  font-size: 13px; color: var(--text-secondary);
  margin-top: 4px;
  text-shadow: 0 1px 8px rgba(0,0,0,.5);
}

/* ══════════════════ Referral Banner ══════════════════ */
.ref-banner {
  background: linear-gradient(135deg, rgba(74,144,245,.15), rgba(155,89,182,.15));
  border: 1px solid rgba(74,144,245,.2);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.ref-banner-text { flex: 1; }
.ref-banner-text .ref-title { font-size: 14px; font-weight: 600; }
.ref-banner-text .ref-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.95); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}

/* ══════════════════ Bot Grid ══════════════════ */
.section-title {
  font-size: 16px; font-weight: 700;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}

.bots-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.bot-card {
  background: var(--bg-card);
  border: 1px solid rgba(74,144,245,.08);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  overflow: hidden;
}
.bot-card:active { transform: scale(.97); background: var(--bg-card-hover); }

.bot-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bot-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.bot-icon.photo   { background: linear-gradient(135deg, #667eea, #764ba2); }
.bot-icon.music   { background: linear-gradient(135deg, #f093fb, #f5576c); }
.bot-icon.chat    { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.bot-icon.astro   { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.bot-icon.biz     { background: linear-gradient(135deg, #1e3c72, #2a5298); }
.bot-icon.video   { background: linear-gradient(135deg, #fa709a, #fee140); }
.bot-icon.code    { background: linear-gradient(135deg, #30cfd0, #330867); }
.bot-icon.health  { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.bot-icon.interior{ background: linear-gradient(135deg, #ffecd2, #fcb69f); }
.bot-icon.look    { background: linear-gradient(135deg, #f093fb, #f5576c); }

.bot-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.bot-desc { font-size: 11px; color: var(--text-secondary); }

.bot-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.bot-counter { font-size: 11px; color: var(--text-muted); }
.bot-badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent);
}
.bot-badge.hot { background: rgba(231,76,60,.15); color: var(--red); }
.bot-badge.new { background: rgba(46,204,113,.15); color: var(--green); }

.bot-status {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  position: absolute; top: 12px; right: 12px;
  box-shadow: 0 0 6px var(--green);
}
.bot-status.offline { background: var(--text-muted); box-shadow: none; }

/* ── Scroll dots ── */
.scroll-dots {
  display: flex; justify-content: center; gap: 6px;
  margin-bottom: 16px;
}
.scroll-dots .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all .3s;
}
.scroll-dots .dot.active {
  width: 20px; border-radius: 3px;
  background: var(--accent);
}

/* ── Channel button ── */
.channel-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid rgba(74,144,245,.12);
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all .2s;
}
.channel-btn:active { background: var(--bg-card-hover); transform: scale(.98); }

/* ══════════════════ History Tab ══════════════════ */
.filter-row {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
  flex-shrink: 0;
  padding: 7px 16px;
  background: var(--bg-card);
  border: 1px solid rgba(74,144,245,.1);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .2s;
  -webkit-tap-highlight-color: transparent;
}
.filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.balance-summary {
  display: flex; gap: 10px;
  margin-bottom: 16px;
}
.summary-card {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.summary-card .val { font-size: 22px; font-weight: 700; }
.summary-card .label { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.summary-card.accent .val { color: var(--accent); }

.tx-list { display: flex; flex-direction: column; gap: 2px; }

.tx-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.tx-item:active { background: var(--bg-card-hover); }

.tx-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.tx-icon.spend   { background: rgba(231,76,60,.12); }
.tx-icon.deposit  { background: rgba(46,204,113,.12); }
.tx-icon.bonus   { background: rgba(74,144,245,.12); }
.tx-icon.referral { background: rgba(155,89,182,.12); }

.tx-info { flex: 1; min-width: 0; }
.tx-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date  { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.tx-amount { font-size: 14px; font-weight: 700; white-space: nowrap; }
.tx-amount.plus  { color: var(--green); }
.tx-amount.minus { color: var(--red); }

.tx-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ══════════════════ Help Tab ══════════════════ */
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card);
  border: 1px solid rgba(74,144,245,.1);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.search-box input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  color: var(--text);
  font-size: 14px;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-icon { font-size: 18px; color: var(--text-muted); }

.faq-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

.faq-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(74,144,245,.06);
}
.faq-question {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.faq-question .arrow { font-size: 12px; color: var(--text-muted); transition: transform .25s; }
.faq-item.open .faq-question .arrow { transform: rotate(180deg); }

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease, padding .3s ease;
  padding: 0 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.faq-item.open .faq-answer {
  max-height: 300px;
  padding: 0 16px 14px;
}

.support-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--accent);
  border-radius: var(--radius);
  font-size: 15px; font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: all .2s;
}
.support-btn:active { transform: scale(.98); opacity: .9; }

/* ══════════════════ Profile Tab ══════════════════ */
.profile-header {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 0 16px;
}
.avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700;
  margin-bottom: 10px;
  border: 3px solid rgba(74,144,245,.3);
}
.profile-name { font-size: 18px; font-weight: 700; }
.profile-date { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Level bar */
.level-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.level-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.level-name { font-size: 14px; font-weight: 600; }
.level-xp { font-size: 12px; color: var(--text-muted); }
.level-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}
.level-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: 3px;
  transition: width .6s ease;
}

/* Promo banner */
.promo-banner {
  background: linear-gradient(135deg, rgba(243,156,18,.15), rgba(231,76,60,.12));
  border: 1px solid rgba(243,156,18,.2);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: none;
}
.promo-banner.visible { display: flex; align-items: center; justify-content: space-between; }
.promo-text { font-size: 13px; font-weight: 600; }
.promo-timer { font-size: 13px; color: var(--orange); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ID Card */
.id-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.id-card-left { display: flex; flex-direction: column; gap: 2px; }
.id-label { font-size: 11px; color: var(--text-muted); }
.id-value { font-size: 14px; font-weight: 600; font-family: monospace; }
.id-hint { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.copy-btn {
  padding: 8px 14px;
  background: var(--accent-dim);
  border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition: all .2s;
}
.copy-btn:active { transform: scale(.95); }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.stat-val { font-size: 20px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.stat-card:nth-child(1) .stat-val { color: var(--accent); }
.stat-card:nth-child(2) .stat-val { color: var(--purple); }
.stat-card:nth-child(3) .stat-val { color: var(--green); }
.stat-card:nth-child(4) .stat-val { color: var(--gold); }

/* Menu items */
.menu-list { display: flex; flex-direction: column; gap: 2px; }

.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.menu-item:active { background: var(--bg-card-hover); }

.menu-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.menu-icon.inv  { background: rgba(74,144,245,.12); }
.menu-icon.theme { background: rgba(155,89,182,.12); }
.menu-icon.notif { background: rgba(46,204,113,.12); }
.menu-icon.fav  { background: rgba(243,156,18,.12); }
.menu-icon.help { background: rgba(231,76,60,.12); }

.menu-text { flex: 1; font-size: 14px; font-weight: 500; }
.menu-arrow { font-size: 14px; color: var(--text-muted); }

/* Toggle switch */
.toggle {
  width: 44px; height: 24px;
  background: var(--text-muted);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background .25s;
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle::after {
  content: '';
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  position: absolute; top: 2px; left: 2px;
  transition: transform .25s;
}
.toggle.on::after { transform: translateX(20px); }

/* ══════════════════ Toast ══════════════════ */
.toast {
  position: fixed;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 16px);
  left: 50%; transform: translateX(-50%) translateY(60px);
  background: var(--bg-card);
  border: 1px solid rgba(74,144,245,.15);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 13px; font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: all .3s ease;
  z-index: 200;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ══════════════════ Loading ══════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ══════════════════ Home Screen Banner ══════════════════ */
.hs-banner {
  position: fixed;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 8px);
  left: 12px;
  right: 12px;
  background: rgba(30, 80, 200, 0.95);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  padding: 16px 18px;
  z-index: 200;
  box-shadow: 0 -4px 32px rgba(30, 80, 200, 0.4);
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}
.hs-banner.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.hs-banner-title {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 10px;
}
.hs-banner-steps {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 12px;
}
.hs-banner-steps .hs-link {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-style: dotted;
}
.hs-banner-buttons {
  display: flex;
  gap: 10px;
}
.hs-banner-buttons button {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.hs-banner-buttons button:active { opacity: 0.7; }
.hs-btn-add {
  background: #fff;
  color: #1e50c8;
}
.hs-btn-later {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* ══════════════════ Responsive ══════════════════ */
@media (min-width: 400px) {
  .bots-grid { gap: 12px; }
  .bot-card { padding: 16px; }
}
