/* =========================================================================
   Crypto Suite — frontend stylesheet (Phase 5a)
   All rules are scoped under `.cs-root` so the host theme can never leak
   styles into the plugin output (and vice-versa).
   ========================================================================= */

.cs-root {
  --cs-bg: #ffffff;
  --cs-bg-soft: #f8fafc;
  --cs-bg-muted: #f1f5f9;
  --cs-border: #e2e8f0;
  --cs-text: #0f172a;
  --cs-text-soft: #475569;
  --cs-text-muted: #94a3b8;
  --cs-primary: #2563eb;
  --cs-primary-soft: #dbeafe;
  --cs-success: #10b981;
  --cs-success-soft: #d1fae5;
  --cs-danger: #ef4444;
  --cs-danger-soft: #fee2e2;
  --cs-radius: 10px;
  --cs-radius-lg: 16px;
  --cs-shadow: 0 1px 2px rgba(15, 23, 42, .04);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  color: var(--cs-text);
  font-size: 15px;
  line-height: 1.5;
  box-sizing: border-box;
}
.cs-root *, .cs-root *::before, .cs-root *::after { box-sizing: border-box; }

.cs-mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.cs-right { text-align: right; }
.cs-up    { color: var(--cs-success); font-weight: 600; }
.cs-down  { color: var(--cs-danger);  font-weight: 600; }

/* ----- Coin cell ----- */
.cs-coin-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  color: inherit;
  text-decoration: none;
}
a.cs-coin-cell.cs-coin-cell-link {
  cursor: pointer;
  transition: color .15s;
}
a.cs-coin-cell.cs-coin-cell-link:hover .cs-coin-name {
  color: var(--cs-primary);
}
a.cs-coin-cell.cs-coin-cell-link:focus-visible {
  outline: 2px solid var(--cs-primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.cs-coin-logo {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--cs-bg-muted);
}
.cs-coin-fallback {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--cs-primary-soft);
  color: var(--cs-primary);
  font-weight: 700;
  flex-shrink: 0;
}
.cs-coin-meta { display: inline-flex; flex-direction: column; line-height: 1.2; }
.cs-coin-name   { font-weight: 600; }
.cs-coin-symbol { font-size: 12px; color: var(--cs-text-muted); text-transform: uppercase; letter-spacing: .03em; }

/* ----- Sparkline ----- */
.cs-sparkline      { width: 120px; height: 40px; display: inline-block; vertical-align: middle; }
.cs-sparkline-up   polyline { stroke: var(--cs-success); }
.cs-sparkline-down polyline { stroke: var(--cs-danger);  }
.cs-sparkline-empty { color: var(--cs-text-muted); font-size: 14px; }
.cs-table .cs-th-spark,
.cs-table .cs-td-spark { min-width: 130px; }

/* ============== List Table widget ============== */
.cs-list-table {
  background: #fff;
  border: 1px solid var(--cs-border);
  border-radius: var(--cs-radius-lg);
  overflow: hidden;
  box-shadow: var(--cs-shadow);
}
.cs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--cs-border);
  flex-wrap: wrap;
}
.cs-tabs { display: flex; gap: 4px; }
.cs-tab {
  appearance: none;
  border: 0;
  background: var(--cs-bg-muted);
  color: var(--cs-text-soft);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.cs-tab:hover { color: var(--cs-text); }
.cs-tab.cs-tab-active { background: var(--cs-primary); color: #fff; }

.cs-search { display: flex; align-items: center; min-width: 220px; }
.cs-search input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--cs-border);
  border-radius: var(--cs-radius);
  font-size: 14px;
  outline: none;
  background: var(--cs-bg-soft);
  color: var(--cs-text);
}
.cs-search input:focus { border-color: var(--cs-primary); background: #fff; }

.cs-table-wrap { overflow-x: auto; }
.cs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.cs-table thead th {
  text-align: center;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--cs-text-muted);
  background: var(--cs-bg-soft);
  padding: 5px;
  border-bottom: 1px solid var(--cs-border);
  white-space: nowrap;
}
/* Name column header keeps left-alignment to line up with the coin name cell. */
.cs-table thead th.cs-th-name { text-align: left; }
.cs-table thead th[data-cs-sort] { cursor: pointer; user-select: none; }
.cs-table thead th[data-cs-sort]:hover { color: var(--cs-text); }
.cs-table thead th.cs-sort-asc::after  { content: " ▲"; font-size: 10px; }
.cs-table thead th.cs-sort-desc::after { content: " ▼"; font-size: 10px; }
.cs-table tbody td {
  padding: 5px;
  border-bottom: 1px solid var(--cs-border);
  vertical-align: middle;
  text-align: center;
}
/* Coin name column keeps left-alignment so the logo + name read naturally. */
.cs-table tbody td.cs-td-name { text-align: left; }
.cs-table tbody tr:hover { background: var(--cs-bg-soft); }
.cs-table tbody tr:last-child td { border-bottom: 0; }

