/* ==========================================================
   TAMIYA MINI 4WD - MOBILE CMS & MARSHALL INPUT STYLES
   Mobile-First, Touch-Optimized, High-Contrast Racing Theme
   ========================================================== */

:root {
  --bg-main: #0a0d18;
  --bg-card: #13182c;
  --bg-card-subtle: #1a213b;
  --bg-input: #0f1324;
  --border-color: rgba(255, 255, 255, 0.12);
  --border-focus: #06b6d4;

  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-race: 'Orbitron', monospace, sans-serif;
  --font-body: 'Rajdhani', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.4;
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================
   HEADER
   ========================================================== */
.mobile-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 19, 36, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 14px 6px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}

.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-role {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  color: #fff;
  font-size: 0.65rem;
  font-family: var(--font-race);
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.brand-title {
  font-size: 1.1rem;
  font-family: var(--font-race);
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #ffffff, #67e8f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.realtime-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.45);
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-family: var(--font-race);
  color: #a7f3d0;
  font-weight: 700;
}

.realtime-pill.status-connecting {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fde68a;
}

.realtime-pill.status-offline {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: live-pulse-glow 1.5s infinite;
}

.status-connecting .live-dot {
  background-color: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
}

.status-offline .live-dot {
  background-color: #ef4444;
  box-shadow: 0 0 6px #ef4444;
  animation: none;
}

@keyframes live-pulse-glow {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.25); opacity: 1; box-shadow: 0 0 10px currentColor; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* Track Selector Tabs */
.track-tab-container {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.track-tab-container::-webkit-scrollbar {
  display: none;
}

.track-select-hint {
  font-size: 0.7rem;
  font-family: var(--font-race);
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 700;
}

.track-tabs {
  display: flex;
  gap: 6px;
  flex: 1;
}

.track-tab-btn {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: #cbd5e1;
  border-radius: 8px;
  font-family: var(--font-race);
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.track-tab-btn:active {
  transform: scale(0.96);
}

.track-tab-btn.active {
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 14px rgba(6, 182, 212, 0.45);
}

/* ==========================================================
   CONTAINER & CARDS
   ========================================================== */
.mobile-container {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.card-header-compact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.track-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.active-track-title {
  font-family: var(--font-race);
  font-size: 1.35rem;
  font-weight: 900;
  color: #38bdf8;
}

.time-limit-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.time-limit-badge strong {
  color: #fbbf24;
  font-family: var(--font-race);
}

.btn-display-link {
  font-size: 0.8rem;
  color: #67e8f9;
  text-decoration: none;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.35);
  padding: 5px 10px;
  border-radius: 6px;
  font-weight: 700;
  white-space: nowrap;
}

.btn-display-link:active {
  background: rgba(6, 182, 212, 0.25);
}

/* BTO Strip */
.bto-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.bto-box {
  background: var(--bg-card-subtle);
  border-radius: 8px;
  padding: 8px 10px;
  border-left: 3px solid #f59e0b;
}

.bto-box.bto-2 {
  border-left-color: #94a3b8;
}

.bto-label {
  font-size: 0.72rem;
  font-family: var(--font-race);
  font-weight: 800;
  color: #fbbf24;
  display: block;
}

.bto-box.bto-2 .bto-label {
  color: #cbd5e1;
}

.bto-time {
  font-family: var(--font-race);
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  display: block;
}

.bto-team {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* ==========================================================
   STOPWATCH SECTION
   ========================================================== */
.card-header-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.header-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-with-icon h3 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.card-icon {
  font-size: 1.15rem;
}

.btn-toggle-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.stopwatch-digital-display {
  font-family: var(--font-race);
  font-size: 2.8rem;
  font-weight: 900;
  text-align: center;
  color: #67e8f9;
  text-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
  background: #080a12;
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: 10px;
  padding: 8px 0;
  margin: 10px 0;
  letter-spacing: 2px;
}

.sw-main-buttons {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.btn-sw {
  padding: 12px 6px;
  border-radius: 8px;
  border: none;
  font-family: var(--font-race);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-sw:active {
  transform: scale(0.96);
}

.btn-sw-start {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-sw-start.running {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-sw-lap {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #fff;
}

.btn-sw-lap:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-sw-reset {
  background: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

.sw-apply-group {
  background: var(--bg-card-subtle);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.apply-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.apply-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.btn-apply-lap {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: #67e8f9;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: var(--font-body);
  font-weight: 700;
  cursor: pointer;
}

.btn-apply-lap:active {
  background: rgba(6, 182, 212, 0.35);
  transform: scale(0.96);
}

.sw-laps-scroller {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.sw-lap-item {
  background: #0b0f1e;
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  font-family: var(--font-race);
  color: #cbd5e1;
}

/* ==========================================================
   FORM INPUT HASIL TIM
   ========================================================== */
.form-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.form-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-title-group h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f1f5f9;
}

.btn-text-action {
  background: transparent;
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: #67e8f9;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-text-action:active {
  background: rgba(6, 182, 212, 0.2);
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 5px;
}

.form-group label .required {
  color: #ef4444;
}

.form-row {
  display: flex;
  gap: 10px;
}

.flex-1 {
  flex: 1;
}

.mobile-input,
.mobile-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.mobile-input:focus,
.mobile-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

/* 3 Big Lap Inputs */
.laps-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.lap-field label {
  font-size: 0.75rem;
  font-family: var(--font-race);
  font-weight: 800;
  color: #94a3b8;
  display: block;
  margin-bottom: 4px;
  text-align: center;
}

.mobile-lap-input {
  width: 100%;
  background: #080a14;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 12px 6px;
  font-family: var(--font-race);
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  text-align: center;
  outline: none;
  transition: all 0.2s;
}

.mobile-lap-input:focus {
  border-color: #38bdf8;
  background: #0b1126;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.3);
}

/* Auto Calculated Best Time & Score */
.calc-strip {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.calc-box {
  background: var(--bg-card-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.best-time-box {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(59, 130, 246, 0.15));
  border-color: rgba(6, 182, 212, 0.4);
}

.calc-label {
  font-size: 0.68rem;
  font-family: var(--font-race);
  font-weight: 800;
  color: #67e8f9;
  display: block;
  margin-bottom: 2px;
}

.calc-value {
  font-family: var(--font-race);
  font-size: 1.45rem;
  font-weight: 900;
  color: #ffffff;
  display: block;
}

.mobile-score-input {
  width: 100%;
  background: transparent;
  border: none;
  font-family: var(--font-race);
  font-size: 1.45rem;
  font-weight: 900;
  color: #fbbf24;
  outline: none;
}

/* Score Chips */
.chips-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}

.chips-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.score-chip {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: #cbd5e1;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
  font-family: var(--font-race);
  font-weight: 700;
  cursor: pointer;
}

.score-chip:active {
  background: rgba(251, 191, 36, 0.25);
  color: #fbbf24;
  transform: scale(0.95);
}

/* Status Toggle */
.status-select-group {
  margin-bottom: 14px;
}

.status-toggle-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-status-toggle {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  font-family: var(--font-race);
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-status-toggle.active[data-status="FINISH"] {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: #34d399;
  color: #fff;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.btn-status-toggle.active[data-status="DNF"] {
  background: linear-gradient(135deg, #b91c1c, #ef4444);
  border-color: #f87171;
  color: #fff;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

/* Checkbox */
.checkbox-group {
  margin-bottom: 16px;
}

.custom-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.custom-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #06b6d4;
}

.checkbox-text {
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.3;
}

/* BIG SUBMIT BUTTON */
.submit-action-container {
  margin-top: 6px;
}

.btn-submit-big {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-family: var(--font-race);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.4);
  transition: all 0.15s ease;
}

.btn-submit-big:active {
  transform: scale(0.98);
  box-shadow: 0 2px 10px rgba(6, 182, 212, 0.3);
}

.submit-icon {
  font-size: 1.3rem;
}

/* ==========================================================
   BTO MANAGEMENT (COLLAPSIBLE)
   ========================================================== */
.bto-management-body {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bto-edit-block {
  background: var(--bg-card-subtle);
  border-radius: 8px;
  padding: 10px;
  border-left: 3px solid #fbbf24;
}

.bto-2-block {
  border-left-color: #cbd5e1;
}

.bto-edit-title {
  font-family: var(--font-race);
  font-size: 0.82rem;
  font-weight: 800;
  color: #fbbf24;
  margin-bottom: 8px;
}

.bto-2-block .bto-edit-title {
  color: #cbd5e1;
}

.btn-secondary-full {
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary-full:active {
  background: rgba(255, 255, 255, 0.15);
}

/* ==========================================================
   MINI LEADERBOARD / RESULT LIST
   ========================================================== */
.counter-badge {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-race);
}

.mobile-table-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card-subtle);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 10px 12px;
  border-radius: 8px;
  transition: all 0.2s;
}

.team-result-item.rank-1 {
  border-left: 3px solid #fbbf24;
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.1), var(--bg-card-subtle));
}

.team-result-item.rank-2 {
  border-left: 3px solid #94a3b8;
}

.team-result-item.rank-3 {
  border-left: 3px solid #b45309;
}

.team-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.rank-badge {
  font-family: var(--font-race);
  font-size: 1.1rem;
  font-weight: 900;
  width: 26px;
  text-align: center;
  color: #38bdf8;
}

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

.team-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.racer-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-right {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: right;
  flex-shrink: 0;
}

.time-score-group {
  display: flex;
  flex-direction: column;
}

.best-time-val {
  font-family: var(--font-race);
  font-size: 1.1rem;
  font-weight: 800;
  color: #67e8f9;
}

.score-val {
  font-size: 0.72rem;
  color: #fbbf24;
  font-weight: 700;
}

.status-tag {
  font-size: 0.65rem;
  font-weight: 800;
  font-family: var(--font-race);
  padding: 2px 6px;
  border-radius: 4px;
}

.status-tag.finish {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.status-tag.dnf {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.item-actions {
  display: flex;
  gap: 4px;
}

.btn-item-action {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-item-action:active {
  background: rgba(255, 255, 255, 0.2);
}

.empty-state {
  text-align: center;
  padding: 20px 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ==========================================================
   FOOTER NAVIGATION
   ========================================================== */
.mobile-footer-nav {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 8px;
  margin-top: 10px;
}

.nav-btn {
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  color: #cbd5e1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: all 0.2s;
}

.nav-btn.primary {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.45);
  color: #67e8f9;
}

.nav-btn:active {
  transform: scale(0.98);
}

/* Toast */
.mobile-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  pointer-events: none;
  white-space: nowrap;
}

.mobile-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
