/* Stocks index — Audit Ledger theme.
   Flat hairline cards, mono figures, ledger rank tags.
   No gradients, no gloss, no entrance animations. */

.stocks-page {
  background: var(--bg-main);
  min-height: 100vh;
}

/* ============ Hero ============ */
.stocks-hero {
  background: var(--bg-main);
  border-top: 1px solid var(--border);
  padding: 4.5rem 0 3.5rem;
  position: relative;
}

.stocks-hero::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.stocks-hero .hero-title {
  margin: 0 0 1rem;
  font-size: clamp(2.2rem, 4vw, 3.5rem);
}

.stocks-hero .lead {
  margin: 0;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.65;
  max-width: 58ch;
}

/* ============ Top stocks grid ============ */
.stocks-list {
  padding: 3.5rem 0 1.5rem;
}

.stock-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.stock-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1.75rem 1.5rem 1.5rem;
  transition: border-color 0.2s ease;
}

.stock-card:hover {
  border-color: var(--text-muted);
}

.stock-card-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border-light);
}

/* Ledger entry number — gold for the top entry, no medals */
.stock-rank {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.3rem 0.55rem;
  flex-shrink: 0;
}

.stock-rank::before {
  content: '№ ';
  color: var(--text-dim);
}

.stock-card:first-child .stock-rank {
  color: var(--secondary);
  border-color: var(--secondary);
}

.stock-info {
  min-width: 0;
}

.stock-info h3 {
  margin: 0 0 0.2rem;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-bright);
}

.stock-info .sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0 0 1.5rem;
}

.stock-metrics > div {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.5rem;
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 2px;
}

.stock-metrics dt {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.45rem;
}

.stock-metrics dd {
  margin: auto 0 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-bright);
  line-height: 1.2;
}

.stock-card-actions {
  margin-top: auto;
  display: flex;
}

.stock-card-actions .btn {
  flex: 1;
}

/* ============ Empty state (shared with asset show tabs) ============ */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.empty-message {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 0.5rem;
}

.empty-hint {
  color: var(--text-muted);
  margin: 0;
}

@media (max-width: 768px) {
  .stocks-hero {
    padding: 3.25rem 0 2.5rem;
  }

  .stocks-list {
    padding: 2.5rem 0 1rem;
  }

  .stock-cards {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .stock-card {
    padding: 1.5rem 1.25rem 1.25rem;
  }

  .stock-metrics {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .stock-metrics > div {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    text-align: left;
    padding: 0.7rem 0.9rem;
  }

  .stock-metrics dt {
    margin-bottom: 0;
  }

  .stock-metrics dd {
    margin: 0;
  }
}


/* Section titles — flat audit-ledger labels with a primary tick */
.analysis-detail .section-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.analysis-detail .section-title::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  background: var(--primary);
  flex-shrink: 0;
}

/* Titles inside card headers must not inherit the in-card separator
   (home.css adds margin-top/border-top to .analysis-detail .section-title) */
.analysis-detail .section-header .section-title,
.analysis-detail .price-header .section-title {
  margin: 0;
  padding: 0;
  border: none;
}

/* Add spacing between analysis cards on the show page */
.analyses-section .analysis-detail-card {
  margin-bottom: 2rem;
}

.analyses-section .analysis-detail-card:last-child {
  margin-bottom: 0;
}

/* Influencer Sentiment Section */
.influencer-sentiment {
  display: flex;
  gap: 2rem;
  justify-content: center;
}

.sentiment-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  background: var(--bg-surface);
  border-radius: 2px;
  border: 1px solid var(--border);
  flex: 1;
  max-width: 280px;
  transition: border-color 0.2s ease;
}

.sentiment-item:hover {
  border-color: var(--text-muted);
}

.sentiment-item.sentiment-buy {
  border-left: 3px solid var(--success);
}

.sentiment-item.sentiment-sell {
  border-left: 3px solid var(--danger);
}

.sentiment-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 2px;
  flex-shrink: 0;
}

.sentiment-buy .sentiment-icon {
  background: rgba(93, 169, 122, 0.12);
  border: 1px solid rgba(93, 169, 122, 0.35);
  color: var(--success);
}

.sentiment-sell .sentiment-icon {
  background: rgba(194, 95, 76, 0.12);
  border: 1px solid rgba(194, 95, 76, 0.35);
  color: var(--danger);
}

.sentiment-icon svg {
  width: 24px;
  height: 24px;
}

.sentiment-data {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sentiment-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text-bright);
}

.sentiment-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.sentiment-period-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.45rem 0.9rem;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

@media (max-width: 768px) {
  .influencer-sentiment {
    flex-direction: column;
    gap: 1rem;
  }

  .sentiment-item {
    max-width: none;
    padding: 1.25rem 1.5rem;
  }

  .sentiment-count {
    font-size: 1.75rem;
  }

  .sentiment-icon {
    width: 40px;
    height: 40px;
  }

  .sentiment-icon svg {
    width: 20px;
    height: 20px;
  }
}

/* ============ Stock search — flat ledger lookup ============ */
.stock-search-section {
  margin-top: 2rem;
  padding: 3.5rem 0 4.5rem;
  border-top: 1px solid var(--border);
}

.stock-search-section h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-bright);
}

