/* ============================================================
   SIM LIVE STUDIO - LIVE DISPLAY STYLESHEET
   Mobile-first, fluid responsive for TikTok LIVE Studio resizing
   ============================================================ */

:root {
  /* Fluid base typography scales smoothly when resizing in TikTok LIVE Studio */
  --stt-font: clamp(11px, 2.85vw, 17px);
  --num-font: clamp(14px, 4.35vw, 25px);
  --cell-font: clamp(11px, 3.05vw, 18px);
  --badge-font: clamp(9.5px, 2.45vw, 14px);
  --header-font: clamp(10.5px, 2.8vw, 16px);
  --marquee-font: clamp(13px, 3.6vw, 21px);
  --logo-h: clamp(14px, 3.7vw, 23px);
  --row-pad-y: clamp(4px, 1.15vw, 8px);

  /* Palette */
  --bg-outer: #0d1b3e;
  --board-bg: #ffffff;
  --row-alt: #f4f8ff;
  --row-border: #e5edf8;
  --pinned-bg: #fffdf2;
  --pinned-alt: #fff7db;
  --pinned-border: #fde68a;

  --num-blue: #102a83;
  --num-red: #e11d2e;
  --pkg-green: #15803d;
  --price-red: #c81e1e;
  --stt-color: #1e293b;

  /* Element (Mệnh) colors */
  --menh-kim: linear-gradient(135deg, #9aa4b2, #6b7280);
  --menh-moc: linear-gradient(135deg, #10b981, #047857);
  --menh-thuy: linear-gradient(135deg, #0ea5e9, #0369a1);
  --menh-hoa: linear-gradient(135deg, #ef4444, #b91c1c);
  --menh-tho: linear-gradient(135deg, #f59e0b, #c2410c);
  --menh-other: linear-gradient(135deg, #94a3b8, #64748b);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-outer);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
}

.live-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #09132b 0%, #10234d 100%);
  padding: clamp(3px, 0.9vw, 8px);
  gap: clamp(3px, 0.8vw, 6px);
  overflow: hidden;
}

/* ============================================================
   TOP MARQUEE BAR (Slow Left-to-Right)
   ============================================================ */
.marquee-bar {
  flex: 0 0 auto;
  width: 100%;
  overflow: hidden;
  background: linear-gradient(90deg, #050a18 0%, #0b1838 50%, #050a18 100%);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: clamp(6px, 1.6vw, 10px);
  padding: clamp(4px, 1vw, 7px) 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.marquee-bar.hidden {
  display: none;
}

.marquee-track {
  display: flex;
  width: max-content;
  will-change: transform;
  animation: marquee-ltr var(--marquee-duration, 24s) linear infinite;
}

.marquee-item {
  white-space: nowrap;
  padding-right: clamp(36px, 10vw, 80px);
  font-size: var(--marquee-font);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #5eead4;
  text-shadow: 0 0 8px rgba(45, 212, 191, 0.45);
}

@keyframes marquee-ltr {
  0% {
    transform: translate3d(-50%, 0, 0);
  }
  100% {
    transform: translate3d(0%, 0, 0);
  }
}

/* ============================================================
   MAIN BOARD CARD
   ============================================================ */
.board-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--board-bg);
  border-radius: clamp(8px, 2vw, 14px);
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(2, 8, 28, 0.45);
  border: 1.5px solid rgba(59, 130, 246, 0.45);
}

/* Shared 5-column grid layout */
.sim-grid {
  display: grid;
  grid-template-columns: 10% 39% 17% 16% 18%;
  align-items: center;
  width: 100%;
}

/* Table Headers */
.table-header {
  flex: 0 0 auto;
  padding: clamp(5px, 1.3vw, 9px) clamp(2px, 0.7vw, 6px);
  color: #ffffff;
  font-size: var(--header-font);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.header-pinned {
  background: linear-gradient(90deg, #0047ab 0%, #1d4ed8 55%, #0284c7 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.header-main {
  background: linear-gradient(90deg, #0055b8 0%, #0284c7 60%, #0369a1 100%);
  border-top: 1.5px solid #dbeafe;
  border-bottom: 1.5px solid #0284c7;
}

.th {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

/* ============================================================
   SECTION 1: PINNED SIMS (SỐ ĐANG HOT)
   Font-size strictly +2px larger than main table below!
   ============================================================ */
.section-pinned {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  max-height: 44%;
}

.pinned-body {
  overflow-y: auto;
  scrollbar-width: none;
}

.pinned-body::-webkit-scrollbar {
  display: none;
}

.pinned-empty {
  text-align: center;
  padding: clamp(6px, 1.5vw, 10px) 8px;
  font-size: clamp(11px, 2.8vw, 15px);
  color: #64748b;
  font-style: italic;
  background: #f8fafc;
}

.sim-row.is-pinned-row {
  background: var(--pinned-bg);
  border-bottom: 1px solid var(--pinned-border);
  padding: clamp(5px, 1.3vw, 9px) clamp(2px, 0.7vw, 6px);
  position: relative;
}

.sim-row.is-pinned-row:nth-child(even) {
  background: var(--pinned-alt);
}

.sim-row.is-pinned-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #f59e0b, #ef4444);
}

/* Exact +2px font-size bump on all pinned values */
.sim-row.is-pinned-row .col-stt {
  font-size: calc(var(--stt-font) + 2px);
  color: #b45309;
}

.sim-row.is-pinned-row .col-num {
  font-size: calc(var(--num-font) + 2px);
}

.sim-row.is-pinned-row .col-price {
  font-size: calc(var(--cell-font) + 2px);
  color: var(--price-red);
  font-weight: 900;
}

.sim-row.is-pinned-row .menh-pill {
  font-size: calc(var(--badge-font) + 2px);
  padding: 0.22em 0.62em;
}

.sim-row.is-pinned-row .carrier-logo {
  height: calc(var(--logo-h) + 2px);
}

/* ============================================================
   SECTION 2: MAIN AUTO-SCROLLING SIM TABLE
   ============================================================ */
.section-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--board-bg);
}

.scroll-viewport {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: var(--board-bg);
}

.scroll-track {
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.sim-list {
  display: flex;
  flex-direction: column;
}

.sim-list.hidden {
  display: none;
}

.sim-row {
  padding: var(--row-pad-y) clamp(2px, 0.7vw, 6px);
  border-bottom: 1px solid var(--row-border);
  background: var(--board-bg);
  transition: background-color 0.15s ease;
  cursor: pointer;
}

.sim-row:nth-child(even) {
  background: var(--row-alt);
}

.sim-row:hover {
  background: #e8f1ff;
}

/* Column 1: STT */
.col-stt {
  text-align: center;
  font-size: var(--stt-font);
  font-weight: 700;
  color: var(--stt-color);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Column 2: SIM NUMBER */
.col-num {
  text-align: center;
  font-size: var(--num-font);
  font-weight: 900;
  color: var(--num-blue);
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

.col-num .hl-red {
  color: var(--num-red);
}

/* Column 3: GÓI KM (Main) -> Hover swaps to GIÁ BÁN */
.col-mid {
  text-align: center;
  font-size: var(--cell-font);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

.col-pkg {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pkg-green);
  min-height: 1.75em;
  border-radius: 6px;
  transition: background-color 0.14s ease, transform 0.14s ease;
}

.col-pkg .val-pkg {
  display: inline-block;
  color: var(--pkg-green);
  font-weight: 800;
}

.col-pkg .val-price {
  display: none;
  color: #ffffff;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  padding: 0.14em 0.45em;
  border-radius: 6px;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.35);
}

.col-pkg:hover .val-pkg,
.col-pkg.show-price .val-pkg {
  display: none;
}

.col-pkg:hover .val-price,
.col-pkg.show-price .val-price {
  display: inline-block;
}

/* Column 4: MỆNH (Rounded colored pill) */
.col-menh {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
}

.menh-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.3em;
  padding: 0.2em 0.55em;
  border-radius: 999px;
  font-size: var(--badge-font);
  font-weight: 800;
  line-height: 1.15;
  color: #ffffff;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
  white-space: nowrap;
}

.menh-kim { background: var(--menh-kim); }
.menh-moc { background: var(--menh-moc); }
.menh-thuy { background: var(--menh-thuy); }
.menh-hoa { background: var(--menh-hoa); }
.menh-tho { background: var(--menh-tho); }
.menh-other { background: var(--menh-other); }

/* Column 5: SÓNG (Carrier SVG logo) */
.col-song {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 clamp(2px, 0.6vw, 6px);
}

.carrier-logo {
  display: block;
  height: var(--logo-h);
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

/* Empty list state */
.empty-list {
  padding: 36px 16px;
  text-align: center;
  color: #64748b;
  font-size: clamp(13px, 3.2vw, 17px);
}

/* ============================================================
   RESPONSIVE REFINEMENTS (Very narrow or very wide resize)
   ============================================================ */
@media (max-width: 340px) {
  .sim-grid {
    grid-template-columns: 9% 40% 17% 16% 18%;
  }
  .menh-pill {
    min-width: 3.7em;
    padding: 0.18em 0.35em;
  }
}

@media (min-width: 640px) {
  .live-shell {
    padding: 8px;
    gap: 6px;
  }
  .sim-grid {
    grid-template-columns: 9% 38% 17% 17% 19%;
  }
}
