/* ====================================
   Whale Analyzer — Shared Components
   ==================================== */

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-lg);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  border: var(--border-width) solid var(--border-bold);
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: all var(--transition-fast);
}
.btn:hover {
  box-shadow: var(--shadow-btn-hover);
  transform: translate(-1px, -1px);
}
.btn:active {
  box-shadow: 1px 1px 0px var(--border-bold);
  transform: translate(1px, 1px);
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-ghost {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2xs);
  padding: var(--sp-2xs) var(--sp-sm);
  border-radius: var(--radius-pill);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-extrabold);
  letter-spacing: 0.02em;
  border: 1.5px solid;
}
.badge-green { background: var(--color-green-dim); color: var(--color-green); border-color: var(--color-green); }
.badge-red { background: var(--color-red-dim); color: var(--color-red); border-color: var(--color-red); }
.badge-blue { background: var(--color-blue-dim); color: var(--color-blue); border-color: var(--color-blue); }
.badge-yellow { background: var(--color-orange-dim); color: var(--color-orange); border-color: var(--color-orange); }
.badge-orange { background: var(--color-orange-dim); color: var(--color-orange); border-color: var(--color-orange); }
.badge-purple { background: var(--color-purple-dim); color: var(--color-purple); border-color: var(--color-purple); }

/* ── Generic Cards ── */
.card {
  background: var(--bg-card);
  border: var(--border-width-bold) solid var(--border-bold);
  border-radius: var(--radius-lg);
  padding: var(--sp-xl);
  box-shadow: var(--shadow-card);
}
.card-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-extrabold);
  margin-bottom: var(--sp-xs);
}
.card-subtitle {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.data-table thead th {
  text-align: left;
  padding: var(--sp-md) var(--sp-lg);
  font-size: var(--fs-xs);
  font-weight: var(--fw-extrabold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: var(--border-width) solid var(--border-bold);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 2;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.data-table thead th:hover { color: var(--text-primary); }
.data-table thead th .sort-arrow {
  margin-left: var(--sp-2xs);
  opacity: 0.3;
}
.data-table thead th.sorted .sort-arrow {
  opacity: 1;
  color: var(--text-primary);
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-fast);
}
.data-table tbody tr:hover {
  background: var(--accent-dim);
}
.data-table tbody td {
  padding: var(--sp-md) var(--sp-lg);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.data-table .ticker-cell {
  font-weight: var(--fw-extrabold);
  color: var(--text-primary);
  cursor: pointer;
}
.data-table .ticker-cell:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
.data-table .sector-cell {
  color: var(--text-tertiary);
  font-size: var(--fs-xs);
  line-height: 1.35;
  min-width: 150px;
}
.data-table .sector-cell span {
  display: block;
  color: var(--text-secondary);
  font-weight: var(--fw-semibold);
}
.data-table .holding-industry {
  margin-top: 2px;
  color: var(--text-muted);
}
.data-table .positive { color: var(--color-green); font-weight: var(--fw-bold); }
.data-table .negative { color: var(--color-red); font-weight: var(--fw-bold); }
.data-table .text-right { text-align: right; }

/* ── Table wrapper ── */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: var(--border-width-bold) solid var(--border-bold);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

/* ── Spinner ── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: var(--sp-xl);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: #FFFFFF;
  padding: var(--sp-md) var(--sp-xl);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  box-shadow: var(--shadow-card);
  border: var(--border-width) solid var(--border-bold);
  z-index: var(--z-toast);
  opacity: 0;
  transition: all var(--transition-base);
  pointer-events: none;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-lg);
}
.kpi-card {
  background: var(--bg-card);
  border: var(--border-width-bold) solid var(--border-bold);
  border-radius: var(--radius-lg);
  padding: var(--sp-xl);
  text-align: center;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}
.kpi-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-card-hover);
}
.kpi-label {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-sm);
}
.kpi-value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-black);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.kpi-value.accent {
  background: var(--accent);
  padding: 0 var(--sp-sm);
  border-radius: var(--radius-sm);
  display: inline;
}
.kpi-value.green { color: var(--color-green); }
.kpi-value.red { color: var(--color-red); }
.kpi-sub {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-top: var(--sp-xs);
}

/* ── Chart Legend ── */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-md);
  justify-content: center;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--text-secondary);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--border-bold);
}

/* ── Heatmap ── */
.heatmap-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  padding: var(--sp-lg);
}
.heatmap-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-bold);
  padding: var(--sp-md);
  flex: 1 1 80px;
  min-width: 60px;
  text-align: center;
  transition: all var(--transition-fast);
  cursor: pointer;
  background: var(--bg-secondary);
}
.heatmap-cell:hover {
  transform: translate(-2px, -2px);
  box-shadow: 3px 3px 0px var(--border-bold);
}
.cell-ticker {
  font-size: var(--fs-sm);
  font-weight: var(--fw-extrabold);
}
.cell-change {
  font-size: var(--fs-2xs);
  color: var(--text-tertiary);
  margin-top: var(--sp-2xs);
}

/* ── Tab Bar ── */
.tab-bar {
  display: flex;
  gap: var(--sp-xs);
  margin-bottom: var(--sp-xl);
  background: var(--bg-secondary);
  border: var(--border-width-bold) solid var(--border-bold);
  border-radius: var(--radius-pill);
  padding: var(--sp-2xs) var(--sp-xs);
  box-shadow: var(--shadow-card-sm);
  overflow-x: auto;
  width: fit-content;
}
.tab-btn {
  padding: var(--sp-sm) var(--sp-xl);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text-tertiary);
  border-radius: var(--radius-pill);
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.tab-btn.active {
  color: var(--accent-text);
  background: var(--accent);
}
