/* ============================================
   TopElectro — Shared Styles
   Design system, themes, components
   ============================================ */

/* ============ FONTS ============ */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700;800&family=Geist+Mono:wght@400;500&display=swap');

/* ============ THEME TOKENS ============ */
:root {
  /* Light theme (default) */
  --bg: #ffffff;
  --bg-elev: #fafaf9;
  --bg-elev-2: #f4f4f2;
  --bg-inverse: #0a0a0a;

  --ink: #0a0a0a;
  --ink-2: #525252;
  --ink-3: #a3a3a3;
  --ink-inverse: #fafaf9;

  --line: rgba(0, 0, 0, 0.08);
  --line-2: rgba(0, 0, 0, 0.14);

  --volt: #d4ff00;
  --volt-deep: #93b800;
  --signal: #00d088;
  --signal-bg: #d8fce8;
  --alert: #ff3a3a;
  --alert-bg: #ffe1e1;
  --transit: #ba7517;
  --transit-bg: #fff0d4;

  --r-xs: 6px;
  --r-s: 8px;
  --r: 12px;
  --r-l: 18px;
  --r-xl: 24px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);

  --topbar-h: 64px;
  --bottom-nav-h: 64px;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-elev: #141414;
  --bg-elev-2: #1c1c1c;
  --bg-inverse: #fafaf9;

  --ink: #fafaf9;
  --ink-2: #a3a3a3;
  --ink-3: #6b6b6b;
  --ink-inverse: #0a0a0a;

  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.16);

  --signal-bg: rgba(0, 208, 136, 0.12);
  --alert-bg: rgba(255, 58, 58, 0.12);
  --transit-bg: rgba(186, 117, 23, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* ============ RESET ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01";
  transition: background 0.25s ease, color 0.25s ease;
  min-height: 100vh;
}

img, svg { display: block; max-width: 100%; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

input, textarea, select { font-family: inherit; color: inherit; }

a { color: inherit; text-decoration: none; }

/* ============ TYPOGRAPHY ============ */
.mono, .num {
  font-family: 'Geist Mono', monospace;
  font-feature-settings: "tnum";
}

.eyebrow {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink-3);
  font-weight: 500;
}

h1 { font-size: clamp(40px, 6vw, 72px); font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
h2 { font-size: clamp(28px, 4vw, 40px); font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; }
h3 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
h4 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }

.text-secondary { color: var(--ink-2); }
.text-tertiary { color: var(--ink-3); }
.text-volt { color: var(--volt-deep); }
[data-theme="dark"] .text-volt { color: var(--volt); }

.highlight-volt {
  background: var(--volt);
  color: var(--ink-inverse);
  padding: 0 10px;
}
[data-theme="dark"] .highlight-volt { color: #0a0a0a; }

/* ============ LAYOUT ============ */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 32px;
}

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.gap-32 { gap: 32px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: var(--r-s);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: all 0.15s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: var(--ink);
  color: var(--bg);
}
.btn-primary:hover { background: var(--ink-2); }
[data-theme="dark"] .btn-primary {
  background: var(--ink);
  color: var(--bg-inverse);
}

.btn-volt {
  background: var(--volt);
  color: var(--ink-inverse);
}
[data-theme="dark"] .btn-volt { color: #0a0a0a; }
.btn-volt:hover { background: #c5ed00; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-2);
}
.btn-ghost:hover { background: var(--bg-elev); }

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  color: var(--ink-2);
  transition: all 0.15s ease;
}
.btn-icon:hover {
  background: var(--bg-elev);
  color: var(--ink);
}

.btn-block { width: 100%; }
.btn-large { padding: 16px 26px; font-size: 15px; }
.btn-small { padding: 8px 14px; font-size: 13px; }

/* ============ INPUTS ============ */
.input-group {
  position: relative;
  margin-bottom: 14px;
}
.input-label {
  display: block;
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-3);
  margin-bottom: 8px;
  font-weight: 500;
}
.input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: var(--r-s);
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: all 0.15s ease;
}
.input::placeholder { color: var(--ink-3); }
.input:hover { border-color: var(--line-2); }
.input:focus {
  border-color: var(--ink);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--line);
}
.input-with-icon {
  position: relative;
}
.input-with-icon .input { padding-left: 44px; }
.input-with-icon i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  font-size: 17px;
  pointer-events: none;
}

/* ============ BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  font-family: 'Geist Mono', monospace;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge-volt { background: var(--volt); color: #0a0a0a; }
.badge-ink { background: var(--ink); color: var(--bg); }
.badge-soft { background: var(--bg-elev-2); color: var(--ink); }
.badge-signal { background: var(--signal-bg); color: var(--signal); }
.badge-alert { background: var(--alert-bg); color: var(--alert); }
.badge-transit { background: var(--transit-bg); color: var(--transit); }

/* ============ CARDS ============ */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 24px;
  transition: all 0.15s ease;
}
.card-elev {
  background: var(--bg-elev);
  border-color: transparent;
}
.card-dark {
  background: var(--bg-inverse);
  color: var(--ink-inverse);
  border-color: transparent;
}
.card-hover:hover {
  border-color: var(--line-2);
  transform: translateY(-2px);
}

