/*
 * derivatives.css
 * Extends /assets/exchanges.css with derivatives-specific styles.
 * exchanges.css is NOT imported here — both files are loaded independently.
 * All base styles (ticker, header, table, pagination, footer…) are copied
 * from exchanges.css so this file is fully self-contained.
 */

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

:root {
  --bg:        #0a0c12;
  --surface:   #111420;
  --border:    #1e2235;
  --border2:   #252840;
  --text:      #e8eaf6;
  --muted:     #6b7280;
  --accent:    #5b6ef5;
  --accent2:   #00d4aa;
  --red:       #ff4d6d;
  --green:     #00d4aa;
  --yellow:    #f5c842;
  --radius:    12px;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-sans: 'IBM Plex Sans', sans-serif;
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: clip;
}
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(91,110,245,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91,110,245,.04) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

/* ── Global Ticker ───────────────────────────────────────────────────────── */
.global-ticker {
  position: relative;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  height: 36px;
  z-index: 100;
}
.global-ticker-inner {
  display: flex;
  align-items: center;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 40px;
  scroll-behavior: smooth;
}
.global-ticker-inner::-webkit-scrollbar { display: none; }
.ticker-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 16px;
  height: 100%;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 12px;
  font-family: var(--font-mono);
}
.ticker-item:first-child { border-left: 1px solid var(--border); }
.ticker-label { color: var(--muted); font-size: 11px; }
.ticker-value { color: var(--text); font-weight: 600; font-size: 12px; }
.ticker-change { font-size: 11px; font-weight: 700; }
.ticker-change.up   { color: var(--green); }
.ticker-change.down { color: var(--red); }
.dom-bar {
  display: inline-flex;
  align-items: center;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--border2);
  vertical-align: middle;
}
.dom-segment { height: 100%; flex-shrink: 0; }
.dom-btc { background: var(--yellow); }
.dom-eth { background: #627eea; }
.ticker-arrow-btn {
  position: absolute;
  top: 0; bottom: 0;
  width: 36px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity .2s;
}
.ticker-arrow-btn.hidden { display: none; }
.ticker-arrow-btn svg {
  width: 14px; height: 14px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ticker-arrow-btn:hover svg { stroke: var(--text); }
#tickerArrowLeft  { left: 0;  background: linear-gradient(to right, var(--surface) 60%, transparent); }
#tickerArrowRight { right: 0; background: linear-gradient(to left,  var(--surface) 60%, transparent); }

/* ── Wrapper ─────────────────────────────────────────────────────────────── */
.wrapper {
  position: relative; z-index: 1;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 32px 60px;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 32px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 18px; color: #fff;
}
.logo-text { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); }
.logo-text span { color: var(--accent); }
.header-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: var(--muted); font-family: var(--font-mono);
}
.live-dot { display: inline-flex; align-items: center; gap: 6px; color: var(--green); }
.live-dot::before {
  content: '';
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:.5; transform:scale(1.4); }
}
.header-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.header-nav {
  display: flex; align-items: center; gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}
.nav-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: all .2s;
  white-space: nowrap;
}
.nav-item:hover { color: var(--text); background: var(--border); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 14px; }
.lang-switcher {
  display: flex; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  overflow: hidden;
  font-size: 12px; font-family: var(--font-mono);
}
.lang-current { padding: 6px 12px; background: var(--accent); color: #fff; font-weight: 700; }
.lang-option  { padding: 6px 12px; color: var(--muted); text-decoration: none; transition: color .2s, background .2s; }
.lang-option:hover { color: var(--text); background: var(--border); }

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header { padding: 28px 0 20px; }
.page-title {
  font-size: 22px; font-weight: 800;
  letter-spacing: -0.3px; margin-bottom: 10px; color: var(--text);
}
.page-subtitle {
  font-size: 13px; color: var(--muted);
  line-height: 1.7; max-width: 860px; font-family: var(--font-mono);
}
.page-subtitle strong { color: var(--text); font-weight: 700; }

/* ── Controls ────────────────────────────────────────────────────────────── */
.controls {
  display: flex; align-items: center; gap: 10px;
  padding: 0 0 20px; flex-wrap: wrap;
}
.rows-select-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 0 4px 0 12px; height: 38px;
  flex-shrink: 0; margin-left: auto;
}
.rows-label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.rows-select-wrap select {
  border: none; background: transparent;
  color: var(--text); font-size: 13px;
  font-family: var(--font-sans); font-weight: 600;
  padding: 0 8px; height: 100%;
  outline: none; cursor: pointer;
}

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
thead { background: rgba(91,110,245,.06); border-bottom: 1px solid var(--border); }
th {
  padding: 12px 16px;
  font-size: 12px; font-weight: 600;
  text-transform: none; letter-spacing: 0;
  color: #ffffff; text-align: left;
  white-space: nowrap; cursor: pointer; user-select: none;
  transition: color .2s;
}
th:hover { color: #ffffff; }
th[data-sort]:hover::after { opacity: .6; border-bottom-color: #ffffff; }
th[data-sort] { position: relative; padding-right: 22px; }
th[data-sort]::after {
  content: '';
  position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent; opacity: 0.2;
}
th.sort-asc::after  { border-bottom-color: #ffffff; margin-top: -2px; opacity: .8; }
th.sort-desc::after { border-top-color:    #ffffff; margin-top:  2px; opacity: .8; }
th.right, td.right   { text-align: right; }
th.center, td.center { text-align: center; }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s; cursor: pointer;
  animation: rowIn .4s ease both;
}
@keyframes rowIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(91,110,245,.05); }
td { padding: 14px 16px; font-size: 13px; vertical-align: middle; white-space: nowrap; }

/* ── Rank ────────────────────────────────────────────────────────────────── */
.rank-cell {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--muted); width: 40px; text-align: center;
}

/* ── Exchange cell ───────────────────────────────────────────────────────── */
.exchange-cell { display: flex; align-items: center; gap: 12px; }
.exchange-logo {
  width: 32px; height: 32px;
  border-radius: 8px; background: var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--accent); overflow: hidden;
}
.exchange-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }
.exchange-name {
  font-weight: 700; font-size: 14px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.exchange-country { font-size: 11px; color: var(--muted); font-family: var(--font-mono); margin-top: 2px; }

/* ── Volume cell (reused for OI too) ────────────────────────────────────── */
.volume-cell { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--text); }

