/* ==========================================
   Newx Spot — Mobile-first improvements
   Loaded after style.css to override
   ========================================== */

/* ============================================
   Base — touch friendly minimum
   ============================================ */
:root {
  --touch-min: 44px; /* Apple HIG */
}

button, .btn, a.btn, input[type="submit"], input[type="button"] {
  min-height: var(--touch-min);
  padding: 0.5rem 1rem;
}

.btn-sm {
  min-height: 36px;
}

/* Form inputs — bigger on mobile */
.form-control, .form-select {
  font-size: 16px; /* prevents iOS zoom */
  min-height: var(--touch-min);
}

@media (max-width: 768px) {
  body {
    font-size: 15px;
    /* Padding bottom เผื่อ bottom nav */
    padding-bottom: 70px;
  }

  /* Container ใช้พื้นที่เต็ม */
  .container, .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Headings smaller */
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  h4 { font-size: 1.1rem; }
  h5 { font-size: 1rem; }

  /* Cards — padding ลด */
  .card-body {
    padding: 1rem 0.85rem;
  }

  /* Stat cards — แสดงเป็นแถวเดียว */
  .stat-card .big-stat {
    font-size: 1.75rem;
  }

  /* Hide some columns on mobile */
  .d-mobile-none {
    display: none !important;
  }

  /* Show only on mobile */
  .d-mobile-only {
    display: block !important;
  }
}

@media (min-width: 769px) {
  .d-mobile-only {
    display: none !important;
  }
}

/* ============================================
   Mobile Card View for Tables
   ============================================ */
