/* ═══════════════════════════════════════════════════════
   REYA WALLET DASHBOARD – styles.css
   Dark monochrome, sharp edges, responsive
   ═══════════════════════════════════════════════════════ */

/* ── Custom Properties ── */
:root {
  --bg: #0a0a0a;
  --bg-2: #111111;
  --bg-3: #181818;
  --bg-4: #1e1e1e;
  --border: #2a2a2a;
  --border-hi: #3a3a3a;
  --text: #f0f0f0;
  --text-dim: #888888;
  --text-muted: #555555;
  --accent: #d0d0d0;
  --green: #22c55e;
  --red: #ef4444;
  --green-dim: rgba(34, 197, 94, 0.12);
  --red-dim: rgba(239, 68, 68, 0.12);
  --font: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Mono', 'Courier New', monospace;
  --radius: 1px;
  --footer-h: 42px;
  --header-h: 56px;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--footer-h) + 8px);
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-2);
}
::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: var(--radius);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ══════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  height: auto;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
  height: var(--header-h);
  flex-wrap: wrap;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-logo {
  width: 18px;
  height: 18px;
  display: block;
}

.brand-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text);
  white-space: nowrap;
}

/* Wallet form */
.wallet-form {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

#walletInput {
  flex: 1;
  min-width: 0;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

#walletInput:focus {
  border-color: var(--border-hi);
}

#walletInput::placeholder {
  color: var(--text-muted);
}

#walletSubmit {
  background: var(--text);
  color: var(--bg);
  border: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 6px 14px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: opacity 0.15s;
  white-space: nowrap;
}

#walletSubmit:hover {
  opacity: 0.85;
}

.btn-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 9px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: border-color 0.15s, color 0.15s;
}

.btn-clear:hover {
  border-color: var(--border-hi);
  color: var(--text);
}

.lang-select {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: border-color 0.15s, color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.lang-select:hover {
  border-color: var(--border-hi);
  color: var(--text);
}

.lang-select option {
  background: var(--bg);
  color: var(--text);
}

/* WS Status pill */
.ws-status {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  white-space: nowrap;
  flex-shrink: 0;
}

.ws-idle {
  color: var(--text-muted);
  border-color: var(--border);
}

.ws-connecting {
  color: #f59e0b;
  border-color: #f59e0b44;
}

.ws-live {
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.35);
}

.ws-error {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.35);
}

.ws-rest {
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.35);
}

/* Wallet error */
.wallet-error {
  font-size: 11px;
  color: var(--red);
  padding: 3px 16px;
  min-height: 0;
  transition: all 0.15s;
}

/* Trade Link */
.trade-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--green);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 14px;
  text-decoration: none;
  border-radius: var(--radius);
  transition: opacity 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.trade-link:hover {
  opacity: 0.85;
}

/* ══════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════ */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* ── Idle State ── */
.idle-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: calc(100vh - var(--header-h) - var(--footer-h) - 60px);
  padding: 20px 0;
}

.idle-inner {
  text-align: center;
  max-width: 480px;
}

.idle-icon {
  font-size: 48px;
  opacity: 0.15;
  margin-bottom: 24px;
}

.idle-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.idle-sub {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 16px;
}

.idle-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.idle-hint code {
  font-family: var(--mono);
  background: var(--bg-4);
  padding: 1px 5px;
  border: 1px solid var(--border);
}

/* ── Loading State ── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: calc(100vh - var(--header-h) - var(--footer-h) - 40px);
  color: var(--text-dim);
  font-size: 13px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--bg-2);
  padding: 18px 20px;
  transition: background 0.15s;
}

.kpi-card:hover {
  background: var(--bg-3);
}

.kpi-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.kpi-label em {
  font-style: normal;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 22px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.kpi-value.positive {
  color: var(--green);
}

.kpi-value.negative {
  color: var(--red);
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ── Status Bar ── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 0 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.wallet-display {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ── Tab Nav ── */
.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  border-radius: 0;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  background: var(--bg-4);
  color: var(--text-dim);
  font-size: 9px;
  font-family: var(--mono);
  margin-left: 6px;
  vertical-align: middle;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.tab-btn.active .tab-badge {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.tab-badge:empty {
  display: none;
}

/* ── Tab Panels ── */
.tab-panel {
  margin-top: 0;
}

.panel-subtitle {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
  padding-top: 16px;
  padding-left: 2px;
}

.split-tables {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.split-tables-col {
  flex: 1;
  min-width: 300px;
}

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-top: none;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table thead {
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
}

.data-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px;
  white-space: nowrap;
}

.data-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--bg-3);
}

/* Empty row */
.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 14px;
  font-family: var(--font);
  font-size: 12px;
}

/* Side chips */
.chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: var(--radius);
}

