/* ==========================================================================
   GASTERUS v3 — MARKET PLAY / BETTING PAGE STYLES (CANONICAL CONSOLIDATED)
   Clean, Maintainable, Audit-Ready Architecture (Zero Redundant Overrides)
   ========================================================================== */

/* ==========================================================================
   1. PLAY HEADER & MARKET STATUS
   ========================================================================== */
.play-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-x: clip;
}

.market-meta-info {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.market-meta-title {
  min-width: 0;
  max-width: 100%;
}

.market-meta-title h1 {
  font-size: 1.5rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.brand-logo .brand-logo-img {
  height: 34px;
  max-width: 150px;
}

/* ==========================================================================
   2. MAIN TWO-COLUMN LAYOUT (Grid Form & Betslip)
   ========================================================================== */
.bet-grid-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.quick-bet-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-x: clip;
}

#bet-rows-container {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* ==========================================================================
   3. TOGEL MODE NAVIGATION TABS (Standard 4D/3D/2D, BBFS, Fast Bet)
   ========================================================================== */
.togel-mode-nav {
  display: flex;
  gap: 8px;
  margin-bottom: var(--space-4);
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.mode-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: #94a3b8;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.mode-tab-btn:hover {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  color: #ffffff;
  border-color: #64748b;
  transform: translateY(-1px);
}

.mode-tab-btn.active {
  background: linear-gradient(180deg, #0284c7 0%, #1d4ed8 100%);
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.mode-tab-btn .tab-icon {
  font-size: 1.05rem;
}

/* ==========================================================================
   4. BBFS (BOLAK BALIK FULL SET) GENERATOR PANEL
   ========================================================================== */
.bbfs-panel-card {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.9) 100%);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: var(--space-4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.bbfs-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  border-bottom: 1px solid #334155;
  padding-bottom: 10px;
}

.bbfs-title {
  font-size: 1.08rem;
  font-weight: 800;
  color: #38bdf8;
  margin: 0 0 4px;
}

.bbfs-subtitle {
  font-size: 0.8rem;
  color: #94a3b8;
  margin: 0;
  line-height: 1.4;
}

.bbfs-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bbfs-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bbfs-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #e2e8f0;
}

.bbfs-input-wrap {
  display: flex;
  gap: 8px;
}

.bbfs-input {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 3px;
  text-align: center;
  background: #0b1326;
  border: 1px solid #3b82f6;
  color: #38bdf8;
  border-radius: 8px;
  height: 42px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.bbfs-input:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25), inset 0 2px 4px rgba(0, 0, 0, 0.5);
  color: #fbbf24;
}

.bbfs-digit-counter {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 600;
}

.bbfs-targets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.bbfs-target-item {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bbfs-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  color: #f1f5f9;
}

.bbfs-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.bbfs-target-name {
  color: #e2e8f0;
}

.bbfs-target-badge {
  font-size: 0.75rem;
  color: #38bdf8;
  font-weight: 800;
  margin-left: auto;
}

.bbfs-stake-input-wrap {
  display: flex;
  align-items: center;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 0 8px;
  height: 32px;
}

.bbfs-currency-prefix {
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  margin-right: 4px;
}

.bbfs-stake-input {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0;
  height: 100%;
  outline: none;
  width: 100%;
}

.bbfs-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 4px;
}

.bbfs-summary-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bbfs-summary-stat .stat-label {
  font-size: 0.72rem;
  color: #94a3b8;
  text-transform: uppercase;
  font-weight: 700;
}

.bbfs-summary-stat .stat-val {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
}

.bbfs-summary-stat .stat-val.highlight {
  color: #38bdf8;
}

.bbfs-generate-btn {
  background: linear-gradient(180deg, #38bdf8 0%, #2563eb 50%, #1d4ed8 100%);
  color: #ffffff;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.5px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid #60a5fa;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  transition: all 0.15s ease;
}

.bbfs-generate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.6);
}

.bbfs-generate-btn:active {
  transform: translateY(2px);
}

