/* =====================================================================
   NEXORA — Application Stylesheet
   Shared by dashboard, auth, and admin pages
   ===================================================================== */

:root {
  --bg-deepest: #06080F;
  --bg-base: #0A0E1A;
  --bg-elevated: #11162A;
  --bg-card: #141A2E;
  --bg-card-hover: #1A2138;
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.12);

  --text-primary: #F4F6FA;
  --text-secondary: #A1A8BE;
  --text-tertiary: #6B7388;
  --text-faint: #404659;

  --accent: #FF6B1A;
  --accent-hot: #FF8546;
  --accent-glow: rgba(255, 107, 26, 0.35);
  --secondary: #7EE3FB;
  --secondary-glow: rgba(126, 227, 251, 0.25);

  --up: #10D17F;
  --up-soft: rgba(16, 209, 127, 0.12);
  --down: #FF4D5E;
  --down-soft: rgba(255, 77, 94, 0.12);

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-quick: cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-w: 240px;
  --topbar-h: 72px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #0a0a0a; }

.mono { font-family: var(--font-mono); font-feature-settings: 'tnum'; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--text-tertiary); }
.text-accent { color: var(--accent) !important; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap { display: flex; gap: 12px; align-items: center; }
.grid { display: grid; }
.hide-on-mobile { }

/* =====================================================================
   LAYOUT
   ===================================================================== */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  background: var(--bg-base);
}