.cs-empty {
  padding: 32px;
  text-align: center;
  color: var(--cs-text-muted);
}

.cs-pagination {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--cs-border);
}
.cs-page-btn {
  appearance: none;
  border: 1px solid var(--cs-border);
  background: #fff;
  padding: 6px 14px;
  border-radius: var(--cs-radius);
  font-size: 13px;
  cursor: pointer;
  color: var(--cs-text-soft);
}
.cs-page-btn:hover:not(:disabled) { border-color: var(--cs-primary); color: var(--cs-primary); }
.cs-page-btn:disabled { opacity: .4; cursor: not-allowed; }
.cs-page-info { font-size: 13px; color: var(--cs-text-muted); }

/* ============== Top coins (compact, no pagination) ============== */
.cs-top-coins-title {
  margin: 0 0 14px;
  padding: 0 18px;
  padding-top: 14px;
  font-size: 18px;
  font-weight: 700;
  color: var(--cs-text);
}
.cs-top-coins-view-all {
  display: block;
  text-align: center;
  padding: 14px;
  border-top: 1px solid var(--cs-border);
  font-size: 14px;
  font-weight: 600;
  color: var(--cs-primary);
  text-decoration: none;
  transition: background .15s;
}
.cs-top-coins-view-all:hover { background: var(--cs-bg-soft); }

/* ============== Top list (gainers/losers) ============== */
.cs-top-list {
  background: #fff;
  border: 1px solid var(--cs-border);
  border-radius: var(--cs-radius-lg);
  padding: 18px 20px;
  box-shadow: var(--cs-shadow);
}
.cs-top-title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
}
.cs-top-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cs-top-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--cs-border);
}
.cs-top-item:last-child { border-bottom: 0; }
.cs-top-rank {
  color: var(--cs-text-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.cs-top-price  { font-weight: 600; font-size: 13px; min-width: 80px; text-align: right; }
.cs-top-change { font-size: 13px; min-width: 70px; text-align: right; }
.cs-top-empty {
  padding: 20px; text-align: center;
  color: var(--cs-text-muted);
  background: var(--cs-bg-soft);
  border-radius: var(--cs-radius); border: 1px dashed var(--cs-border);
}

/* Live-update flash (used by Phase 5b live-price.js) */
.cs-flash-up   { animation: cs-flash-up   .8s ease; }
.cs-flash-down { animation: cs-flash-down .8s ease; }
@keyframes cs-flash-up   { 0% { background: var(--cs-success-soft); } 100% { background: transparent; } }
@keyframes cs-flash-down { 0% { background: var(--cs-danger-soft);  } 100% { background: transparent; } }

@media (max-width: 640px) {
  /* Keep <thead> visible on mobile — `.cs-table-wrap` already enables
     horizontal scrolling for narrow viewports. */
  .cs-table thead th { font-size: 10px; }
  .cs-table tbody td { font-size: 13px; }
}
