/* =========================================================================
   mobile.css — phone and tablet layout. Loaded LAST on every page, so it
   wins over the page's own styles. Desktop looks the same as before.
   ========================================================================= */

/* ---- all screen sizes ---- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, svg, video { max-width: 100%; }
.brand-name { white-space: nowrap; }
.search-bar, .hero-search, .search-bar input, .hero-search input { min-width: 0; }

/* The logo had a 28px bottom margin meant for the login card. In a nav bar it made the bar
   taller and pushed the logo up, so remove it there. */
body .navbar .brand,
body .home-nav .brand { margin-bottom: 0; }

/* Filters button only exists on phones. */
.filters-toggle { display: none; }

/* Touch screens have no hover, so do not leave cards "lifted" after a tap. */
@media (hover: none) {
  .product-card:hover, .category-card:hover, .btn-primary:hover,
  .btn-social:hover, .btn-confirm:hover, .btn-reject:hover { transform: none; }
}

/* ---- tablets and phones ---- */
@media (max-width: 860px) {
  body .filters, body .dash-nav { position: static; }
}

/* ---- phones ---- */
@media (max-width: 720px) {
  body { padding: 12px; min-height: 100vh; }
  @supports (height: 100dvh) { body { min-height: 100dvh; } }

  /* Typing in a field must not make iPhones zoom the page. */
  input, select, textarea { font-size: 16px !important; }

  /* page containers and cards */
  body .page { padding: 12px 12px 56px; }
  body .auth-card { padding: 28px 20px; }
  body .cart-card, body .page-card, body .method-card, body .card { padding: 20px; }
  body .cart-wrap, body .page-wrap { margin: 12px auto 24px; padding: 0; }

  /* top bars: logo on top, search / links underneath, not sticky (they would eat the screen) */
  body .navbar {
    position: relative; top: 0; flex-wrap: wrap; gap: 10px 12px;
    padding: 10px 14px; margin-bottom: 16px;
  }
  body .navbar .brand-name, body .brand-name { font-size: 16px; }
  body .navbar .search-bar { order: 3; flex: 1 1 100%; padding: 9px 14px; }

  body .home-nav {
    position: relative; top: 0; flex-wrap: wrap; gap: 8px 10px;
    padding: 10px 14px; margin: 8px auto 0;
  }
  body .home-nav .brand { order: 1; }
  body .home-nav .nav-actions { order: 2; margin-left: auto; }
  body .home-nav .nav-links {
    order: 3; flex: 1 1 100%; justify-content: space-around; gap: 6px;
    padding-top: 8px; border-top: 1px solid var(--color-border);
  }
  body .home-nav .nav-links a { padding: 6px 8px; font-size: 13.5px; }
  body .nav-btn { padding: 8px 12px; font-size: 13px; }
  body .profile-trigger .username { max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body .profile-dropdown { min-width: 210px; max-width: calc(100vw - 32px); }

  /* home page */
  body .hero { padding: 36px 8px 28px; }
  body .hero::before { width: 100%; max-width: 380px; height: 280px; top: -40px; }   /* was 600px wide: caused sideways scrolling */
  body .hero h1 { font-size: 30px; }
  body .hero p { font-size: 14.5px; margin-bottom: 22px; }
  body .hero-search { padding: 8px 8px 8px 14px; gap: 8px; }
  body .hero-search button { padding: 9px 14px; }
  body .section { padding: 24px 4px; }
  body .section-head h2 { font-size: 19px; }
  body .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  body .category-card { padding: 16px 10px; }

  /* product lists: two per row, like a normal shop app */
  body .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  body .product-card { padding: 10px; }
  body .product-title { font-size: 13px; }
  body .price-now { font-size: 15px; }
  body .results-head { flex-wrap: wrap; gap: 10px; }

  /* catalog filters: hidden behind a button */
  body .filters-toggle {
    display: inline-flex; align-items: center; gap: 8px; width: 100%; justify-content: center;
    padding: 11px; margin-bottom: 12px; border-radius: 14px; cursor: pointer;
    background: rgba(255,255,255,0.06); border: 1px solid var(--color-border);
    color: var(--color-text); font-size: 14px; font-weight: 600;
  }
  body .filters { display: none; padding: 16px; margin-bottom: 14px; }
  body .filters.open { display: block; }

  /* seller / admin dashboards: side menu becomes a swipeable tab bar */
  body .dashboard-layout { gap: 12px; }
  body .dash-nav { display: flex; gap: 6px; overflow-x: auto; padding: 8px; -webkit-overflow-scrolling: touch; }
  body .dash-nav-item { flex: 0 0 auto; white-space: nowrap; margin-bottom: 0; padding: 9px 14px; }
  body .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  body .stat-card { padding: 14px; }
  body .stat-value { font-size: 20px; }
  body .panel { padding: 16px; }
  body .product-list-row { grid-template-columns: 1fr; gap: 8px; justify-items: start; }
  body .queue-row, body .payment-row { padding: 14px; }
  body .action-row { flex-wrap: wrap; }
  body table.admin-table { display: block; max-width: 100%; overflow-x: auto; white-space: nowrap; }

  /* chat */
  body .chat-layout { grid-template-columns: 1fr; height: auto; gap: 12px; }
  body .conv-list { max-height: 190px; }
  body .thread { height: 70vh; min-height: 380px; }
  @supports (height: 100dvh) { body .thread { height: 70dvh; } }
  body .msg-bubble { max-width: 86%; }
  body .conv-preview { max-width: 55vw; }
  body .thread-header, body .thread-input { padding: 12px; }
  body .thread-messages { padding: 12px; }
  body .typing-indicator { padding: 0 12px 8px; }

  /* cart, orders, checkout, notifications */
  body .cart-item, body .order-row { flex-wrap: wrap; gap: 10px; }
  body .cart-item-info { flex: 1 1 100%; }
  body .bkash-number { font-size: 19px; word-break: break-all; }
  body .notif-item { padding: 12px 14px; }
  body .notif-title, body .notif-body { word-break: break-word; }

  /* seller application + rules pages */
  body .rules-box { max-height: 50vh; }
  body .rule-card { padding: 18px; }
  body .head { padding: 20px; }
  body .steps { gap: 6px; }
  body .step-pill { font-size: 11.5px; padding: 7px 4px; }

  /* messages that pop up at the bottom */
  body .toast {
    width: calc(100% - 24px); max-width: 420px; text-align: center;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---- very small phones ---- */
@media (max-width: 380px) {
  body .brand-name, body .navbar .brand-name { font-size: 15px; }
  body .profile-trigger .username { display: none; }
  body .hero h1 { font-size: 26px; }
  body .auth-card { padding: 24px 16px; }
}
