/* =============================================
   MOBILE RESPONSIVE - App-like Design
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Sinhala:wght@400;500;600;700;800&family=Noto+Sans:wght@400;500;600;700;800&display=swap');

/* Desktop */
@media (min-width: 1025px) {
  .em-hero h1 { font-size: 2.8rem; }
  .em-hero { min-height: 540px; }
}

/* Tablet */
@media (max-width: 1024px) {
  .em-categories-grid { grid-template-columns: repeat(3, 1fr); }
  .em-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .em-dashboard { grid-template-columns: 220px 1fr; }
  .em-listing-detail { grid-template-columns: 1fr; }
}

/* =============================================
   MOBILE APP MODE
   ============================================= */
@media (max-width: 768px) {

  /* Show bottom nav like an app */
  .em-bottom-nav { display: block; }

  /* Add padding for bottom nav */
  .em-app { padding-bottom: 70px; }

  /* Hero adjustments */
  .em-hero { min-height: 380px; }
  .em-hero h1 { font-size: 1.6rem; }
  .em-hero p { font-size: 0.95rem; }
  .em-hero-actions { gap: 10px; }
  .em-hero-actions .em-btn { padding: 11px 20px; font-size: 14px; }
  .em-hero-stats { gap: 20px; margin-top: 28px; }
  .em-hero-stat .num { font-size: 1.5rem; }

  /* Categories horizontal scroll on mobile */
  .em-categories-grid {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 12px;
    padding-bottom: 4px;
    -ms-overflow-style: none;
  }
  .em-categories-grid::-webkit-scrollbar { display: none; }

  .em-cat-card {
    flex-shrink: 0;
    width: 90px;
    padding: 14px 8px;
  }

  .em-cat-icon { width: 48px; height: 48px; }
  .em-cat-name-si { font-size: 11px; }

  /* Listings grid */
  .em-listings-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .em-listing-image { height: 150px; }
  .em-listing-body { padding: 12px; }
  .em-listing-title { font-size: 13px; }
  .em-price { font-size: 15px; }

  /* Section padding */
  .em-section { padding: 24px 14px; }
  .em-section-title { font-size: 1.1rem; }

  /* Search bar */
  .em-search-bar { padding: 12px 14px; }
  .em-search-inner { gap: 8px; }
  .em-search-input { padding: 8px 12px; }
  .em-search-input input { font-size: 14px; }

  /* Dashboard - full width on mobile */
  .em-dashboard {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 16px;
  }

  .em-sidebar {
    position: static;
    display: none; /* Hidden on mobile, controlled by bottom nav */
  }

  .em-sidebar.show-mobile { display: block; }

  .em-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .em-stat-card { padding: 14px; }
  .em-stat-number { font-size: 1.4rem; }

  /* Auth */
  .em-auth-card { padding: 24px 20px; }

  /* Forms */
  .em-form-row { grid-template-columns: 1fr; }

  /* Modal */
  .em-modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .em-modal {
    border-radius: var(--em-radius-lg) var(--em-radius-lg) 0 0;
    max-height: 85vh;
    animation: em-slide-up-modal 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

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

  /* Listing detail */
  .em-listing-detail {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 16px;
  }

  .em-gallery-main { height: 260px; }

  /* Add listing */
  .em-add-listing { padding: 14px; }
  .em-listing-form-card { padding: 20px; }

  /* Table scroll */
  .em-content-card-body { overflow-x: auto; }

  /* Toast */
  .em-toast-container {
    bottom: 80px;
    right: 14px;
    left: 14px;
  }
  .em-toast { max-width: 100%; }
}

@media (max-width: 400px) {
  .em-listings-grid { grid-template-columns: 1fr; }
  .em-hero h1 { font-size: 1.35rem; }
  .em-hero-stats { display: none; }
}

/* =============================================
   PWA / App Feel Enhancements
   ============================================= */
@media (max-width: 768px) {
  /* Prevent text selection for app feel */
  .em-bottom-nav, .em-cat-card, .em-listing-card {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  /* Smooth scroll */
  .em-app { -webkit-overflow-scrolling: touch; }

  /* Pull to refresh indicator space */
  .em-hero { padding-top: env(safe-area-inset-top, 0); }

  /* Bottom safe area */
  .em-bottom-nav { padding-bottom: env(safe-area-inset-bottom, 0); }

  .em-app.has-bottom-nav { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0)); }

  /* Active states for touch */
  .em-btn:active { transform: scale(0.97); }
  .em-listing-card:active { transform: scale(0.98); box-shadow: var(--em-shadow-sm); }
  .em-cat-card:active { transform: scale(0.95); }
}

/* =============================================
   Dark header for app look
   ============================================= */
.em-app-header {
  background: var(--em-green-dark);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 150;
}

.em-app-header-logo {
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.em-app-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.em-header-icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--em-transition);
  position: relative;
  text-decoration: none;
}

.em-header-icon-btn:hover { background: rgba(255,255,255,0.25); }

.em-header-badge {
  position: absolute;
  top: -2px; right: -2px;
  background: var(--em-orange);
  color: white;
  font-size: 9px;
  font-weight: 800;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--em-green-dark);
}

/* Desktop header shows full nav */
@media (min-width: 769px) {
  .em-app-header { display: none; }
}
