/* ═══════════════════════════════════════
   Stock Live — Market Dashboard Styles
   ═══════════════════════════════════════ */

/* ===== BREADCRUMB ===== */
.stock-breadcrumb {
  padding: 0.75rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stock-breadcrumb a {
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.stock-breadcrumb a:hover {
  color: var(--primary);
}

.stock-breadcrumb .separator {
  color: var(--border-light);
}

.stock-breadcrumb .current {
  color: var(--primary);
  font-weight: 600;
}

/* ===== TRENDING TICKER BAR ===== */
.trending-ticker-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  height: 56px;
  margin-bottom: 1.5rem;
  position: relative;
}

.trending-label {
  flex-shrink: 0;
  background: #16a34a;
  color: white;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  margin-left: 0.5rem;
  z-index: 2;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
}

.trending-label::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 4px solid #16a34a;
}

.trending-track-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.trending-track-wrapper::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 80px;
  background: linear-gradient(90deg, transparent, var(--bg-card));
  z-index: 1;
  pointer-events: none;
}

.trending-track {
  display: flex;
  align-items: center;
  white-space: nowrap;
  animation: trending-scroll 40s linear infinite;
  padding: 0 0.5rem;
  width: max-content;
}

.trending-track:hover {
  animation-play-state: paused;
}

@keyframes trending-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.trending-stock {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  height: 56px;
  border-right: 1px solid var(--border);
  cursor: default;
  transition: background var(--transition-fast);
}

.trending-stock:hover {
  background: rgba(249, 115, 22, 0.04);
}

.trending-stock-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trending-stock-symbol {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}

