/* ============================
   MTFX — Global Styles
   ============================ */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1629;
  --bg-card: #141d35;
  --bg-card-hover: #1a2540;
  --bg-input: #0d1525;
  --border: #1e2d4a;
  --border-light: #243352;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59,130,246,0.15);
  --green: #10b981;
  --green-bg: rgba(16,185,129,0.1);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.1);
  --yellow: #f59e0b;
  --yellow-bg: rgba(245,158,11,0.1);
  --purple: #8b5cf6;
  --purple-bg: rgba(139,92,246,0.1);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.3);
  --transition: all 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ====== TYPOGRAPHY ====== */
h1, h2, h3, h4, h5, h6 { color: var(--text-primary); font-weight: 600; line-height: 1.3; }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.375rem; }
h4 { font-size: 1.125rem; }

.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-accent { color: var(--accent); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace; }

/* ====== LAYOUT ====== */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-4 { gap: 16px; }
.gap-2 { gap: 8px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }
.grid { display: grid; }
.w-full { width: 100%; }

/* ====== CARDS ====== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-light); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

/* ====== BUTTONS ====== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; border: none;
  transition: var(--transition); white-space: nowrap; user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 0 20px var(--accent-glow); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-light); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ====== FORMS ====== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 14px; transition: var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text-muted); }
.form-input.error { border-color: var(--red); }
.form-error { color: var(--red); font-size: 12px; margin-top: 4px; }
.form-hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.input-group { position: relative; }
.input-group .form-input { padding-right: 44px; }
.input-group-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); cursor: pointer;
}
.input-group-btn:hover { color: var(--text-primary); }

/* ====== BADGES ====== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 100px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-blue { background: var(--accent-glow); color: var(--accent); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* ====== TABLES ====== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border); background: var(--bg-secondary);
  white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid rgba(30,45,74,0.5); font-size: 13px; }
tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--bg-card-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ====== TABS ====== */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px; background: none; border: none;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  cursor: pointer; transition: var(--transition);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ====== MODALS ====== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; width: 100%;
  max-width: 480px; max-height: 90vh; overflow-y: auto;
  transform: translateY(20px); transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: var(--text-primary); }

/* ====== TOAST NOTIFICATIONS ====== */
#toast-container {
  position: fixed; top: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--border);
  min-width: 280px; max-width: 380px; box-shadow: var(--shadow);
  animation: slideIn 0.3s ease; font-size: 13px;
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.warning { border-color: var(--yellow); }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-msg { flex: 1; color: var(--text-primary); }
.toast-close { background: none; border: none; color: var(--text-muted); cursor: pointer; margin-left: 8px; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
.toast.hiding { animation: slideOut 0.3s ease forwards; }

/* ====== NAV ====== */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,14,26,0.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: 60px; display: flex; align-items: center;
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700; color: var(--text-primary);
}
.navbar-brand .logo-icon {
  width: 32px; height: 32px; background: var(--accent);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: white; font-weight: 800;
}
.navbar-links { display: flex; align-items: center; gap: 4px; }
.navbar-links a, .navbar-links button.nav-link {
  padding: 6px 14px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  border: none; background: none; transition: var(--transition);
}
.navbar-links a:hover, .navbar-links button.nav-link:hover,
.navbar-links a.active, .navbar-links button.nav-link.active {
  color: var(--text-primary); background: var(--bg-card);
}
.navbar-user { display: flex; align-items: center; gap: 12px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white; cursor: pointer;
}

/* ====== SIDEBAR ====== */
.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
  width: 220px; background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 20px 12px; flex-shrink: 0;
}
.sidebar-group { margin-bottom: 24px; }
.sidebar-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; padding: 0 12px; margin-bottom: 6px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  transition: var(--transition); cursor: pointer; border: none;
  background: none; width: 100%; text-align: left;
}
.sidebar-link:hover { color: var(--text-primary); background: var(--bg-card); }
.sidebar-link.active { color: var(--accent); background: var(--accent-glow); }
.sidebar-link svg, .sidebar-link .icon { width: 16px; height: 16px; flex-shrink: 0; }
.main-content { flex: 1; overflow: auto; padding: 24px; }

/* ====== STATS GRID ====== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ====== LOADING ====== */
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; background: rgba(10,14,26,0.8); border-radius: inherit;
}

/* ====== EMPTY STATE ====== */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-text { font-size: 14px; }

/* ====== PRICE COLORS ====== */
.price-up { color: var(--green) !important; }
.price-down { color: var(--red) !important; }
.price-neutral { color: var(--text-secondary) !important; }

/* ====== ORDER BOOK ====== */
.orderbook-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  padding: 4px 12px; font-size: 12px; font-family: monospace;
  position: relative; cursor: default; border-radius: 2px;
}
.orderbook-row .depth-bar {
  position: absolute; top: 0; bottom: 0; right: 0;
  opacity: 0.12; border-radius: 2px;
}
.orderbook-bid .depth-bar { background: var(--green); }
.orderbook-ask .depth-bar { background: var(--red); }

/* ====== CHART PLACEHOLDER ====== */
.chart-container {
  background: var(--bg-secondary); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
}
.chart-placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 13px; min-height: 300px;
}

/* ====== PAGE HEADER ====== */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 10px; }

/* ====== SELECT ====== */
.form-select {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 14px; transition: var(--transition); outline: none; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 36px;
}
.form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ====== UTILS ====== */
.hidden { display: none !important; }
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-4 { padding: 16px; }
.rounded { border-radius: var(--radius); }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ====== TICKER TAPE ====== */
.ticker-tape {
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  overflow: hidden; height: 36px; position: relative;
}
.ticker-tape-inner {
  display: flex; gap: 32px; align-items: center; height: 100%;
  animation: scrollLeft 40s linear infinite;
  white-space: nowrap;
}
@keyframes scrollLeft { from { transform: translateX(100%); } to { transform: translateX(-100%); } }
.ticker-item { display: flex; gap: 8px; align-items: center; font-size: 12px; }
.ticker-symbol { font-weight: 600; color: var(--text-secondary); }
.ticker-price { color: var(--text-primary); font-family: monospace; }

/* ====== GLOW EFFECTS ====== */
.glow-green { box-shadow: 0 0 12px rgba(16,185,129,0.25); }
.glow-red { box-shadow: 0 0 12px rgba(239,68,68,0.25); }
.glow-blue { box-shadow: 0 0 12px var(--accent-glow); }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .container { padding: 0 16px; }
  h1 { font-size: 1.75rem; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
