/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:       #050508;
  --surface:  #0a0d16;
  --surface2: #0f1623;
  --border:   rgba(0,212,255,0.12);
  --border2:  rgba(255,255,255,0.06);
  --cyan:     #00d4ff;
  --cyan2:    #0088ff;
  --green:    #00ff88;
  --red:      #ff3366;
  --gold:     #ffd700;
  --purple:   #a855f7;
  --text:     #e2e8f0;
  --muted:    #475569;
  --sidebar:  240px;
}

html { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Background grid ── */
.grid-bg {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  padding: 0;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 22px; color: var(--cyan); }
.logo-text {
  font-family: 'Orbitron', monospace;
  font-size: 16px; font-weight: 700;
  color: var(--cyan);
  letter-spacing: 2px;
}

.nav-section-label {
  font-size: 10px; font-weight: 600;
  color: var(--muted); letter-spacing: 2px;
  padding: 16px 20px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: all 0.2s;
  border-left: 2px solid transparent;
  position: relative;
}
.nav-item:hover { color: var(--text); background: rgba(0,212,255,0.04); }
.nav-item.active {
  color: var(--cyan);
  background: rgba(0,212,255,0.08);
  border-left-color: var(--cyan);
}
.nav-icon { font-size: 15px; }

.sidebar-footer { margin-top: auto; padding: 16px 20px; border-top: 1px solid var(--border); }
.sidebar-version { font-size: 10px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }

/* ── Main layout ── */
.main-content {
  margin-left: var(--sidebar);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
  position: relative; z-index: 1;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(5,5,8,0.8);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
}
.page-title {
  font-family: 'Orbitron', monospace;
  font-size: 14px; font-weight: 700;
  color: var(--text); letter-spacing: 2px;
  text-transform: uppercase;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.status-pill {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,255,136,0.08);
  border: 1px solid rgba(0,255,136,0.2);
  padding: 5px 12px; border-radius: 20px;
  font-size: 11px; font-weight: 600; color: var(--green);
  letter-spacing: 1px;
}
.pulse-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50% { opacity:0.5; transform:scale(1.4); }
}

.content-area { padding: 28px; flex: 1; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  text-decoration: none; border: none;
}
.btn-primary {
  background: var(--cyan); color: #000;
}
.btn-primary:hover { background: #33dfff; box-shadow: 0 0 20px rgba(0,212,255,0.4); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #ff5580; box-shadow: 0 0 20px rgba(255,51,102,0.4); }
.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { color: var(--text); border-color: var(--cyan); }
.btn-ai {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
}
.btn-ai:hover { box-shadow: 0 0 20px rgba(168,85,247,0.4); }

/* ── Cards ── */
.card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.3;
}
.card-label {
  font-size: 10px; font-weight: 600; color: var(--muted);
  letter-spacing: 2px; text-transform: uppercase; margin-bottom: 8px;
}
.card-value {
  font-family: 'Orbitron', monospace;
  font-size: 26px; font-weight: 700; color: var(--text);
  line-height: 1.1;
}
.card-value.positive { color: var(--green); }
.card-value.negative { color: var(--red); }
.card-value.cyan     { color: var(--cyan); }
.card-value.gold     { color: var(--gold); }
.card-sub { font-size: 11px; color: var(--muted); margin-top: 6px; }
.card-glow-green::after {
  content: '';
  position: absolute; bottom: -20px; right: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,255,136,0.15), transparent 70%);
}
.card-glow-red::after {
  content: '';
  position: absolute; bottom: -20px; right: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,51,102,0.15), transparent 70%);
}
.card-glow-cyan::after {
  content: '';
  position: absolute; bottom: -20px; right: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,212,255,0.12), transparent 70%);
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Charts ── */
.chart-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}
.chart-title {
  font-size: 11px; font-weight: 600; color: var(--muted);
  letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.chart-title::before {
  content: ''; display: inline-block;
  width: 3px; height: 14px; border-radius: 2px;
  background: var(--cyan);
}

/* ── Table ── */
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  padding: 10px 14px;
  text-align: left; font-size: 10px;
  font-weight: 600; color: var(--muted);
  letter-spacing: 1.5px; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  vertical-align: middle;
}
.data-table tr:hover td { background: rgba(0,212,255,0.03); }
.data-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.5px;
}
.badge-buy  { background: rgba(0,255,136,0.1); color: var(--green); border: 1px solid rgba(0,255,136,0.2); }
.badge-sell { background: rgba(255,51,102,0.1); color: var(--red);  border: 1px solid rgba(255,51,102,0.2); }
.pnl-pos { color: var(--green); font-weight: 600; font-family: 'JetBrains Mono', monospace; }
.pnl-neg { color: var(--red);   font-weight: 600; font-family: 'JetBrains Mono', monospace; }
.mono    { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* ── Forms ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  letter-spacing: 1px; text-transform: uppercase;
}
.form-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px; border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px; transition: border-color 0.2s;
  outline: none;
}
.form-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0,212,255,0.1); }
.form-input option { background: var(--surface2); }
textarea.form-input { resize: vertical; min-height: 80px; }

