/* ==========================================
   📈 MARKET LIVE PAGE STYLES
   Trading Platform Pro - Market Live
   ========================================== */

/* ==========================================
   Layout
   ========================================== */
.market-live-page {
  padding: 0 !important;
  padding-bottom: 120px !important;
  overflow-y: auto;
}

@media (min-width: 768px) {
  .market-live-page {
    padding-left: 260px !important;
  }
}

/* ==========================================
   IHSG Summary Bar
   ========================================== */
.ml-ihsg-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card, #1e1e22);
  border-bottom: 1px solid var(--border-color, #2a2a2e);
}

.ml-ihsg-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ml-ihsg-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary-orange, #f97316);
  letter-spacing: 0.5px;
}

.ml-ihsg-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #fff);
}

.ml-ihsg-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.ml-ihsg-change.positive {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.12);
}

.ml-ihsg-change.negative {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

.ml-ihsg-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

.ml-ihsg-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.ml-stat-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted, #71717a);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ml-stat-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #a1a1aa);
}

.ml-stat-value.positive { color: #22c55e; }
.ml-stat-value.negative { color: #ef4444; }

.ml-ihsg-kurs {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-orange, #f97316);
  background: rgba(249, 115, 22, 0.12);
  padding: 4px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.2s;
}

.ml-ihsg-kurs:hover {
  background: rgba(249, 115, 22, 0.25);
}

/* ==========================================
   IDX Indices Grid
   ========================================== */
.ml-indices-section {
  padding: 10px 12px 8px;
  margin-top: 6px;
  border-bottom: 1px solid var(--border-color, #2a2a2e);
  overflow: hidden;
}

.ml-indices-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-orange, #f97316);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px 10px;
}

.ml-indices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 8px;
}

.ml-indices-col {
  display: flex;
  flex-direction: column;
}

/* Index row */
.ml-idx-row {
  display: grid;
  grid-template-columns: 55px 1fr 50px 46px;
  align-items: center;
  padding: 6px 4px;
  font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.15s;
}

.ml-idx-row:hover {
  background: rgba(255,255,255,0.04);
}

.ml-idx-row:last-child {
  border-bottom: none;
}

.ml-idx-name {
  font-weight: 600;
  color: var(--text-primary, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ml-idx-last {
  text-align: right;
  font-weight: 600;
  color: var(--text-primary, #fff);
  font-variant-numeric: tabular-nums;
}

.ml-idx-chg {
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.ml-idx-pct {
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.ml-idx-chg.positive, .ml-idx-pct.positive { color: #22c55e; }
.ml-idx-chg.negative, .ml-idx-pct.negative { color: #ef4444; }
.ml-idx-chg.neutral, .ml-idx-pct.neutral { color: var(--text-muted, #71717a); }

/* Index skeleton */
.ml-idx-skeleton {
  height: 24px;
  background: linear-gradient(90deg, var(--bg-elevated, #27272a) 25%, rgba(255,255,255,0.06) 50%, var(--bg-elevated, #27272a) 75%);
  background-size: 200% 100%;
  animation: mlShimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 4px;
}

@keyframes mlShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================
   Stock List Section
   ========================================== */
.ml-stock-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ml-stock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-card, #1e1e22);
  border-bottom: 1px solid var(--border-color, #2a2a2e);
}

.ml-stock-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary, #fff);
}

.ml-stock-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ml-action-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-color, #2a2a2e);
  border-radius: 6px;
  color: var(--text-muted, #71717a);
  cursor: pointer;
  transition: all 0.2s;
}

.ml-action-btn:hover {
  color: var(--text-primary, #fff);
  border-color: var(--text-secondary, #a1a1aa);
}

.ml-action-btn.active {
  background: var(--primary-orange, #f97316);
  border-color: var(--primary-orange, #f97316);
  color: white;
}

/* ==========================================
   Stock Table (sticky CODE + LAST)
   ========================================== */
.ml-table-container {
  flex: 1;
  overflow: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.ml-stock-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.ml-stock-table thead {
  position: sticky;
  top: 0;
  z-index: 20;
}

.ml-stock-table th {
  padding: 6px 8px;
  background: var(--bg-elevated, #27272a);
  color: var(--text-muted, #71717a);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-color, #2a2a2e);
  user-select: none;
}

.ml-stock-table th.col-code {
  text-align: left;
  min-width: 65px;
}

.ml-stock-table th.col-last {
  min-width: 60px;
}

.ml-stock-table td {
  padding: 5px 8px;
  text-align: right;
  white-space: nowrap;
  color: var(--text-secondary, #a1a1aa);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.ml-stock-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

.ml-stock-table tbody tr:hover {
  background: rgba(255,255,255,0.04);
}

.ml-stock-table tbody tr:active {
  background: rgba(249, 115, 22, 0.1);
}

/* Sticky columns */
.sticky-col {
  position: sticky;
  z-index: 10;
  background: var(--bg-dark, #18181b);
}

.ml-stock-table thead .sticky-col {
  background: var(--bg-elevated, #27272a);
  z-index: 25;
}

.sticky-col.col-code {
  left: 0;
}

.sticky-col.col-last {
  left: 65px;
  box-shadow: 2px 0 8px rgba(0,0,0,0.3);
}

/* Code cell styling */
.ml-code-cell {
  display: flex;
  align-items: center;
  gap: 5px;
  text-align: left;
}

.ml-code-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ml-code-dot.up { background: #22c55e; }
.ml-code-dot.down { background: #ef4444; }
.ml-code-dot.flat { background: var(--text-muted, #71717a); }

.ml-code-text {
  font-weight: 700;
  color: var(--text-primary, #fff);
  font-size: 11px;
}

/* Value colors */
.ml-val-pos { color: #22c55e !important; }
.ml-val-neg { color: #ef4444 !important; }
.ml-val-zero { color: var(--text-muted, #71717a) !important; }
.ml-val-last { 
  font-weight: 700; 
  color: var(--text-primary, #fff); 
}

/* ==========================================
   Loading / Error states
   ========================================== */
.ml-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--text-muted, #71717a);
  font-size: 13px;
}

.ml-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-color, #2a2a2e);
  border-top-color: var(--primary-orange, #f97316);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.ml-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--text-muted, #71717a);
  font-size: 13px;
}

.ml-retry-btn {
  padding: 8px 20px;
  background: var(--primary-orange, #f97316);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.ml-retry-btn:hover {
  opacity: 0.85;
}

/* ==========================================
   Bottom Stock Tabs
   ========================================== */
.ml-stock-tabs {
  position: fixed;
  bottom: 66px; /* above bottom-nav with spacing */
  left: 0;
  right: 0;
  z-index: 90;
  background: var(--bg-card, #1e1e22);
  border-top: 1px solid var(--border-color, #2a2a2e);
  padding: 0;
}

@media (min-width: 768px) {
  .ml-stock-tabs {
    left: 260px;
  }
}

.ml-tabs-scroll {
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.ml-tabs-scroll::-webkit-scrollbar {
  display: none;
}

.ml-tab-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-right: 1px solid rgba(255,255,255,0.06);
  color: var(--text-secondary, #a1a1aa);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.ml-tab-btn:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary, #fff);
}

.ml-tab-btn.active {
  background: var(--primary-orange, #f97316);
  color: white;
}

.ml-tab-fav {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--primary-orange, #f97316);
}

.ml-tab-fav.active {
  background: var(--primary-orange, #f97316);
  color: white;
}

.ml-tab-all {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--primary-orange, #f97316);
  font-weight: 700;
}

.ml-tab-all.active {
  background: var(--primary-orange, #f97316);
  color: white;
}

/* Load More Button */
.ml-load-more-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px dashed rgba(249, 115, 22, 0.3);
  border-radius: 0;
  color: var(--primary-orange, #f97316);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.ml-load-more-btn:hover {
  background: rgba(249, 115, 22, 0.2);
}

.ml-load-more-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* Extra padding for market live page main content */
.market-live-page {
  padding-bottom: 130px !important; /* bottom-nav + stock-tabs */
}

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 380px) {
  .ml-ihsg-stats {
    display: none;
  }
  
  .ml-idx-row {
    grid-template-columns: 50px 1fr 50px 45px;
    font-size: 10px;
  }
}

@media (min-width: 768px) {
  .ml-idx-row {
    grid-template-columns: 80px 1fr 70px 60px;
    font-size: 12px;
    padding: 5px 8px;
  }
  
  .ml-stock-table {
    font-size: 12px;
  }
  
  .ml-stock-table th {
    font-size: 11px;
    padding: 8px 10px;
  }
  
  .ml-stock-table td {
    padding: 6px 10px;
  }
}

/* ==========================================
   📈 LIVE TICK FLASH ANIMATIONS
   Price flash for real-time updates
   ========================================== */
.price-flash-up {
  color: #22c55e !important;
  text-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  transition: color 0.15s, text-shadow 0.15s;
}
.price-flash-down {
  color: #ef4444 !important;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
  transition: color 0.15s, text-shadow 0.15s;
}
.ml-ihsg-value.tick-up { color: #22c55e !important; text-shadow: 0 0 8px rgba(34, 197, 94, 0.5); }
.ml-ihsg-value.tick-down { color: #ef4444 !important; text-shadow: 0 0 8px rgba(239, 68, 68, 0.5); }
.ml-val-last { font-variant-numeric: tabular-nums; transition: color 0.3s, text-shadow 0.3s; }
.ml-ihsg-value { font-variant-numeric: tabular-nums; transition: color 0.3s, text-shadow 0.3s; }