/* ==========================================================================
   5. PAY4D QUICK ACTION TOOLBAR (Set Stake & Bulk Actions)
   ========================================================================== */
.pay4d-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(13, 33, 70, 0.9) 0%, rgba(8, 20, 48, 0.96) 100%);
  border: 1px solid rgba(192, 202, 219, 0.35);
  box-shadow: 0 4px 14px rgba(5, 12, 30, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  margin-bottom: 14px;
}

.pay4d-mass-set {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pay4d-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.pay4d-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pay4d-prefix {
  font-size: 0.8rem;
  font-weight: 700;
  color: #94a3b8;
}

.pay4d-mass-input {
  max-width: 110px;
  height: 34px;
  padding: 4px 8px;
  font-size: 0.85rem;
  text-align: right;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #ffffff;
  font-weight: 700;
  border-radius: 6px;
}

.pay4d-row-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-danger-soft {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger-soft:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #fee2e2;
}

/* ==========================================================================
   6. CANONICAL BET ROW & TABLE STYLES (Single Source of Truth)
   ========================================================================== */
.bet-row-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary, #94a3b8);
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Desktop 6-Column Grid */
.bet-row {
  display: grid;
  grid-template-columns: 36px minmax(130px, 1.4fr) minmax(170px, 1.6fr) minmax(120px, 1.2fr) minmax(130px, 1.2fr) 36px;
  gap: 8px 10px;
  align-items: center;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(13, 27, 62, 0.85) 0%, rgba(8, 18, 44, 0.94) 100%);
  border: 1px solid rgba(192, 202, 219, 0.32);
  box-shadow: 0 3px 12px rgba(4, 10, 26, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  margin-bottom: 8px;
  width: 100%;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.bet-row:hover,
.bet-row:focus-within {
  border-color: #38bdf8;
  background: linear-gradient(135deg, rgba(18, 38, 84, 0.9) 0%, rgba(12, 25, 58, 0.98) 100%);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.bet-row.pay4d-table-header {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 12px 6px;
  margin-bottom: var(--space-3);
  box-shadow: none;
}

.bet-row > * {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.bet-row .form-control,
.quick-bet-card .form-control {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.bet-row select.form-control {
  padding-left: 0.5rem;
  padding-right: 1.4rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-mobile-title {
  display: none;
}

/* Pay4D Single Number Input */
.pay4d-number-input {
  font-family: 'JetBrains Mono', 'Roboto Mono', 'SF Pro Text', monospace, sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 3px;
  text-align: center;
  background: rgba(11, 19, 38, 0.95);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #38bdf8;
  border-radius: 6px;
  min-height: 42px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: all 0.15s ease;
}

.pay4d-number-input:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25), inset 0 2px 4px rgba(0, 0, 0, 0.5);
  color: #fbbf24;
}

.pay4d-number-input::placeholder {
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 1px;
  color: rgba(148, 163, 184, 0.45);
}

.row-no-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  border: 1px solid #94a3b8;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #f1f5f9;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.row-net-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(51, 65, 85, 0.5);
  border-radius: 6px;
  font-size: 0.82rem;
  min-height: 38px;
  justify-content: flex-end;
}

.row-net-badge.active {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.35);
  color: #10b981;
}

.row-net-badge .net-amount {
  font-weight: 700;
  color: #34d399;
}

.row-net-badge .net-disc-tag {
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  padding: 1px 5px;
  border-radius: 4px;
}

.row-net-badge .net-placeholder {
  color: var(--text-muted, #64748b);
  font-size: 0.78rem;
}

.btn-remove-row {
  color: var(--status-danger);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  width: 100%;
  max-width: 40px;
  min-width: 0;
  box-sizing: border-box;
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.btn-remove-row:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* ==========================================================================
   7. BETSLIP SUMMARY CARD (Sidebar)
   ========================================================================== */
.betslip-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-brand);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  position: sticky;
  top: 80px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-x: clip;
}

.betslip-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: 0.9rem;
  padding-block: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.betslip-summary-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.betslip-summary-row > span:last-child {
  flex-shrink: 0;
  text-align: right;
  max-width: 55%;
}

.betslip-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  padding-block: var(--space-4);
  font-size: 1.1rem;
  font-weight: 700;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  flex-wrap: wrap;
}

.betslip-total-amount {
  font-size: 1.4rem;
  color: var(--text-gold);
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: right;
  min-width: 0;
  max-width: 100%;
}

.betslip-card .btn-block {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  white-space: normal;
}

/* ==========================================================================
   8. FOOTER LINKS
   ========================================================================== */
.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-4) 0;
  font-size: 0.8rem;
}