/* ── Calendar ── */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-header {
  text-align: center; padding: 8px 4px;
  font-size: 10px; font-weight: 700;
  color: var(--muted); letter-spacing: 2px;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
  border: 1px solid var(--border2);
  background: var(--surface2);
  padding: 4px; position: relative;
  min-height: 70px;
}
.cal-day:hover { transform: scale(1.04); z-index: 10; }
.cal-day.win {
  background: rgba(0,255,136,0.08);
  border-color: rgba(0,255,136,0.25);
}
.cal-day.loss {
  background: rgba(255,51,102,0.08);
  border-color: rgba(255,51,102,0.25);
}
.cal-day.empty { opacity: 0; pointer-events: none; }
.cal-day.today { border-color: var(--cyan); }
.cal-day-num {
  font-size: 11px; color: var(--muted); font-weight: 600;
  align-self: flex-start; padding: 2px;
}
.cal-pnl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 700;
  margin-top: 2px;
}
.cal-pnl.pos { color: var(--green); }
.cal-pnl.neg { color: var(--red); }
.cal-wl { font-size: 9px; color: var(--muted); }
.cal-nav { display: flex; align-items: center; gap: 16px; }

/* ── AI Coach ── */
.chat-window {
  height: 480px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.msg { max-width: 80%; }
.msg-user { align-self: flex-end; }
.msg-ai   { align-self: flex-start; }
.msg-bubble {
  padding: 12px 16px; border-radius: 12px;
  font-size: 13px; line-height: 1.6;
}
.msg-user .msg-bubble {
  background: var(--cyan2); color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-ai .msg-bubble {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-input-row {
  display: flex; gap: 10px; margin-top: 12px;
}
.chat-input-row .form-input { flex: 1; }

.typing-indicator span {
  width: 6px; height: 6px; background: var(--cyan);
  border-radius: 50%; display: inline-block;
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100% { transform:translateY(0); } 30% { transform:translateY(-8px); } }

/* ── Misc ── */
.section-title {
  font-family: 'Orbitron', monospace;
  font-size: 11px; font-weight: 700;
  color: var(--muted); letter-spacing: 3px;
  text-transform: uppercase; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px;
  background: var(--border);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mt-8  { margin-top: 32px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--muted); font-size: 12px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.glow-text { text-shadow: 0 0 20px currentColor; }
.table-wrap { overflow-x: auto; }

/* ── Win rate ring ── */
.wr-ring { position: relative; width: 120px; height: 120px; }
.wr-ring svg { transform: rotate(-90deg); }
.wr-ring-val {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.wr-ring-num {
  font-family: 'Orbitron', monospace;
  font-size: 20px; font-weight: 700; color: var(--cyan);
}
.wr-ring-lbl { font-size: 9px; color: var(--muted); letter-spacing: 1px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #334155; }

/* ── Loading overlay ── */
.loading-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(5,5,8,0.8); z-index: 999;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
}
.loading-overlay.show { display: flex; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid rgba(0,212,255,0.2);
  border-top-color: var(--cyan);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Emotion tag selector ── */
.emotion-grid {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  margin-top: 8px;
}
.emotion-tag {
  cursor: pointer;
  display: inline-block;
}
.emotion-tag span {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,0.12);
  background: #0f1623;
  color: #64748b;
  transition: all 0.15s;
  user-select: none;
  cursor: pointer;
  white-space: nowrap;
}
.emotion-tag:hover span {
  border-color: #00d4ff;
  color: #e2e8f0;
}
.emotion-tag input:checked + span {
  background: rgba(0,212,255,0.15);
  border-color: #00d4ff;
  color: #00d4ff;
  font-weight: 600;
}

/* ── Image upload zones ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  min-height: 100px;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px;
  cursor: pointer; transition: all 0.2s;
  background: var(--surface);
  text-align: center; padding: 12px;
}
.upload-zone:hover { border-color: var(--cyan); background: rgba(0,212,255,0.04); }
.upload-zone.has-file { border-color: var(--green); border-style: solid; }

/* ── Image lightbox ── */
.trade-thumb {
  width: 48px; height: 36px;
  object-fit: cover; border-radius: 4px;
  cursor: pointer; border: 1px solid var(--border);
  transition: transform 0.2s;
}
.trade-thumb:hover { transform: scale(1.1); border-color: var(--cyan); }

.lightbox-overlay {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.92);
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img {
  max-width: 90vw; max-height: 90vh;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 0 60px rgba(0,212,255,0.15);
}
.lightbox-close {
  position: fixed; top: 20px; right: 24px;
  color: var(--muted); font-size: 28px; cursor: pointer;
  line-height: 1; transition: color 0.2s;
}
.lightbox-close:hover { color: var(--text); }

/* ── Responsive ── */
@media (max-width: 900px) {
  :root { --sidebar: 60px; }
  .logo-text, .nav-section-label, .nav-item span:not(.nav-icon), .sidebar-footer { display: none; }
  .nav-item { justify-content: center; padding: 14px; }
  .sidebar-logo { justify-content: center; padding: 16px; }
}

/* ── v0.4: Light theme ───────────────────────────────────────── */
[data-theme="light"] {
  --bg:       #f0f2f5;
  --surface:  #ffffff;
  --border:   #dde1e7;
  --text:     #1a1a2e;
  --muted:    #6b7280;
  --cyan:     #0099bb;
  --gold:     #b8860b;
  --red:      #cc2200;
}
[data-theme="light"] .grid-bg { opacity: 0.03; }
[data-theme="light"] .sidebar { background: #1a1a2e; }
[data-theme="light"] .main-content { background: var(--bg); }
[data-theme="light"] .card { background: var(--surface); }
[data-theme="light"] .form-input { background: #f8f9fa; color: var(--text); border-color: var(--border); }
[data-theme="light"] .data-table th { background: #f0f2f5; color: var(--muted); }
[data-theme="light"] .data-table tr:hover { background: rgba(0,0,0,.03); }

/* ── Badge variants ──────────────────────────────────────────── */
.badge-active  { background: rgba(0,212,255,.15); color: #00d4ff; }
.badge-trial   { background: rgba(0,212,255,.08); color: #00d4ff; }
.badge-pending { background: rgba(255,215,0,.12); color: #ffd700; }
.badge-expired { background: rgba(255,68,68,.12);  color: #ff4444; }

/* ── Alert boxes ─────────────────────────────────────────────── */
.alert { border-radius: 8px; padding: 12px 16px; font-size: 13px; }
.alert-success { background: rgba(0,212,255,.08); border: 1px solid rgba(0,212,255,.25); color: #00d4ff; }
.alert-error   { background: rgba(255,68,68,.08);  border: 1px solid rgba(255,68,68,.25);  color: #ff6666; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
