/* ================================================
   Coltivera Mobile Styles
   Responsive breakpoints, touch targets, bottom nav
   ================================================ */

/* ── Bottom Navigation (mobile only) ────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #dee2e6;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
  z-index: 1050;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.mobile-bottom-nav .nav {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: 56px;
}
.mobile-bottom-nav .nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: #6c757d;
  font-size: 0.65rem;
  padding: 4px 0;
  gap: 2px;
  text-decoration: none;
  transition: color 0.15s;
  min-width: 44px;
  min-height: 44px;
}
.mobile-bottom-nav .nav-link svg {
  width: 22px;
  height: 22px;
}
.mobile-bottom-nav .nav-link.active {
  color: #198754;
}
.mobile-bottom-nav .nav-link:active {
  background-color: rgba(25, 135, 84, 0.08);
}
/* Gradient fade above bottom nav for visual separation from content */
.mobile-bottom-nav::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 20px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.95), transparent);
  pointer-events: none;
}

/* ── Touch Target Sizing ─────────────────────────── */
@media (pointer: coarse) {
  /* Ensure minimum 44px touch targets */
  .btn-sm {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 0.75rem;
  }
  .form-select, .form-control {
    min-height: 44px;
  }
  .nav-tabs .nav-link {
    padding: 0.75rem 1rem;
  }
  /* Larger tag chips for touch */
  .tag-chip {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
  /* Filter pills */
  #statusFilters .btn {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
  }
}

/* ── Small Mobile (< 576px) ──────────────────────── */
@media (max-width: 575.98px) {
  /* Show bottom nav */
  .mobile-bottom-nav {
    display: block;
  }
  /* Add padding at bottom for fixed bottom nav.
     Use 60px (not 56px) to account for the 1px border-top on .mobile-bottom-nav
     plus a small buffer to prevent sub-pixel overlap. */
  body {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0));
  }
  /* Ensure main content clears the fixed bottom nav with breathing room.
     main.py-4 specificity (0,1,1) beats Bootstrap .py-4 (0,1,0). */
  main.py-4 {
    padding-bottom: calc(60px + 1.5rem + env(safe-area-inset-bottom, 0)) !important;
  }
  /* Account for fixed bottom nav in scroll positioning */
  html {
    scroll-padding-bottom: calc(60px + env(safe-area-inset-bottom, 0));
  }
  /* Hide desktop navbar collapse items on mobile (bottom nav replaces them) */
  .navbar .navbar-toggler {
    display: none;
  }
  .navbar .navbar-collapse {
    display: none !important;
  }

  /* Container padding */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Landing page hero compact */
  .landing-hero {
    padding: 2.5rem 0 2rem;
  }
  .landing-hero .display-5 {
    font-size: 1.75rem;
  }
  .landing-step-icon {
    width: 48px;
    height: 48px;
  }
  .landing-step-icon svg {
    width: 24px;
    height: 24px;
  }

  /* Smaller page titles */
  h1 {
    font-size: 1.5rem;
  }
  .lead {
    font-size: 0.95rem;
  }

  /* Stack marketplace filter selects */
  #filterForm .row {
    gap: 0.5rem;
  }

  /* Idea detail: stack sidebar below content */
  .idea-detail-sidebar {
    margin-top: 1.5rem;
  }

  /* Stage milestones: compact on mobile */
  .stage-milestones {
    padding: 0 0.25rem;
  }
  .stage-milestone .fw-semibold {
    font-size: 0.7rem;
  }
  .stage-dot {
    width: 24px;
    height: 24px;
  }
  .stage-line {
    top: 12px;
    left: 8%;
    right: 8%;
  }

  /* Funding tracker stat boxes compact */
  .funding-stats .col-4 .fs-5 {
    font-size: 1rem !important;
  }

  /* Summary cards: smaller text */
  #portfolioSummary .fs-4 {
    font-size: 1.1rem !important;
  }
  #portfolioSummary .card-body {
    padding: 0.5rem;
  }

  /* Demo viewer header: stack buttons below title */
  .demo-header-actions {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
    margin-top: 0.75rem;
  }
  .demo-header-actions .btn {
    width: 100%;
  }

  /* Admin KPI cards: 2x2 grid */
  .admin-kpi .fs-3 {
    font-size: 1.25rem !important;
  }

  /* Step indicator: hide step labels, show only numbers */
  .step-indicator .step {
    font-size: 0;
    padding: 0.5rem 0.25rem;
  }
  .step-indicator .step-number {
    font-size: 0.8rem;
    margin-right: 0;
  }
  .step-indicator .step.active,
  .step-indicator .step.completed {
    font-size: 0.75rem;
  }
  .step-indicator .step.active .step-number,
  .step-indicator .step.completed .step-number {
    margin-right: 0.25rem;
  }

  /* Footer spacing — footer.border-top beats Bootstrap .py-4 specificity.
     Use 60px to match body padding (56px nav + 1px border + 3px buffer). */
  footer.border-top {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0)) !important;
  }
}

/* ── Medium Mobile (576px - 767px) ───────────────── */
@media (min-width: 576px) and (max-width: 767.98px) {
  /* Show bottom nav on tablets in portrait too */
  .mobile-bottom-nav {
    display: block;
  }
  body {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0));
  }
  main.py-4 {
    padding-bottom: calc(60px + 1.5rem + env(safe-area-inset-bottom, 0)) !important;
  }
  /* Account for fixed bottom nav in scroll positioning */
  html {
    scroll-padding-bottom: calc(60px + env(safe-area-inset-bottom, 0));
  }
  .navbar .navbar-toggler {
    display: none;
  }
  .navbar .navbar-collapse {
    display: none !important;
  }

  footer.border-top {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0)) !important;
  }
}

/* ── Tablet (768px - 991px) ──────────────────────── */
@media (min-width: 768px) and (max-width: 991.98px) {
  /* Stage milestones: slightly less padding */
  .stage-milestones {
    padding: 0 0.5rem;
  }
}

/* ── Disable hover effects on touch devices ──────── */
@media (hover: none) {
  .idea-card:hover,
  .performance-card:hover {
    transform: none;
    box-shadow: none;
  }
}

/* ── Safe area insets for notched phones ──────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .mobile-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ── Smooth scrolling for mobile ─────────────────── */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ── Pull-to-refresh visual hint (optional) ──────── */
.ptr-indicator {
  display: none;
  text-align: center;
  padding: 0.5rem;
  color: #6c757d;
  font-size: 0.85rem;
}