.footer-links a {
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--brand-primary);
}

/* ==========================================================================
   9. RESPONSIVE BREAKPOINTS (Single Unified Cascade)
   ========================================================================== */

/* Tablet (max-width: 900px) */
@media (max-width: 900px) {
  .bet-grid-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .betslip-card {
    position: static;
  }

  .quick-bet-card,
  .betslip-card,
  .play-header {
    padding: var(--space-4);
  }
}

/* Mobile Screen (max-width: 640px) */
@media (max-width: 640px) {
  .play-header {
    flex-direction: column;
    align-items: stretch;
  }

  .play-header > div:last-child {
    text-align: left;
  }

  .play-header #market-countdown {
    font-size: 1.25rem;
  }

  .market-meta-title h1 {
    font-size: 1.2rem;
  }

  .bet-grid-layout {
    gap: var(--space-4);
  }

  .quick-bet-card,
  .betslip-card {
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }

  /* Sembunyikan header tabel desktop di layar mobile */
  .pay4d-table-header {
    display: none;
  }

  /* Transformasi Baris Menjadi Kartu Taruhan Pay4D Mobile */
  .bet-row {
    display: grid;
    grid-template-columns: 32px 1fr 1fr 34px;
    grid-template-rows: auto auto auto;
    gap: 10px 8px;
    padding: 12px 10px;
    background: linear-gradient(145deg, rgba(14, 30, 68, 0.92) 0%, rgba(8, 18, 44, 0.98) 100%);
    border: 1px solid rgba(192, 202, 219, 0.38);
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 4px 18px rgba(4, 10, 28, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }

  /* Baris 1: Nomor Urut (#1), Input Nomor Tebakan (Tengah), Tombol Hapus */
  .cell-no {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .cell-selection {
    grid-column: 2 / 4;
    grid-row: 1 / 2;
  }

  .cell-remove {
    grid-column: 4 / 5;
    grid-row: 1 / 2;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Baris 2: Dropdown Game (Full Width) */
  .cell-game {
    grid-column: 1 / 5;
    grid-row: 2 / 3;
  }

  /* Baris 3: 50% Taruhan (Kiri) dan 50% Bayar Net (Kanan) — Bersih, Seimbang, Tidak Bertumpuk */
  .cell-stake {
    grid-column: 1 / 3;
    grid-row: 3 / 4;
    min-width: 0;
  }

  .cell-net {
    grid-column: 3 / 5;
    grid-row: 3 / 4;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .cell-mobile-title {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .cell-no .cell-mobile-title,
  .cell-remove .cell-mobile-title {
    display: none;
  }

  .cell-stake .bet-stake {
    width: 100%;
    min-height: 40px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 6px;
    text-align: right;
    padding: 6px 10px;
    box-sizing: border-box;
  }

  .cell-net .row-net-badge {
    width: 100%;
    min-height: 40px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
  }

  .cell-net .row-net-badge .net-amount {
    font-size: 0.88rem;
    font-weight: 800;
  }

  .cell-net .row-net-badge .net-disc-tag {
    font-size: 0.72rem;
    font-weight: 700;
  }

  .betslip-summary-row {
    font-size: 0.85rem;
  }

  .betslip-total-amount {
    font-size: 1.2rem;
  }
}

/* Small Phones (max-width: 480px) */
@media (max-width: 480px) {
  .brand-logo .brand-logo-img {
    height: 28px;
    max-width: 118px;
  }

  .app-header .header-actions {
    display: none;
  }
}
