/* ========================================
   PWA Mobile App Styles
   ======================================== */

/* Only apply mobile styles on small screens */
@media (max-width: 767.98px) {

  /* Fullscreen app layout */
  html,
  body {
    height: 100%;
    overflow-x: hidden;
  }

  /* App in standalone mode */
  @media all and (display-mode: standalone) {
    body {
      padding-bottom: 70px;
      /* Space for bottom nav */
    }

    /* Hide hero header in standalone mode for more space */
    .pm-hero {
      padding: 1rem 0 !important;
      margin-bottom: 1rem !important;
    }

    .pm-hero .title {
      font-size: 1.25rem !important;
    }

    .pm-hero .text-muted {
      font-size: 0.8rem;
    }
  }

  /* Bottom Navigation Bar */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #ffffff;
    border-top: 1px solid #e9ecff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding: 0.5rem 0;
  }

  .mobile-bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #6c757d;
    font-size: 0.7rem;
    transition: all 0.2s ease;
    padding: 0.25rem;
  }

  .mobile-bottom-nav .nav-item i {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
  }

  .mobile-bottom-nav .nav-item.active {
    color: #36288F;
  }

  .mobile-bottom-nav .nav-item:active {
    transform: scale(0.95);
  }

  /* Touch-optimized buttons */
  .btn,
  .card {
    -webkit-tap-highlight-color: rgba(54, 40, 143, 0.1);
  }

  /* Swipeable cards */
  .swipeable-card {
    touch-action: pan-y;
    transition: transform 0.3s ease;
  }

  .swipeable-card.swiping {
    transition: none;
  }

  /* Pull to refresh indicator */
  .pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 999;
  }

  .pull-to-refresh.visible {
    transform: translateY(0);
  }

  /* Larger touch targets */
  .table tbody td::before {
    min-width: 100px;
  }

  /* Optimized stat cards for mobile - more compact */
  .pm-stat {
    padding: 0.75rem !important;
    margin-bottom: 0.75rem !important;
  }

  .pm-stat .fs-3 {
    font-size: 1.25rem !important;
  }

  .pm-stat h6,
  .pm-stat p,
  .pm-stat small {
    font-size: 0.8rem !important;
    margin-bottom: 0.25rem !important;
  }

  .pm-stat .fw-bold {
    font-size: 1.5rem !important;
  }

  /* Compact summary cards container */
  .row.g-4.mb-4 {
    gap: 0.5rem !important;
    margin-bottom: 1rem !important;
  }

  /* Compact pagination */
  .pagination {
    font-size: 0.85rem;
  }

  .page-link {
    padding: 0.375rem 0.65rem;
  }

  /* Mobile-optimized alerts */
  .alert {
    font-size: 0.9rem;
    padding: 0.75rem;
  }

  /* Compact Page Summary section on mobile */
  #page-summary .card-header h5 {
    font-size: 0.95rem !important;
    margin-bottom: 0 !important;
  }

  #page-summary .card-header .badge {
    font-size: 0.7rem !important;
    padding: 0.25em 0.5em !important;
  }

  #page-summary .card-header small {
    font-size: 0.7rem !important;
  }

  #page-summary .card-body {
    padding: 0.75rem !important;
  }

  #page-summary h6,
  #page-summary .h6 {
    font-size: 0.85rem !important;
  }

  #page-summary .fw-bold {
    font-size: 1rem !important;
  }

  #page-summary small {
    font-size: 0.7rem !important;
  }

  #page-summary .table {
    font-size: 0.8rem !important;
  }

  #page-summary .table th,
  #page-summary .table td {
    padding: 0.5rem !important;
  }

  /* Sticky section headers with adjusted top */
  .section-header {
    position: sticky;
    top: 0;
    z-index: 100;
  }

  /* Card improvements for mobile */
  .card {
    margin-bottom: 1rem;
    border-radius: 12px;
  }

  .card-header {
    border-radius: 12px 12px 0 0 !important;
  }

  /* Improved mobile table scrolling */
  .table-responsive {
    -webkit-overflow-scrolling: touch;
  }

  /* Badge sizing */
  .badge {
    font-size: 0.75rem;
    padding: 0.35em 0.6em;
  }

  /* Container padding */
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Install prompt banner - smaller and less intrusive */
  .install-prompt {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 350px;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    padding: 0.75rem;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: none;
    align-items: center;
    gap: 0.75rem;
    z-index: 1001;
    animation: slideUp 0.3s ease;
  }

  @keyframes slideUp {
    from {
      transform: translate(-50%, 100%);
      opacity: 0;
    }

    to {
      transform: translate(-50%, 0);
      opacity: 1;
    }
  }

  .install-prompt.visible {
    display: flex;
  }

  .install-prompt .prompt-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
  }

  .install-prompt .prompt-text {
    flex: 1;
  }

  .install-prompt .prompt-text h6 {
    margin: 0 0 0.15rem 0;
    font-weight: 600;
    font-size: 0.9rem;
  }

  .install-prompt .prompt-text p {
    margin: 0;
    font-size: 0.75rem;
    opacity: 0.9;
  }

  .install-prompt button {
    flex-shrink: 0;
    padding: 0.4rem 0.8rem;
    background: white;
    color: #6a11cb;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
  }

  .install-prompt .close-prompt {
    background: transparent;
    color: white;
    padding: 0.2rem 0.4rem;
    font-size: 1.1rem;
  }

  /* Offline indicator */
  .offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff6b6b;
    color: white;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.85rem;
    z-index: 1002;
    display: none;
  }

  .offline-banner.visible {
    display: block;
  }

  /* Smooth scrolling */
  html {
    scroll-behavior: smooth;
  }

  /* Focus styles for accessibility */
  *:focus-visible {
    outline: 2px solid #36288F;
    outline-offset: 2px;
  }
}

/* Desktop - Hide mobile-only elements */
@media (min-width: 768px) {

  .mobile-bottom-nav,
  .install-prompt,
  .pull-to-refresh,
  .offline-banner {
    display: none !important;
  }
}

/* iOS-specific styles */
@supports (-webkit-touch-callout: none) {
  /* iOS safe area insets */
  @media (max-width: 767.98px) {
    body {
      padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }

    .mobile-bottom-nav {
      padding-bottom: env(safe-area-inset-bottom);
      height: calc(60px + env(safe-area-inset-bottom));
    }
  }
}