@media (max-width: 768px) {
  /* แปลงตารางเป็น cards */
  .table-mobile-cards {
    display: block;
  }

  .table-mobile-cards thead {
    display: none;
  }

  .table-mobile-cards tbody {
    display: block;
  }

  .table-mobile-cards tr {
    display: block;
    background: var(--bg-card, #1a2030);
    border: 1px solid var(--border-soft, #2a3142);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
  }

  .table-mobile-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0 !important;
    border: none !important;
    text-align: left !important;
  }

  .table-mobile-cards td::before {
    content: attr(data-label);
    color: var(--text-muted, #9aa3b2);
    font-size: 0.85rem;
    font-weight: 500;
  }

  .table-mobile-cards td.text-end {
    text-align: right !important;
    justify-content: flex-end;
  }

  .table-mobile-cards td.text-center {
    text-align: center !important;
    justify-content: space-between;
  }
}

/* ============================================
   Bottom Navigation (mobile only)
   ============================================ */
.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #000;
    border-top: 1px solid var(--border-soft, #2a3142);
    z-index: 1030;
    padding: 0.4rem 0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #9aa3b2);
    text-decoration: none;
    padding: 0.5rem 0.25rem;
    font-size: 0.7rem;
    transition: color 0.15s;
    min-height: var(--touch-min);
  }

  .bottom-nav-item i {
    font-size: 1.4rem;
    margin-bottom: 0.15rem;
  }

  .bottom-nav-item.active {
    color: var(--binance-yellow, #f0b90b);
  }

  .bottom-nav-item:hover {
    color: var(--binance-yellow, #f0b90b);
  }

  /* ซ่อน navbar ปกติ ใช้แต่ logo */
  .navbar .navbar-collapse {
    display: none !important;
  }

  .navbar .navbar-toggler {
    display: none !important;
  }
}

/* ============================================
   Floating Action Button (FAB)
   ============================================ */
.fab {
  display: none;
}

@media (max-width: 768px) {
  .fab {
    display: flex;
    position: fixed;
    bottom: 80px;
    right: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--binance-yellow, #f0b90b);
    color: #000;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(240, 185, 11, 0.4);
    z-index: 1020;
    cursor: pointer;
    border: none;
    transition: transform 0.15s, box-shadow 0.15s;
  }

  .fab:active {
    transform: scale(0.95);
  }

  .fab:hover {
    box-shadow: 0 6px 16px rgba(240, 185, 11, 0.6);
    color: #000;
  }
}

/* ============================================
   Skeleton Loading
   ============================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 6px;
  height: 1.2rem;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  background: var(--bg-card, #1a2030);
  border-radius: 12px;
  padding: 1rem;
}

.skeleton-line {
  height: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
}

/* ============================================
   Pull-to-refresh indicator
   ============================================ */
.ptr-indicator {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--binance-yellow, #f0b90b);
  color: #000;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  z-index: 1040;
  transition: top 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ptr-indicator.active {
  top: 70px;
}

@media (hover: hover) and (pointer: fine) {
  .ptr-indicator { display: none; }
}

/* ============================================
   PWA Install Banner
   ============================================ */
.pwa-install-banner {
  display: none;
  position: fixed;
  bottom: 80px;
  left: 1rem;
  right: 1rem;
  background: linear-gradient(135deg, #f0b90b 0%, #d4a309 100%);
  color: #000;
  padding: 1rem;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 1050;
  animation: slide-up 0.4s ease;
}

.pwa-install-banner.show {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

@keyframes slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ============================================
   Touch animations
   ============================================ */
.btn:active, .card.clickable:active {
  transform: scale(0.97);
}

.touchable {
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: rgba(240, 185, 11, 0.2);
}

.touchable:active {
  background-color: rgba(240, 185, 11, 0.05);
}

/* ============================================
   Big number formatting
   ============================================ */
.number-mobile {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* ============================================
   Stack on mobile
   ============================================ */
@media (max-width: 768px) {
  .navbar-brand {
    font-size: 1rem !important;
  }

  /* Modals fit screen */
  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-fullscreen-mobile {
    max-width: 100%;
    margin: 0;
    height: 100%;
  }

  .modal-fullscreen-mobile .modal-content {
    border-radius: 0;
    height: 100%;
  }

  /* Forms */
  .form-label {
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
  }

  /* Reduce padding */
  .py-4, .py-5 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }

  /* Hero sections smaller */
  .hero {
    padding: 3rem 0 !important;
  }

  .hero h1 {
    font-size: 2.25rem !important;
  }

  .hero p.lead {
    font-size: 1.1rem !important;
  }

  /* Pricing cards stack */
  .pricing-card.featured {
    transform: none !important;
  }

  /* Stat sizes */
  .big-stat, .stat-big {
    font-size: 2rem !important;
  }
}

/* ============================================
   Step Form (signup)
   ============================================ */
.step-indicator {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  position: relative;
}

.step-indicator::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-soft, #2a3142);
  z-index: 0;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  flex: 1;
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card, #1a2030);
  border: 2px solid var(--border-soft, #2a3142);
  color: var(--text-muted, #9aa3b2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  margin-bottom: 0.4rem;
  transition: all 0.3s;
}

.step-item.active .step-circle {
  background: var(--binance-yellow, #f0b90b);
  border-color: var(--binance-yellow, #f0b90b);
  color: #000;
  box-shadow: 0 0 0 4px rgba(240, 185, 11, 0.2);
}

.step-item.completed .step-circle {
  background: #4ade80;
  border-color: #4ade80;
  color: #000;
}

.step-label {
  font-size: 0.8rem;
  color: var(--text-muted, #9aa3b2);
}

.step-item.active .step-label {
  color: var(--text-primary, #f5f7fa);
  font-weight: 600;
}

.step-content {
  display: none;
}

.step-content.active {
  display: block;
  animation: fade-in 0.3s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Tier card on mobile
   ============================================ */
@media (max-width: 768px) {
  .tier-card {
    margin-bottom: 0.75rem;
  }
}

/* ============================================
   Mobile improvements for charts
   ============================================ */
@media (max-width: 768px) {
  canvas {
    max-height: 300px !important;
  }
}

/* ============================================
   Status indicator dot
   ============================================ */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  animation: pulse-dot 2s infinite;
}

.status-dot.online { background: #4ade80; }
.status-dot.offline { background: #f87171; }
.status-dot.warning { background: #f0b90b; }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; }
  50% { box-shadow: 0 0 0 6px transparent; }
}