.trending-stock-price {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.trending-stock-change {
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 3px;
}

.trending-stock-change.up { color: #16a34a; }
.trending-stock-change.down { color: #dc2626; }
.trending-stock-change.neutral { color: var(--text-muted); }

.trending-stock-change .arrow {
  font-size: 0.65rem;
}

.trending-view-btn {
  flex-shrink: 0;
  margin: 0 1rem;
  z-index: 2;
}

.trending-view-btn a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  background: var(--bg-card);
  border: 2px solid var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0.5rem 1.25rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.trending-view-btn a:hover {
  background: var(--text-primary);
  color: white;
}

.trending-view-btn .market-status {
  font-size: 0.65rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.trending-view-btn .market-status .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.trending-view-btn .market-status .status-dot.open {
  background: #16a34a;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.trending-view-btn .market-status .status-dot.closed {
  background: #dc2626;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== STOCK LIVE HEADER ===== */
.stock-live-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.stock-live-title h2 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.stock-live-title .stock-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stock-market-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.stock-market-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.stock-market-status .status-dot.open {
  background: #16a34a;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.stock-market-status .status-dot.closed {
  background: #dc2626;
}

.stock-market-status.open { color: #16a34a; }
.stock-market-status.closed { color: #dc2626; }

/* ===== SECTOR INDEX CARDS ===== */
.sector-cards-wrapper {
  overflow-x: auto;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
}

.sector-cards-wrapper::-webkit-scrollbar {
  height: 4px;
}

/* scrollbar-width fallback handled by webkit scrollbar above */

.sector-cards-wrapper::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

.sector-cards {
  display: flex;
  gap: 1rem;
  min-width: max-content;
}

.sector-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  min-width: 220px;
  max-width: 260px;
  flex: 1;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.sector-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.sector-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.sector-card-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sector-card-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.sector-card-change-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.sector-card-turnover {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.sector-card-change {
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sector-card-change.up { color: #16a34a; }
.sector-card-change.down { color: #dc2626; }
.sector-card-change.neutral { color: var(--text-muted); }

.sector-card-arrow {
  font-size: 1rem;
}

.sector-card-arrow.up { color: #16a34a; }
.sector-card-arrow.down { color: #dc2626; }

.sector-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

.sector-card-stat {
  text-align: center;
  flex: 1;
}

.sector-card-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.2rem;
}

.sector-card-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Advance/decline progress bar */
.sector-ad-bar {
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
  background: var(--bg-tertiary);
}

.sector-ad-advance {
  background: #16a34a;
  transition: width var(--transition);
}

.sector-ad-decline {
  background: #dc2626;
  transition: width var(--transition);
}

/* ===== MARKET DISTRIBUTION BAR ===== */
.market-distribution {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.distribution-segments {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.distribution-segment {
  flex: 1;
  padding: 1rem 0.75rem;
  text-align: center;
  border-right: 1px solid var(--border);
  transition: all var(--transition);
  cursor: default;
}

.distribution-segment:last-child {
  border-right: none;
}

.distribution-segment:hover {
  background: rgba(0, 0, 0, 0.02);
}

.distribution-segment-label {
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.distribution-segment-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.distribution-segment-count strong {
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 700;
}

/* Segment colors */
.dist-below-5 .distribution-segment-label { color: #dc2626; }
.dist-neg5-3 .distribution-segment-label { color: #ea580c; }
.dist-neg3-0 .distribution-segment-label { color: #d97706; }
.dist-0-3 .distribution-segment-label { color: #16a34a; }
.dist-3-5 .distribution-segment-label { color: #0d9488; }
.dist-above-5 .distribution-segment-label { color: #2563eb; }

/* ===== LIVE TRADING SECTION ===== */
.live-trading-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.live-trading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.live-trading-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.live-trading-title h3 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
}

.live-trading-title .live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #dcfce7;
  color: #16a34a;
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-xl);
  font-size: 0.75rem;
  font-weight: 600;
}

.live-trading-title .live-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.live-trading-search {
  position: relative;
}

.live-trading-search input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.5rem 1rem 0.5rem 2.2rem;
  border-radius: var(--radius-xl);
  font-size: 0.85rem;
  width: 220px;
  font-family: inherit;
  transition: all var(--transition);
}

.live-trading-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
  width: 280px;
}

.live-trading-search .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== TRADING TABLE ===== */
.trading-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.trading-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.trading-table thead {
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.trading-table th {
  padding: 0.85rem 1rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background var(--transition-fast);
  white-space: nowrap;
}

.trading-table th:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.trading-table th .sort-icon {
  margin-left: 4px;
  font-size: 0.65rem;
  opacity: 0.5;
}

.trading-table th.sort-active .sort-icon {
  opacity: 1;
  color: var(--primary);
}

.trading-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.trading-table tbody tr {
  transition: background var(--transition-fast);
}

.trading-table tbody tr:hover {
  background: rgba(249, 115, 22, 0.03);
}

.trading-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.015);
}

.trading-table tbody tr:nth-child(even):hover {
  background: rgba(249, 115, 22, 0.04);
}

/* Ticker cell */
.ticker-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ticker-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.ticker-icon.banking { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.ticker-icon.insurance { background: linear-gradient(135deg, #a855f7, #7e22ce); }
.ticker-icon.telecom { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.ticker-icon.hydropower { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.ticker-icon.manufacturing { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.ticker-icon.finance { background: linear-gradient(135deg, #f59e0b, #d97706); }
.ticker-icon.other { background: linear-gradient(135deg, #94a3b8, #64748b); }

.ticker-info .ticker-sym {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.ticker-info .ticker-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Price columns */
.td-price {
  font-weight: 600;
  color: var(--text-primary);
}

.td-change.up { color: #16a34a; font-weight: 600; }
.td-change.down { color: #dc2626; font-weight: 600; }
.td-change.neutral { color: var(--text-muted); }

.td-change .change-arrow {
  font-size: 0.7rem;
  margin-left: 3px;
}

/* Add to watchlist button */
.watchlist-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.watchlist-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* No results */
.no-results-row td {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== LOADING STATE ===== */
.stock-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
  gap: 0.75rem;
  font-size: 0.9rem;
}

.stock-loading .spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== MARKET SUMMARY BANNER ===== */
.market-summary-banner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.summary-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #f97316);
  opacity: 0.7;
}

.summary-stat:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.summary-stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.summary-stat-label i {
  color: var(--primary);
  font-size: 0.7rem;
}

.summary-stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.summary-stat-change {
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.summary-stat-change.up { color: #16a34a; }
.summary-stat-change.down { color: #dc2626; }
.summary-stat-change.neutral { color: var(--text-muted); }

.summary-stat-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ===== TOP GAINERS & LOSERS ===== */
.gainers-losers-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.gl-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition);
}

.gl-card:hover {
  box-shadow: var(--shadow-md);
}

.gl-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.gl-card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gainers-card .gl-card-header h3 i { color: #16a34a; }
.losers-card .gl-card-header h3 i { color: #dc2626; }

.gainers-card { border-top: 3px solid #16a34a; }
.losers-card { border-top: 3px solid #dc2626; }

.gl-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-xl);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gainer-badge {
  background: #dcfce7;
  color: #16a34a;
}

.loser-badge {
  background: #fef2f2;
  color: #dc2626;
}

.gl-table-wrapper {
  max-height: 400px;
  overflow-y: auto;
}

.gl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.gl-table thead {
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.gl-table th {
  padding: 0.65rem 0.75rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.gl-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.gl-table tbody tr {
  transition: background var(--transition-fast);
}

.gl-table tbody tr:hover {
  background: rgba(249, 115, 22, 0.03);
}

.gl-symbol-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gl-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.gl-symbol {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.gl-name {
  font-size: 0.7rem;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gl-price {
  font-weight: 600;
  color: var(--text-primary);
}

.gl-change {
  font-weight: 600;
}

.gl-change.up { color: #16a34a; }
.gl-change.down { color: #dc2626; }

.gl-empty {
  text-align: center;
  padding: 2rem !important;
  color: var(--text-muted);
  font-style: italic;
}


/* ===== STOCK PAGE WRAPPER ===== */
.stock-page-content {
  padding: 0 0 3rem 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .market-summary-banner {
    grid-template-columns: repeat(3, 1fr);
  }

  .sector-card {
    min-width: 190px;
  }

  .distribution-segment {
    padding: 0.75rem 0.5rem;
  }

  .distribution-segment-label {
    font-size: 0.7rem;
  }
}

@media (max-width: 768px) {
  .market-summary-banner {
    grid-template-columns: repeat(2, 1fr);
  }

  .gainers-losers-section {
    grid-template-columns: 1fr;
  }

  .summary-stat-value {
    font-size: 1.1rem;
  }

  .trending-ticker-bar {
    height: 48px;
  }

  .trending-label {
    font-size: 0.75rem;
    padding: 0.4rem 0.75rem;
  }

  .trending-stock {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }

  .trending-stock-name {
    display: none;
  }

  .trending-view-btn a {
    font-size: 0.7rem;
    padding: 0.4rem 0.75rem;
  }

  .stock-live-title h2 {
    font-size: 1.4rem;
  }

  .live-trading-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .live-trading-search input {
    width: 100%;
  }

  .distribution-segments {
    flex-wrap: wrap;
  }

  .distribution-segment {
    flex: 1 1 calc(33.333% - 1px);
    border-bottom: 1px solid var(--border);
  }

  .sector-card {
    min-width: 170px;
  }

  .trading-table th,
  .trading-table td {
    padding: 0.6rem 0.75rem;
    font-size: 0.82rem;
  }
}

@media (max-width: 480px) {
  .trending-ticker-bar {
    height: 42px;
  }

  .trending-view-btn {
    display: none;
  }

  .stock-live-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .sector-card {
    min-width: 160px;
  }

  .distribution-segment {
    flex: 1 1 50%;
  }
}
