/* ═══════════════════════════════════════════════════════════
   BSTFN Mobile PWA Styles v2
   Target: Android Chrome, iPhone Safari, low-end devices
   ═══════════════════════════════════════════════════════════ */

/* ── Base touch improvements ─────────────────────────────── */
* {
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  /* Space for bottom nav on mobile */
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Smooth scrolling on iOS */
.main-content, .container, .container-fluid {
  -webkit-overflow-scrolling: touch;
}

/* Better tap targets — minimum 44×44px */
a, button, .btn, .nav-link, .dropdown-item {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.nav-link, .dropdown-item {
  padding-top: .6rem !important;
  padding-bottom: .6rem !important;
}

/* ── Bottom Navigation Bar ───────────────────────────────── */
.btm-nav {
  display: none;
}

@media (max-width: 768px) {
  .btm-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-card, #fff);
    border-top: 1px solid var(--border-color, #e9ecef);
    z-index: 1040;
    box-shadow: 0 -4px 20px rgba(0,0,0,.08);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .btm-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted, #888);
    font-size: .62rem;
    font-weight: 600;
    letter-spacing: .2px;
    transition: color .15s;
    position: relative;
    min-height: 60px;
  }

  .btm-nav-item.active,
  .btm-nav-item:hover {
    color: #6c5ce7;
  }

  .btm-nav-item i {
    font-size: 1.25rem;
    line-height: 1;
    min-height: unset;
  }

  .btm-nav-badge {
    position: absolute;
    top: 6px;
    right: calc(50% - 18px);
    background: #e17055;
    color: #fff;
    border-radius: 10px;
    font-size: .55rem;
    font-weight: 800;
    padding: 1px 5px;
    min-width: 16px;
    text-align: center;
    line-height: 1.4;
  }

  /* Push page content above bottom nav */
  body {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Hide top navbar links on mobile — bottom nav replaces them */
  .navbar-collapse .navbar-nav .nav-item:not(.dropdown) {
    display: none;
  }
}

/* ── Navbar mobile polish ────────────────────────────────── */
@media (max-width: 768px) {
  .navbar {
    padding: .5rem 1rem;
  }

  .navbar-brand {
    font-size: 1.1rem !important;
  }

  /* Notification bell stays visible */
  #notifDropdown {
    display: inline-flex !important;
  }

  /* Collapse menu styling */
  .navbar-collapse {
    background: var(--bg-card, #fff);
    border-radius: 16px;
    margin-top: .5rem;
    padding: .75rem;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    border: 1px solid var(--border-color, #e9ecef);
  }
}

/* ── Cards & containers ──────────────────────────────────── */
@media (max-width: 768px) {
  .container, .container-fluid {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .card {
    border-radius: 14px !important;
  }

  /* Hero sections — reduce padding */
  .dash-hero, .hero, .notif-hero, .dash-hero {
    padding: 1.25rem 0 !important;
    border-radius: 0 0 20px 20px !important;
  }

  /* Section titles */
  h1 { font-size: 1.6rem !important; }
  h2 { font-size: 1.3rem !important; }
  h3 { font-size: 1.15rem !important; }
  h4 { font-size: 1rem !important; }
}

/* ── Tables — always responsive on mobile ────────────────── */
@media (max-width: 768px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    border-radius: 10px;
  }

  .table-responsive-force {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Dashboard mobile layout ─────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar goes horizontal on mobile */
  .nav-dash {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    gap: .4rem !important;
    padding-bottom: .5rem !important;
    scrollbar-width: none;
  }
  .nav-dash::-webkit-scrollbar { display: none; }

  .nav-dash .nav-link {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    font-size: .78rem !important;
    padding: .4rem .75rem !important;
    min-height: unset;
  }

  /* Stat cards — 2 per row */
  .stat-card {
    padding: .875rem 1rem !important;
  }
  .stat-num {
    font-size: 1.6rem !important;
  }

  /* KPI cards compact */
  .kpi-card {
    padding: 1rem !important;
  }
  .kpi-num {
    font-size: 1.7rem !important;
  }
}

/* ── Quiz mobile UX ──────────────────────────────────────── */
@media (max-width: 768px) {
  .quiz-shell {
    padding: .75rem .75rem 2rem !important;
  }

  .q-text {
    font-size: 1rem !important;
  }

  .choice-btn {
    padding: .75rem .9rem !important;
    font-size: .88rem !important;
  }

  /* Swipeable quiz cards */
  .q-card {
    padding: 1.25rem !important;
    border-radius: 14px !important;
    touch-action: pan-y;
  }

  /* Timer — always visible */
  .timer-wrap {
    font-size: .82rem !important;
    padding: .3rem .65rem !important;
  }
}

/* ── Forms mobile ────────────────────────────────────────── */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
    border-radius: 10px !important;
    padding: .65rem .9rem !important;
  }

  .form-control, .form-select {
    font-size: 16px !important;
  }

  .btn-lg {
    padding: .7rem 1.5rem !important;
    font-size: .95rem !important;
  }
}

/* ── Modals mobile ───────────────────────────────────────── */
@media (max-width: 768px) {
  .modal-dialog {
    margin: auto .75rem;
    align-items: flex-end;
  }

  /* Bottom sheet style modals on mobile */
  .modal.fade .modal-dialog {
    transform: translateY(100%);
    transition: transform .3s ease;
  }
  .modal.show .modal-dialog {
    transform: translateY(0);
  }

  .modal-content {
    border-radius: 20px 20px 0 0 !important;
  }
}

/* ── Blog/content mobile ─────────────────────────────────── */
@media (max-width: 768px) {
  .blog-body, .job-body, article {
    font-size: .93rem !important;
    line-height: 1.7 !important;
  }

  pre, code {
    font-size: .78rem !important;
    overflow-x: auto;
  }

  img {
    max-width: 100%;
    height: auto;
  }
}

/* ── Notification badge on bottom nav ────────────────────── */
#btm-notif-badge {
  display: none;
}
#btm-notif-badge.visible {
  display: inline-block;
}

/* ── Loading skeleton for slow connections ───────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-muted, #f0f0f0) 25%,
    var(--border-color, #e0e0e0) 50%,
    var(--bg-muted, #f0f0f0) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  color: transparent !important;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Safe area insets (iPhone notch/home bar) ────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .btm-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(60px + env(safe-area-inset-bottom));
  }
}

/* ── Standalone PWA mode (installed app) ─────────────────── */
@media (display-mode: standalone) {
  .navbar {
    padding-top: env(safe-area-inset-top, 0) !important;
  }
}

/* ── Desktop — hide bottom nav ───────────────────────────── */
@media (min-width: 769px) {
  .btm-nav { display: none !important; }
}