.stock-search-section .lead {
  margin: 0 0 1.75rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.stock-search-container {
  position: relative;
  max-width: 600px;
}

.stock-search-input {
  width: 100%;
  padding: 0.9rem 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg-surface);
  color: var(--text-bright);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stock-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--ring);
}

.stock-search-input::placeholder {
  color: var(--text-dim);
}

/* Autocomplete results */
.autocomplete-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 2px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
  max-height: 400px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 100;
}

.autocomplete-results.show {
  opacity: 1;
  visibility: visible;
}

.autocomplete-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s ease;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--bg-highlight);
  box-shadow: inset 2px 0 0 var(--primary);
}

.autocomplete-ticker {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-bright);
  min-width: 80px;
}

.autocomplete-details {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.autocomplete-name {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-exchange {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.2rem 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

/* Scrollbar styling */
.autocomplete-results::-webkit-scrollbar {
  width: 8px;
}

.autocomplete-results::-webkit-scrollbar-track {
  background: var(--bg-surface);
}

.autocomplete-results::-webkit-scrollbar-thumb {
  background: var(--border);
}

.autocomplete-results::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

@media (max-width: 768px) {
  .stock-search-section {
    margin-top: 1.5rem;
    padding: 2.5rem 0 3.5rem;
  }

  .stock-search-section h2 {
    font-size: 1.5rem;
  }

  .autocomplete-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .autocomplete-details {
    justify-content: flex-start;
  }

  .autocomplete-name {
    text-align: left;
  }
}

/* ===========================
   Asset Detail Tabs
   =========================== */

.asset-tabs {
  display: flex;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.asset-tab {
  flex: 1;
  padding: 0.9rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

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

.asset-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.asset-tab-panel {
  display: none;
}

.asset-tab-panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================
   Influencers Tab Styles
   =========================== */

.influencers-table-wrapper {
  overflow-x: auto;
}

.influencers-table {
  width: 100%;
  border-collapse: collapse;
}

.influencers-table th {
  padding: 1rem;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}

.influencers-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.influencers-table tbody tr:hover {
  background: var(--bg-highlight);
}

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

.rank-col {
  width: 60px;
  text-align: center;
}

.influencer-col {
  min-width: 200px;
}

.recommendations-col {
  width: 150px;
  text-align: center;
}

.actions-col {
  width: 140px;
  text-align: right;
}

.influencer-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-radius: 2px;
  border: 1px solid var(--border);
}

.influencer-cell {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.influencer-avatar-small {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-highlight);
}

.influencer-avatar-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-fallback-small {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-highlight);
}

.influencer-name {
  font-weight: 600;
  color: var(--text-bright);
}

.buy-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.875rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--success);
  background: rgba(93, 169, 122, 0.12);
  border: 1px solid rgba(93, 169, 122, 0.35);
  border-radius: 2px;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

/* Mobile Card View for Influencers */
.influencers-cards {
  display: none;
}

.influencer-rank-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  margin-bottom: 0.75rem;
  transition: border-color 0.2s ease;
}

.influencer-rank-card:hover {
  border-color: var(--text-muted);
}

.influencer-rank-card:last-child {
  margin-bottom: 0;
}

.influencer-rank-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.influencer-rank-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.influencer-rank-info .influencer-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.buy-count-label {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 500;
}

/* ===========================
   Analyses Tab Styles
   =========================== */

.analyses-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.analysis-item-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.analysis-item-card:hover {
  border-color: var(--text-muted);
}

.analysis-item-content {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
}

.analysis-item-thumbnail {
  position: relative;
  width: 200px;
  height: 112px;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-highlight);
}

.analysis-item-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.analysis-item-thumbnail .play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.analysis-item-thumbnail:hover .play-overlay {
  opacity: 1;
}

.analysis-item-thumbnail .play-overlay svg {
  width: 48px;
  height: 48px;
  color: white;
}

.analysis-item-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.analysis-item-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.4;
}

.analysis-item-title a {
  color: var(--text-bright);
  text-decoration: none;
  transition: color 0.2s ease;
}

.analysis-item-title a:hover {
  color: var(--primary);
}

.analysis-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
}

.analysis-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.author-avatar-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-highlight);
}

.author-avatar-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.author-name {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.author-name a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.author-name a:hover {
  color: var(--primary);
}

.analysis-date {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.analysis-date svg {
  width: 16px;
  height: 16px;
}

.analysis-item-actions {
  margin-top: auto;
}

/* ===========================
   Empty State Enhancements
   =========================== */

.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 1.5rem;
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  border-radius: 2px;
}

.empty-icon svg {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
}

.empty-hint {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

/* ===========================
   Responsive Styles
   =========================== */

@media (max-width: 768px) {
  .asset-tab {
    padding: 0.875rem 0.5rem;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
  }

  .influencers-table-wrapper {
    display: none;
  }

  .influencers-cards {
    display: block;
  }

  .analysis-item-content {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }

  .analysis-item-thumbnail {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .analysis-item-title {
    font-size: 1rem;
  }

  .analysis-item-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}

@media (max-width: 480px) {
  .asset-tab {
    padding: 0.75rem 0.25rem;
    font-size: 0.65rem;
  }

  .influencer-rank-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .influencer-rank-card .btn {
    width: 100%;
    text-align: center;
  }

  .analysis-item-actions .btn {
    width: 100%;
    text-align: center;
  }
}