/* ── Tab strip ───────────────────────────────────────────────────────────── */
.tab-strip {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px; gap: 2px;
  overflow-x: auto;
  /* Desktop: hide scrollbar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tab-strip::-webkit-scrollbar { display: none; }

/* Mobile: show a subtle scrollbar under the tab strip */
@media (max-width: 768px) {
  .tab-strip {
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
    padding-bottom: 6px;
    -ms-overflow-style: auto;
  }
  .tab-strip::-webkit-scrollbar {
    display: block;
    height: 3px;
  }
  .tab-strip::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 2px;
  }
  .tab-strip::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 2px;
  }
  .tab-strip::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
  }
}
.tab-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border-radius: 7px; border: none;
  background: none;
  color: var(--muted);
  font-size: 13px; font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer; white-space: nowrap;
  text-decoration: none;
  transition: all .2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--accent); color: #fff; }
.tab-icon { font-size: 15px; }

/* ── Settlement badge ────────────────────────────────────────────────────── */
.settle-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 700; font-family: var(--font-mono);
  white-space: nowrap;
}
.settle-cash { background: rgba(0,212,170,.12); color: #00d4aa; border: 1px solid rgba(0,212,170,.3); }
.settle-coin { background: rgba(245,200,66,.12); color: #f5c842; border: 1px solid rgba(245,200,66,.3); }

/* ── Sortable spark headers ──────────────────────────────────────────────── */
th.spark-cell[data-sort] {
  cursor: pointer;
  position: relative;
  padding-right: 22px;
}
th.spark-cell[data-sort]::after {
  content: '';
  position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  opacity: 0.2;
}
th.spark-cell[data-sort]:hover::after { opacity: 0.6; border-bottom-color: var(--text); }
th.spark-cell.sort-asc::after  { border-bottom-color: var(--text); margin-top: -2px; opacity: .8; }
th.spark-cell.sort-desc::after { border-top-color:    var(--text); margin-top:  2px; opacity: .8; }

/* ── Sparkline cells ─────────────────────────────────────────────────────── */
.spark-cell { width: 130px; padding: 8px 12px; }
.spark-wrap { display: flex; align-items: center; height: 40px; }
.spark-wrap svg { display: block; overflow: visible; }

/* ── Visit button ────────────────────────────────────────────────────────── */
.visit-btn {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border2); border-radius: 6px;
  padding: 5px 12px; font-size: 12px; font-weight: 600;
  color: var(--muted); text-decoration: none;
  transition: all .2s; font-family: var(--font-sans);
}
.visit-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(91,110,245,.08); }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination-wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 28px; flex-wrap: wrap; padding: 0 4px;
}
.pagination-info { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-btn {
  min-width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border2); background: var(--surface);
  color: var(--text); font-size: 13px; font-family: var(--font-mono);
  cursor: pointer; transition: all .2s;
  display: grid; place-items: center; padding: 0 10px;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }
.page-ellipsis { padding: 0 4px; color: var(--muted); font-family: var(--font-mono); font-size: 14px; line-height: 36px; }
.pagination-jump { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.pagination-jump input {
  width: 60px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border2); background: var(--surface);
  color: var(--text); font-size: 12px; font-family: var(--font-mono);
  text-align: center; outline: none; transition: border-color .2s;
  -moz-appearance: textfield;
}
.pagination-jump input::-webkit-outer-spin-button,
.pagination-jump input::-webkit-inner-spin-button { -webkit-appearance: none; }
.pagination-jump input:focus { border-color: var(--accent); }

/* ── Error banner ────────────────────────────────────────────────────────── */
.error-banner {
  background: rgba(255,77,109,.1); border: 1px solid rgba(255,77,109,.3);
  border-radius: var(--radius); padding: 18px 24px; margin: 20px 0;
  display: flex; align-items: flex-start; gap: 12px;
}
.error-icon { font-size: 20px; flex-shrink: 0; }
.error-title { font-weight: 700; color: var(--red); margin-bottom: 4px; }
.error-msg { font-size: 13px; color: var(--muted); font-family: var(--font-mono); }

/* ── Footer nav block ────────────────────────────────────────────────────── */
.footer-nav-block {
  display: flex; gap: 48px;
  padding: 48px 0 40px;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin-top: 32px;
}
.footer-brand-col { flex: 0 0 260px; min-width: 0; }
.footer-brand-name { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 12px; letter-spacing: -0.3px; }
.footer-brand-name span { color: #4f8ef7; }
.footer-brand-desc { font-size: 13px; color: rgba(255,255,255,0.45); line-height: 1.7; margin: 0; }
.footer-links-cols { display: flex; flex: 1; gap: 32px; flex-wrap: wrap; }
.footer-link-group { display: flex; flex-direction: column; gap: 10px; min-width: 130px; }
.footer-link-title { font-size: 13px; font-weight: 600; color: #fff; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.footer-link-group a { font-size: 13px; color: rgba(255,255,255,0.45); text-decoration: none; transition: color .15s; white-space: nowrap; }
.footer-link-group a:hover { color: #4f8ef7; }

/* ── Site footer ─────────────────────────────────────────────────────────── */
.site-footer { margin-top: 48px; padding: 28px 0 40px; border-top: 1px solid var(--border); }
.footer-copyright { font-size: 13px; color: var(--text); font-family: var(--font-mono); margin-bottom: 20px; }
.footer-disclaimer { background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; }
.disclaimer-title { font-size: 12px; font-weight: 700; color: var(--text); font-family: var(--font-mono); letter-spacing: .06em; margin-bottom: 10px; }
.footer-disclaimer p { font-size: 12px; line-height: 1.75; color: var(--muted); font-family: var(--font-mono); }

/* ── Back to top ─────────────────────────────────────────────────────────── */
#backToTop {
  text-decoration: none;
  position: fixed; right: 24px; bottom: 32px; z-index: 999;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border2);
  color: var(--text); cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
  transition: border-color .2s, background .2s;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
#backToTop:hover { background: var(--accent); border-color: var(--accent); }
#backToTop .btt-line { width:14px; height:2px; background:currentColor; border-radius:2px; margin-bottom:2px; }
#backToTop svg { width:14px; height:14px; fill:none; stroke:currentColor; stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
/* col-oi7d and col-vol7d always visible — hidden only via JS sort on very small screens if needed */
@media (max-width: 900px) {
  .header-nav .nav-icon { display: none; }
  .nav-item { padding: 5px 10px; font-size: 12px; }
  td.col-visit { display: none; }
}
@media (max-width: 768px) {
  .wrapper { padding: 0 12px 40px; }
  header { flex-wrap: wrap; padding: 14px 0 16px; gap: 10px; }
  .logo { flex: 1; }
  .header-right { order: 2; margin-left: auto; }
  .header-nav { order: 3; width: 100%; justify-content: center; }
  .header-nav .nav-item { flex: 1; justify-content: center; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { width: 900px; }
  th, td { padding: 10px 10px; }
  /* Rank column: force narrow */
  th:first-child, td:first-child,
  .rank-cell {
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    padding-left: 4px !important;
    padding-right: 4px !important;
    font-size: 11px;
  }
  /* Exchange column: limit width so # stays visible */
  th:nth-child(2), td:nth-child(2) {
    max-width: 160px;
    min-width: 120px;
  }
  .exchange-logo { width: 28px; height: 28px; flex-shrink: 0; }
  .exchange-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
  .exchange-country { font-size: 11px; }
  .pagination-wrap { flex-direction: column; align-items: center; }
  .footer-nav-block { flex-direction: column; gap: 32px; }
  .footer-brand-col { flex: none; }
  .global-ticker-inner { padding: 0 32px; }
}
@media (max-width: 480px) {
  .logo-text { font-size: 17px; }
  .logo-icon { width: 30px; height: 30px; font-size: 14px; }
}