.chip-long,
.chip-buy {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.chip-short,
.chip-sell {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.chip-deposit {
  background: rgba(96, 165, 250, 0.1);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.3);
}

.chip-withdrawal {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.chip-transfer {
  background: var(--bg-4);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

/* PnL colors */
td.pnl-pos,
span.pnl-pos,
div.pnl-pos,
.pnl-pos {
  color: var(--green) !important;
}

td.pnl-neg,
span.pnl-neg,
div.pnl-neg,
.pnl-neg {
  color: var(--red) !important;
}

td.pnl-zero,
span.pnl-zero,
div.pnl-zero,
.pnl-zero {
  color: var(--text-dim) !important;
}

/* AI Report Cards */
.ai-report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.ai-report-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-report-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.ai-report-rank {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-report-rank span.icon {
  color: #f59e0b;
}

.ai-report-wallet {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
  padding: 4px 0;
}

.ai-report-wallet:hover {
  color: var(--text);
  text-decoration: underline;
}

.ai-report-points {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
}

.ai-report-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--bg-2);
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.ai-metric {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  background: var(--bg);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.ai-metric span {
  color: var(--text-muted);
  margin-right: 4px;
}

.ai-report-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  margin-top: 4px;
}

/* Tx hash link */
.tx-link {
  color: var(--text-dim);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 11px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.tx-link:hover {
  color: var(--text);
  border-bottom-color: var(--border-hi);
}

/* ══════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════ */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-h);
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  z-index: 100;
}

.site-footer a {
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--border-hi);
  transition: color 0.15s, border-color 0.15s;
}

.site-footer a:hover {
  color: var(--text);
  border-bottom-color: var(--text);
}

@media (max-width: 768px) {
  .split-tables {
    flex-direction: column;
    gap: 32px;
  }

  .split-tables-col {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .header-inner {
    gap: 8px;
    padding: 6px 12px;
    height: auto;
  }

  .brand-name {
    display: none;
  }

  .wallet-form {
    flex: 1;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-value {
    font-size: 18px;
  }

  .tab-btn {
    padding: 10px 12px;
    font-size: 10px;
  }

  .main-content {
    padding: 12px 10px;
  }
}

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

/* ── Utility ── */
.mono {
  font-family: var(--mono);
}

.dim {
  color: var(--text-dim);
}

/* ──────────────────────────────────────────────────────
   WEEKLY VOLUME SUMMARY
   ────────────────────────────────────────────────────── */
.vol-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0 24px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.vol-stat {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.vol-stat-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  min-width: 200px;
}

.vol-stat-value {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
}

/* ──────────────────────────────────────────────────────
   HEALTH FACTOR COLORS
   ────────────────────────────────────────────────────── */
.health-safe {
  color: var(--green);
}

.health-warn {
  color: #f59e0b;
}

.health-danger {
  color: var(--red);
}

/* ──────────────────────────────────────────────────────
   TABLE ACTIONS
   ────────────────────────────────────────────────────── */
.table-actions button {
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ──────────────────────────────────────────────────────
   RECENT WALLETS
   ────────────────────────────────────────────────────── */
.recent-wallets {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.recent-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  font-weight: 600;
}

.recent-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.recent-pill {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.1s;
}

.recent-pill:hover {
  color: var(--text);
  border-color: var(--border-hi);
  background: var(--bg-3);
}

/* ──────────────────────────────────────────────────────
   ANALYTICS & CHART
   ────────────────────────────────────────────────────── */
.analytics-container {
  padding: 24px 0;
}

.chart-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.chart-wrapper {
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 20px;
  height: 400px;
  position: relative;
}

/* ──────────────────────────────────────────────────────
   PAGINATION
   ────────────────────────────────────────────────────── */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding-bottom: 24px;
}

.page-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 32px;
  text-align: center;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--border-hi);
  color: var(--text);
  background: var(--bg-3);
}

.page-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ──────────────────────────────────────────────────────
   DATE INPUTS
   ────────────────────────────────────────────────────── */
.date-input {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 6px;
  outline: none;
  border-radius: var(--radius);
}

.date-input:focus {
  border-color: var(--border-hi);
}

/* ──────────────────────────────────────────────────────
   COFFEE MODAL & BUTTON
   ────────────────────────────────────────────────────── */
.coffee-btn {
  background: rgba(212, 175, 55, 0.1);
  color: #d4af37;
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 10px;
}

.coffee-btn:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: #d4af37;
  color: #fff;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  animation: fadeIn 0.2s forwards;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  padding: 30px;
  width: 90%;
  max-width: 450px;
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  transform: translateY(20px);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
  to { transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text);
}

.btn-copy:hover {
  border-color: var(--text-dim) !important;
  color: #fff !important;
}