/* ============================================
   IBIT APP — Shared Mobile App Styles
   ============================================ */

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

:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --bg-gray: #f0f1f3;
  --surface: #ffffff;
  --border: #ececee;
  --border-2: #e0e2e6;
  --text: #0a0a0a;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --orange: #ff7a1a;
  --orange-2: #ff8c33;
  --orange-soft: #fff1e6;
  --black: #1a1a1a;
  --green: #00b377;
  --red: #f6465d;
  --blue: #1890ff;
  --bottom-nav-height: 68px;
  --nav-safe-top: env(safe-area-inset-top, 0px);
  --nav-safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Responsive app shell — full width on phone, scales on tablet/desktop */
  --app-shell-max: 100%;
  --app-page-padding: 16px;
}

html, body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Lock scroll only on main app shell pages (dashboard, wallet, etc.) */
html:has(.phone-frame),
html:has(.phone-frame) body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; outline: none; border: 0; background: none; }
img, svg { display: block; max-width: 100%; }

/* ============================================
   APP SHELL — native full-screen on phone/tablet;
   centered column on large desktop (no fake phone bezel)
   ============================================ */
.phone-frame {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  background: var(--bg);
}
.phone-notch { display: none !important; }
.app-container {
  position: relative;
  width: 100%;
  max-width: var(--app-shell-max);
  height: 100%;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  padding-top: var(--nav-safe-top);
}

@media (min-width: 768px) {
  :root {
    --app-shell-max: min(100%, 640px);
    --app-page-padding: 18px;
  }
  .phone-frame {
    background: var(--bg-soft);
  }
  .app-container {
    box-shadow: 0 0 0 1px var(--border);
  }
}

@media (min-width: 1024px) {
  :root {
    --app-shell-max: min(100%, 560px);
    --app-page-padding: 20px;
  }
}

@media (min-width: 1280px) {
  :root {
    --app-shell-max: 480px;
  }
  .app-container {
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08);
  }
}

/* Simulated status bar — hidden everywhere (real devices use OS bar) */
.status-bar { display: none !important; }

/* ============================================
   APP HEADER (Logo + Title + Actions)
   ============================================ */
.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 14px;
  background: var(--bg);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
}
.app-header.no-border { border-bottom-color: transparent; }
.header-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: var(--bg-soft);
  flex-shrink: 0;
  transition: 0.15s;
}
.header-back:active { transform: scale(0.93); }
.header-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  margin-right: 36px;
}
.header-actions { display: flex; gap: 6px; flex-shrink: 0; }

.heart-logo { width: 28px; height: 28px; flex-shrink: 0; }

/* ============================================
   APP MAIN SCROLL
   ============================================ */
.app-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--bottom-nav-height) + var(--nav-safe-bottom) + 16px);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.app-main::-webkit-scrollbar { width: 0; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  transition: 0.2s;
  white-space: nowrap;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-orange {
  background: var(--orange);
  color: white;
  box-shadow: 0 6px 16px rgba(255, 122, 26, 0.3);
}
.btn-black {
  background: var(--black);
  color: white;
}
.btn-ghost {
  background: var(--bg-soft);
  color: var(--text);
}
.btn-text {
  background: transparent;
  padding: 8px;
  color: var(--orange);
  font-weight: 600;
}

/* ============================================
   FORM INPUTS
   ============================================ */
.input-group {
  margin-bottom: 16px;
}
.input-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.input-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 14px 16px;
  border: 1px solid transparent;
  transition: 0.2s;
}
.input-box:focus-within {
  border-color: var(--orange);
  background: white;
  box-shadow: 0 0 0 4px rgba(255, 122, 26, 0.08);
}

/* Inline OTP (login / signup) */
.otp-panel {
  display: none;
  margin: 4px 0 16px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 122, 26, 0.25);
  background: rgba(255, 122, 26, 0.06);
  animation: otpSlideIn 0.25s ease;
}
.otp-panel.is-visible { display: block; }
@keyframes otpSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.otp-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 4px;
}
.otp-panel-sub {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.45;
  margin-bottom: 12px;
}
.otp-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.otp-row input {
  width: 44px;
  height: 50px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  border: 1.5px solid var(--border-2);
  border-radius: 12px;
  background: #fff;
  color: var(--text-1);
  outline: none;
}
.otp-row input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.15);
}
.otp-resend {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
}
.otp-resend button {
  color: var(--orange);
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.auth-fields.is-locked .input-box {
  opacity: 0.65;
  pointer-events: none;
}
.input-box i { color: var(--text-3); font-size: 14px; }
.input-box input {
  flex: 1;
  font-size: 15px;
  background: transparent;
}
.input-box input::placeholder { color: var(--text-3); }
.input-box .input-action {
  font-size: 13px;
  color: var(--orange);
  font-weight: 600;
  cursor: pointer;
}
.input-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 4px;
  display: none;
}
.input-error.show { display: block; }

/* ============================================
   CARDS / TILES
   ============================================ */
.card {
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 16px;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}

/* ============================================
   BOTTOM NAV
   ============================================ */
.bottom-nav {
  position: relative;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  min-height: var(--bottom-nav-height);
  padding: 6px 8px calc(10px + var(--nav-safe-bottom));
  background: white;
  border-top: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 6px;
  color: var(--text-2);
  font-size: 10px;
  font-weight: 500;
  flex: 1;
}
.nav-item i { font-size: 18px; }
.nav-item.active { color: var(--text); }
.nav-center { padding: 0; }
.nav-center span { color: var(--text-2); }
.nav-center-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -8px;
  transition: 0.2s;
}
.nav-center-btn:active { transform: scale(0.93); }

/* ============================================
   PAGE COMMON
   ============================================ */