/* ============ TOP NAV ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
[data-theme="dark"] .topbar {
  background: rgba(10, 10, 10, 0.85);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 28px;
  height: 28px;
  background: var(--ink);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--volt);
  font-size: 18px;
  transition: all 0.25s ease;
}
[data-theme="dark"] .brand-mark {
  background: var(--volt);
  color: #0a0a0a;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 14px;
}
.topbar-nav a {
  color: var(--ink-2);
  transition: color 0.15s ease;
  font-weight: 500;
}
.topbar-nav a:hover { color: var(--ink); }
.topbar-nav a.active { color: var(--ink); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 8px;
  border-left: 1px solid var(--line);
  margin-left: 8px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--volt);
  color: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: -0.02em;
}
.user-chip-name { font-size: 13.5px; font-weight: 500; }

.notif-dot {
  position: relative;
}
.notif-dot::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--volt);
  border: 2px solid var(--bg);
}
[data-theme="dark"] .notif-dot::after { border-color: var(--bg); }

/* ============ MOBILE BOTTOM NAV ============ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: var(--bg);
  border-top: 1px solid var(--line);
  z-index: 40;
  padding: 0 8px;
}
.bottom-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 100%;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item i { font-size: 22px; }
.bottom-nav-item.active { color: var(--ink); }
.bottom-nav-item.active i { color: var(--ink); }

/* ============ FLOATING CHAT ============ */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--volt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: var(--shadow-lg);
  z-index: 45;
  transition: all 0.2s ease;
  cursor: pointer;
}
[data-theme="dark"] .chat-fab {
  background: var(--volt);
  color: #0a0a0a;
}
.chat-fab:hover { transform: scale(1.05); }
.chat-fab .chat-fab-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--alert);
  border: 2px solid var(--ink);
  font-size: 0;
}
[data-theme="dark"] .chat-fab .chat-fab-badge { border-color: var(--volt); }

.chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 130px);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-lg);
  z-index: 44;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: all 0.2s ease;
}
.chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elev-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.chat-name { font-weight: 600; font-size: 14px; }
.chat-status { font-size: 11px; color: var(--signal); display: flex; align-items: center; gap: 4px; font-family: 'Geist Mono', monospace; }
.chat-status::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--signal);
  border-radius: 50%;
}
.chat-close-btn {
  margin-left: auto;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  transition: all 0.15s ease;
}
.chat-close-btn:hover { background: var(--bg-elev); color: var(--ink); }
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
}
.chat-msg.in {
  align-self: flex-start;
  background: var(--bg-elev);
  border-bottom-left-radius: 4px;
}
.chat-msg.out {
  align-self: flex-end;
  background: var(--ink);
  color: var(--bg);
  border-bottom-right-radius: 4px;
}
[data-theme="dark"] .chat-msg.out { background: var(--volt); color: #0a0a0a; }
.chat-msg-time {
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 4px;
  text-align: center;
}
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.chat-input-row .input { flex: 1; padding: 10px 14px; }
.chat-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--volt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
[data-theme="dark"] .chat-send { background: var(--volt); color: #0a0a0a; }

/* ============ ANIMATIONS ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulseVolt {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
.fade-up { animation: fadeUp 0.5s ease backwards; }
.fade-up-1 { animation-delay: 0.05s; }
.fade-up-2 { animation-delay: 0.15s; }
.fade-up-3 { animation-delay: 0.25s; }
.fade-up-4 { animation-delay: 0.35s; }
.fade-up-5 { animation-delay: 0.45s; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .container { padding: 0 20px; }
  .topbar-inner { padding: 0 20px; }
  .topbar-nav { display: none; }
  .user-chip-name { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .bottom-nav { display: block; }
  body { padding-bottom: var(--bottom-nav-h); }
  .chat-fab { bottom: calc(var(--bottom-nav-h) + 16px); }
  .chat-panel { bottom: calc(var(--bottom-nav-h) + 88px); right: 16px; }
}

@media (max-width: 600px) {
  .container { padding: 0 16px; }
  .topbar-inner { padding: 0 16px; }
  .topbar-actions { gap: 0; }
  .user-chip { padding-left: 4px; border-left: 0; margin-left: 0; }
}

/* ============ UTILITIES ============ */
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.spacer-8 { height: 8px; }
.spacer-16 { height: 16px; }
.spacer-24 { height: 24px; }
.spacer-32 { height: 32px; }
.spacer-48 { height: 48px; }

.full-screen-bg { min-height: 100vh; background: var(--bg); }

.scroll-area { overflow-y: auto; }

/* hide scrollbar but keep functional */
.scroll-area::-webkit-scrollbar { width: 6px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.scroll-area::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