.sidebar {
  background: var(--bg-deepest);
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  padding: 0 8px 24px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.logo-mark { width: 28px; height: 28px; position: relative; }
.logo-mark::before {
  content: ''; position: absolute; inset: 0; background: var(--accent);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.logo-mark::after {
  content: ''; position: absolute; inset: 0; background: var(--bg-deepest);
  clip-path: polygon(50% 18%, 82% 34%, 82% 66%, 50% 82%, 18% 66%, 18% 34%);
}
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; }
.side-nav--secondary { border-top: 1px solid var(--line); margin-top: auto; padding-top: 12px; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s var(--ease-quick);
}
.side-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.side-nav a:hover { color: var(--text-primary); background: var(--bg-elevated); }
.side-nav a.active {
  color: var(--accent);
  background: rgba(255, 107, 26, 0.08);
  box-shadow: inset 2px 0 0 var(--accent);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: hidden;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  z-index: 50;
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 14px;
  transition: border-color 0.15s;
}
.topbar-search:focus-within { border-color: var(--accent); }
.topbar-search svg { width: 16px; height: 16px; color: var(--text-tertiary); }
.topbar-search input {
  flex: 1;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  font-size: 14px;
}
.topbar-search input::placeholder { color: var(--text-tertiary); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.balance-chip {
  display: flex;
  flex-direction: column;
  text-align: right;
  padding: 4px 12px;
  border-right: 1px solid var(--line);
}
.balance-chip > .mono { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.balance-chip-label { font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.08em; }
.avatar-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #FFB07A);
  color: #0a0a0a;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 14px;
}
.avatar-name { font-size: 14px; font-weight: 500; }
.avatar-mail { font-size: 11px; color: var(--text-tertiary); }

/* =====================================================================
   CONTENT
   ===================================================================== */
.content {
  padding: 24px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-head h1 { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -0.025em; }
.page-head .lead { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.eyebrow::before { content: ''; width: 20px; height: 1px; background: var(--accent); }

/* =====================================================================
   CARDS
   ===================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color 0.2s;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}
.card-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.card-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.08em; }
.card--accent { border-color: rgba(255, 107, 26, 0.25); background: linear-gradient(180deg, rgba(255, 107, 26, 0.04), var(--bg-card)); }

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.005em;
  border-radius: var(--radius);
  transition: all 0.18s var(--ease-quick);
  white-space: nowrap;
}
.btn--primary {
  background: var(--accent);
  color: #0a0a0a;
  box-shadow: 0 0 0 1px var(--accent), 0 4px 14px -4px var(--accent-glow);
}
.btn--primary:hover { background: var(--accent-hot); transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn--ghost:hover { background: var(--bg-elevated); box-shadow: inset 0 0 0 1px var(--text-tertiary); }
.btn--success { background: var(--up); color: #0a0a0a; }
.btn--success:hover { background: #14e58c; }
.btn--danger { background: var(--down); color: #fff; }
.btn--danger:hover { background: #ff6171; }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--lg { padding: 14px 22px; font-size: 15px; }
.btn .arrow { transition: transform 0.18s; }
.btn:hover .arrow { transform: translateX(3px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* =====================================================================
   FORMS
   ===================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}
.field input,
.field select,
.field textarea {
  background: var(--bg-deepest);
  border: 1px solid var(--line);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,107,26,0.18);
}

/* =====================================================================
   FLASH MESSAGES
   ===================================================================== */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin: 16px 24px 0;
  border: 1px solid var(--line);
}
.flash--success { background: var(--up-soft); color: var(--up); border-color: rgba(16,209,127,0.25); }
.flash--error   { background: var(--down-soft); color: var(--down); border-color: rgba(255,77,94,0.25); }
.flash--info    { background: rgba(126,227,251,0.08); color: var(--secondary); border-color: rgba(126,227,251,0.25); }
.flash--warning { background: rgba(255,184,77,0.08); color: #FFC56B; border-color: rgba(255,184,77,0.25); }

/* =====================================================================
   BADGES & PILLS
   ===================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.badge--up { background: var(--up-soft); color: var(--up); }
.badge--down { background: var(--down-soft); color: var(--down); }
.badge--neutral { background: var(--bg-elevated); color: var(--text-secondary); }
.badge--accent { background: rgba(255,107,26,0.12); color: var(--accent); }

/* =====================================================================
   TABLES
   ===================================================================== */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table thead th {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.table tbody tr:hover { background: var(--bg-card-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { font-family: var(--font-mono); font-feature-settings: 'tnum'; }
.table .right { text-align: right; }

/* =====================================================================
   CRYPTO ICONS
   ===================================================================== */
.crypto-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}
.crypto-icon--BTC  { background: linear-gradient(135deg, #F7931A, #FFB36B); }
.crypto-icon--ETH  { background: linear-gradient(135deg, #627EEA, #8FA4FF); }
.crypto-icon--BNB  { background: linear-gradient(135deg, #F3BA2F, #F8E27A); color: #1a1a1a; }
.crypto-icon--SOL  { background: linear-gradient(135deg, #9945FF, #14F195); }
.crypto-icon--XRP  { background: linear-gradient(135deg, #23292F, #4a5057); }
.crypto-icon--ADA  { background: linear-gradient(135deg, #0033AD, #4d7fff); }
.crypto-icon--DOGE { background: linear-gradient(135deg, #C2A633, #f0d878); color: #1a1a1a; }
.crypto-icon--AVAX { background: linear-gradient(135deg, #E84142, #ff7a7b); }
.crypto-icon--DOT  { background: linear-gradient(135deg, #E6007A, #ff5cb0); }
.crypto-icon--MATIC{ background: linear-gradient(135deg, #8247E5, #b07eff); }
.crypto-icon--LINK { background: linear-gradient(135deg, #2A5ADA, #6189ff); }
.crypto-icon--LTC  { background: linear-gradient(135deg, #BFBBBB, #e8e6e6); color: #1a1a1a; }
.crypto-icon--USDT { background: linear-gradient(135deg, #26A17B, #4dc999); }

.asset-cell { display: flex; align-items: center; gap: 10px; }
.asset-name { font-family: var(--font-display); font-weight: 500; font-size: 14px; }
.asset-symbol { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); margin-top: 1px; text-transform: uppercase; }

/* =====================================================================
   TRADING TERMINAL SPECIFIC
   ===================================================================== */
.terminal {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  min-height: calc(100vh - var(--topbar-h) - 48px);
}
.terminal-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.terminal-pair {
  display: flex;
  align-items: center;
  gap: 12px;
}
.terminal-pair-info { display: flex; flex-direction: column; }
.terminal-pair-name { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.terminal-pair-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); }
.terminal-price {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  font-feature-settings: 'tnum';
  letter-spacing: -0.015em;
}
.terminal-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.terminal-stat-label { font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.08em; }
.terminal-stat-value { font-family: var(--font-mono); font-size: 13px; font-weight: 500; margin-top: 2px; }

.terminal-chart {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  min-height: 480px;
  position: relative;
}
.chart-controls {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.chart-tf {
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  transition: all 0.15s;
}
.chart-tf.active, .chart-tf:hover { color: var(--text-primary); border-color: var(--accent); }
.chart-tf.active { background: rgba(255,107,26,0.12); }
.chart-canvas-wrap {
  position: relative;
  height: 420px;
}
.chart-canvas-wrap canvas { width: 100%; height: 100%; }

.order-panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.side-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--bg-deepest);
  padding: 3px;
  border-radius: var(--radius);
}
.side-tab {
  padding: 9px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 13px;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.side-tab.active.buy  { background: var(--up); color: #0a0a0a; }
.side-tab.active.sell { background: var(--down); color: #fff; }

.type-tabs {
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.type-tab {
  color: var(--text-tertiary);
  padding-bottom: 6px;
  border-bottom: 1px solid transparent;
}
.type-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }

.amount-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.amount-presets button {
  padding: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.amount-presets button:hover { color: var(--text-primary); background: var(--bg-card-hover); }

.order-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-family: var(--font-mono);
}
.order-row-label { color: var(--text-tertiary); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }

.orderbook {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.orderbook-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 3px 6px;
  position: relative;
  border-radius: 3px;
}
.orderbook-row .right { text-align: right; }
.orderbook-row .center { text-align: center; color: var(--text-tertiary); }
.orderbook-bar {
  position: absolute;
  top: 0; bottom: 0; right: 0;
  opacity: 0.08;
  pointer-events: none;
}
.orderbook-bar--buy  { background: var(--up); }
.orderbook-bar--sell { background: var(--down); }
.orderbook-spread {
  display: flex;
  justify-content: space-between;
  padding: 8px 6px;
  border-block: 1px solid var(--line);
  margin: 6px 0;
  font-size: 13px;
}

/* =====================================================================
   DASHBOARD-SPECIFIC LAYOUT
   ===================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.kpi-label { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.08em; }
.kpi-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 8px 0 4px;
  font-feature-settings: 'tnum';
}
.kpi-sub { font-family: var(--font-mono); font-size: 12px; color: var(--text-tertiary); }

.split-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 12px;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 1100px) {
  .terminal { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 64px; }
  .sidebar { padding: 16px 8px; }
  .sidebar .logo span:not(.logo-mark) { display: none; }
  .sidebar .logo { justify-content: center; }
  .side-nav a { justify-content: center; padding: 10px; }
  .side-nav a span:not(.logo-mark) { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .split-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .topbar-search { display: none; }
  .avatar-mail { display: none; }
  .content { padding: 16px; }
}

/* =====================================================================
   UTILITIES
   ===================================================================== */
.shimmer {
  background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-card-hover) 50%, var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes flash-up { 0% { background: var(--up-soft); } 100% { background: transparent; } }
@keyframes flash-down { 0% { background: var(--down-soft); } 100% { background: transparent; } }
.flash-up { animation: flash-up 0.6s ease-out; }
.flash-down { animation: flash-down 0.6s ease-out; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.15); }
}
.live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--up);
  animation: pulse 1.8s ease-in-out infinite;
  box-shadow: 0 0 8px var(--up);
  margin-right: 6px;
  vertical-align: middle;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