.page {
  padding: var(--app-page-padding);
}
.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.page-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 22px;
}

/* ============================================
   ALERT/TOAST
   ============================================ */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  pointer-events: none;
}
.toast {
  padding: 12px 20px;
  background: #1a1a1a;
  color: white;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.warn { background: var(--orange); }
@keyframes toastIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-20px); } }

/* ============================================
   SKELETON / LOADING
   ============================================ */
.skel {
  background: linear-gradient(90deg, #f0f1f3, #e8e9eb, #f0f1f3);
  background-size: 200% 100%;
  animation: skelShimmer 1.4s infinite;
  border-radius: 8px;
}
@keyframes skelShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   DASHBOARD-SPECIFIC
   ============================================ */
.balance-card {
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
  border-radius: 20px;
  padding: 22px;
  color: white;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
}
.balance-card::before {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255,122,26,0.25), transparent 60%);
  top: -50px;
  right: -50px;
}
.bal-label {
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 6px;
  position: relative;
}
.bal-amount {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.8px;
  margin-bottom: 16px;
  position: relative;
}
.bal-actions {
  display: flex;
  gap: 8px;
  position: relative;
}
.bal-btn {
  flex: 1;
  padding: 10px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: white;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.bal-btn:active { transform: scale(0.96); }
.bal-btn.primary { background: var(--orange); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

@media (max-width: 360px) {
  .stat-tile-val { font-size: 15px; }
  .stat-tile-lbl { font-size: 10px; }
}

@media (min-width: 768px) {
  .stat-row {
    gap: 12px;
  }
  .stat-tile {
    padding: 14px 12px;
  }
}
.stat-tile {
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}
.stat-tile-val {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.stat-tile-lbl {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
}

/* Quick actions */
.qa-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 8px;
  margin-bottom: 22px;
}
.qa-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: 0.2s;
}
.qa-item:active { transform: scale(0.95); }
.qa-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text);
}
.qa-item span {
  font-size: 11px;
  text-align: center;
  line-height: 1.2;
}

/* Section heading */
.sec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 12px;
}
.sec-head h2 {
  font-size: 16px;
  font-weight: 800;
}
.sec-head a {
  font-size: 12px;
  color: var(--text-2);
}

/* ============================================
   TRANSACTION LIST
   ============================================ */
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-soft);
  border-radius: 12px;
}
.tx-ic {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: white;
  flex-shrink: 0;
}
.tx-ic-roi { background: linear-gradient(135deg, #22d3ee, #06b6d4); }
.tx-ic-referral { background: linear-gradient(135deg, #a78bfa, #8b5cf6); }
.tx-ic-level { background: linear-gradient(135deg, #f472b6, #ec4899); }
.tx-ic-salary { background: linear-gradient(135deg, #34d399, #10b981); }
.tx-ic-reward { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.tx-ic-deposit { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.tx-ic-withdrawal { background: linear-gradient(135deg, #fb7185, #ef4444); }
.tx-ic-package_activation { background: var(--black); }
.tx-ic-cto { background: linear-gradient(135deg, #f59e0b, #d97706); }
.tx-info { flex: 1; min-width: 0; }
.tx-type-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.tx-type {
  font-size: 14px;
  font-weight: 600;
  text-transform: capitalize;
  margin-bottom: 2px;
}
.tx-type-row .tx-type { margin-bottom: 0; }
.tx-status {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 6px;
  flex-shrink: 0;
}
.tx-status-pending,
.tx-status-pending_review { background: rgba(240, 185, 11, 0.22); color: #92400e; }
.tx-status-processing { background: rgba(59, 130, 246, 0.18); color: #1e40af; }
.tx-status-paid,
.tx-status-approved { background: rgba(22, 199, 132, 0.2); color: #047857; }
.tx-status-rejected { background: rgba(239, 68, 68, 0.18); color: #b91c1c; }
.tx-note {
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-amount {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.tx-amount.pos { color: var(--green); }
.tx-amount.neg { color: var(--red); }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-2);
}
.empty i { font-size: 42px; color: var(--text-3); margin-bottom: 14px; display: block; }
.empty h3 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty p { font-size: 13px; }

/* ============================================
   MISC
   ============================================ */
.divider { height: 8px; background: var(--bg-soft); margin: 16px 0; }
.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--text-2);
}
.chip.active { background: var(--orange-soft); color: var(--orange); }
.chip.success { background: rgba(0,179,119,0.1); color: var(--green); }
.chip.pending { background: rgba(245,158,11,0.1); color: #d97706; }
.chip.danger { background: rgba(246,70,93,0.1); color: var(--red); }

/* ============================================
   PWA — standalone / install
   ============================================ */
html.pwa-standalone {
  --nav-safe-bottom: max(env(safe-area-inset-bottom, 0px), 28px);
}

@media (display-mode: standalone) {
  :root {
    --nav-safe-bottom: max(env(safe-area-inset-bottom, 0px), 28px);
    --app-shell-max: 100%;
  }
  .phone-frame {
    background: var(--bg) !important;
  }
  .app-container {
    max-width: 100% !important;
    box-shadow: none !important;
  }
}

.pwa-install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--bottom-nav-height) + var(--nav-safe-bottom) + 12px);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #1a1a1a;
  color: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.pwa-install-banner.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.pwa-install-text { flex: 1; min-width: 0; }
.pwa-install-text strong { display: block; font-size: 13px; margin-bottom: 2px; }
.pwa-install-text span { font-size: 11px; opacity: 0.75; line-height: 1.35; }
.pwa-install-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.pwa-install-btn {
  background: var(--orange);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 10px;
}
.pwa-install-dismiss {
  width: 32px;
  height: 32px;
  font-size: 20px;
  line-height: 1;
  opacity: 0.7;
  border-radius: 8px;
}
