/**
 * SmartConnect — responsive layer (mobile-first)
 * Bootstrap 5 breakpoints: xs <576, sm ≥576, md ≥768, lg ≥992, xl ≥1200, xxl ≥1400
 */

/* ---------- Global safety ---------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: clip;
}

img,
video,
svg,
canvas {
  max-width: 100%;
  height: auto;
}

main {
  min-width: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Readable wrapping — controlled, not aggressive */
.pm-listing-card .title,
.ld-title,
.pm-section-title,
.pm-auth__title,
.pm-category-row__name,
.ld-seller-name,
.admin-topbar h1 {
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

/* ---------- Container padding system ---------- */
.container,
.container-fluid,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

@media (min-width: 576px) {
  .container,
  .container-sm,
  .container-md,
  .container-lg,
  .container-xl,
  .container-xxl {
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
  }
}

@media (min-width: 1200px) {
  .container {
    max-width: 1140px;
  }
}

@media (min-width: 1400px) {
  .container {
    max-width: 1320px;
  }
}

/* Narrow content shells */
.pm-content-narrow {
  width: 100%;
  max-width: 860px;
  margin-inline: auto;
}

.pm-content-page {
  width: 100%;
  max-width: 820px;
  margin-inline: auto;
}

/* ---------- Typography scale ---------- */
.pm-section-title {
  font-size: clamp(1.25rem, 1.05rem + 1vw, 1.85rem);
  line-height: 1.25;
}

.pm-section-sub {
  font-size: clamp(0.9rem, 0.86rem + 0.2vw, 1rem);
  line-height: 1.5;
}

.pm-hero h1 {
  font-size: clamp(1.65rem, 1.2rem + 2.2vw, 3rem);
}

.pm-hero .lead {
  font-size: clamp(0.95rem, 0.9rem + 0.25vw, 1.1rem);
  max-width: 36rem;
}

.pm-dashboard-card .value {
  font-size: clamp(1.35rem, 1.2rem + 0.8vw, 1.75rem);
}

/* ---------- Navbar ---------- */
.pm-navbar .container {
  gap: 0.35rem;
}

.pm-navbar .navbar-brand {
  max-width: min(62vw, 11rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pm-navbar .navbar-toggler {
  border: 1.5px solid var(--pm-border);
  border-radius: 12px;
  padding: 0.45rem 0.65rem;
}

.pm-navbar .navbar-toggler:focus {
  box-shadow: 0 0 0 3px rgba(11, 122, 75, 0.18);
}

.pm-navbar .pm-search-suggest {
  width: 100%;
  max-width: 100%;
}

.pm-navbar .pm-search-suggest .form-control {
  min-width: 0;
  flex: 1 1 auto;
}

.pm-navbar .dropdown-menu {
  max-height: min(70vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.pm-navbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 991.98px) {
  .pm-navbar .navbar-collapse {
    padding: 0.85rem 0 1rem;
    border-top: 1px solid var(--pm-border);
    margin-top: 0.65rem;
  }

  .pm-navbar .navbar-nav {
    margin-bottom: 0.75rem;
  }

  .pm-navbar .pm-search-suggest {
    margin-bottom: 0.85rem !important;
  }

  .pm-navbar-actions {
    width: 100%;
  }

  .pm-navbar-actions .pm-btn-accent,
  .pm-navbar-actions .pm-btn-primary,
  .pm-navbar-actions .pm-btn-outline:not(.btn-sm) {
    flex: 1 1 calc(50% - 0.5rem);
    text-align: center;
    justify-content: center;
  }

  .pm-navbar-actions form {
    flex: 1 1 100%;
  }

  .pm-navbar-actions form .btn-link {
    width: 100%;
    text-align: left;
    padding-left: 0.25rem;
  }
}

@media (min-width: 992px) {
  .pm-navbar .pm-search-suggest {
    width: auto;
    min-width: 220px;
    max-width: 320px;
  }
}

@media (min-width: 1200px) {
  .pm-navbar .pm-search-suggest {
    min-width: 280px;
    max-width: 380px;
  }
}

/* Suggest box stays in viewport */
.pm-suggest-box {
  max-width: min(100vw - 2rem, 420px);
  left: 0;
  right: auto;
}

@media (max-width: 575.98px) {
  .pm-suggest-box {
    left: 0;
    right: 0;
    max-width: none;
  }
}

/* ---------- Hero / home ---------- */
@media (max-width: 575.98px) {
  .pm-hero {
    padding: 1.75rem 0 1.5rem;
  }

  .pm-search-panel {
    padding: 0.85rem;
    border-radius: 16px;
  }

  .pm-search-panel .form-control-lg,
  .pm-search-panel .form-select-lg,
  .pm-search-panel .btn-lg {
    font-size: 1rem;
    padding: 0.7rem 0.9rem;
  }

  .pm-category-row {
    padding: 0.75rem 0.85rem;
  }

  .pm-banner-track {
    grid-template-columns: 1fr;
  }

  .pm-home-banner img {
    height: 120px;
  }
}

/* ---------- Listing cards ---------- */
.pm-listing-card .title {
  min-height: 0;
  line-height: 1.35;
}

.pm-listing-card--compact .title {
  min-height: 0;
  -webkit-line-clamp: 2;
}

.pm-listing-card .meta {
  overflow-wrap: anywhere;
}

.pm-card-snippet {
  overflow-wrap: break-word;
}

.pm-attr-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

@media (max-width: 374.98px) {
  .pm-listing-card .body {
    padding: 0.7rem 0.65rem 0.8rem;
  }

  .pm-listing-card .price {
    font-size: 0.95rem;
  }

  .pm-listing-card .title {
    font-size: 0.88rem;
  }

  .pm-listing-card--list {
    grid-template-columns: 96px 1fr !important;
  }
}

/* ---------- Filters: mobile collapse pattern ---------- */
.pm-filters-toggle {
  display: none;
}

@media (max-width: 991.98px) {
  .pm-filters-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
  }

  .pm-filters-aside .pm-dashboard-card {
    margin-bottom: 0.5rem;
  }

  /* Keep filters usable: collapse content by default via Bootstrap .collapse */
  .pm-filters-collapse:not(.show) {
    display: none;
  }

  .pm-filters-collapse.show {
    display: block;
    margin-bottom: 1rem;
  }
}

@media (min-width: 992px) {
  .pm-filters-collapse {
    display: block !important;
    height: auto !important;
    visibility: visible !important;
    overflow: visible !important;
  }
}

/* ---------- Listing detail ---------- */
.ld-price {
  margin-bottom: 0.85rem !important;
}

.ld-title {
  overflow-wrap: break-word;
}

.ld-actions .btn,
.ld-secondary-actions .btn {
  width: 100%;
}

.ld-btn-call,
.ld-btn-wa,
.ld-btn-light {
  white-space: normal;
  text-align: center;
  line-height: 1.3;
}

.ld-btn-call {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ld-phone-num {
  overflow-wrap: anywhere;
}

@media (max-width: 575.98px) {
  .ld-gallery,
  .ld-summary,
  .ld-card {
    border-radius: 16px;
    padding: 0.7rem;
  }

  .ld-gallery-main {
    border-radius: 12px;
  }

  .ld-thumb {
    width: 64px;
    height: 64px;
  }

  .ld-specs {
    grid-template-columns: 1fr;
  }

  .ld-seller {
    flex-wrap: wrap;
  }

  .ld-featured-badge {
    top: 0.75rem;
    left: 0.75rem;
    font-size: 0.72rem;
    padding: 0.3rem 0.65rem;
  }
}

@media (min-width: 576px) and (max-width: 991.98px) {
  .ld-specs {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------- Auth ---------- */
@media (max-width: 575.98px) {
  .pm-auth {
    padding: 1.25rem 0 2rem;
    min-height: auto;
  }

  .pm-auth__card {
    padding: 1.25rem 1rem 1.1rem;
  }

  .pm-auth__brand-name {
    font-size: 1.35rem;
  }
}

/* ---------- Dashboard ---------- */
.pm-dash-mobile-bar {
  display: none;
}

@media (max-width: 991.98px) {
  .pm-dash-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .pm-sidebar {
    min-height: auto;
  }

  body.pm-dashboard-body {
    padding-bottom: 4.5rem;
  }

  .pm-dash-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--pm-border);
    padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px rgba(20, 33, 61, 0.08);
  }

  .pm-dash-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.45rem 0.2rem;
    font-size: 0.65rem;
    font-weight: 650;
    color: var(--pm-muted);
    text-decoration: none;
    min-width: 0;
    line-height: 1.1;
  }

  .pm-dash-bottom-nav a i {
    font-size: 1.15rem;
  }

  .pm-dash-bottom-nav a.active,
  .pm-dash-bottom-nav a:hover {
    color: var(--pm-green);
  }

  .pm-dash-bottom-nav span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (min-width: 992px) {
  .pm-dash-bottom-nav {
    display: none !important;
  }
}

html[data-theme="dark"] .pm-dash-bottom-nav {
  background: rgba(19, 32, 51, 0.96);
  border-top-color: var(--pm-border);
}

/* ---------- Tables: never break layout ---------- */
.pm-table-wrap,
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pm-table-wrap table,
.table-responsive table {
  min-width: 560px;
}

/* ---------- Footer ---------- */
@media (max-width: 767.98px) {
  .pm-footer {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
    text-align: left;
  }

  .pm-footer .row > [class*="col-"] {
    margin-bottom: 0.25rem;
  }
}

/* ---------- Help FAB / PWA: keep clear of content ---------- */
.pm-help-fab {
  bottom: calc(1rem + env(safe-area-inset-bottom));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 1060;
}

.pm-help-panel {
  max-width: min(360px, calc(100vw - 1.5rem));
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: calc(4.75rem + env(safe-area-inset-bottom));
  max-height: min(70vh, 520px);
}

.pwa-install-banner {
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
  left: max(0.75rem, env(safe-area-inset-left));
  right: max(0.75rem, env(safe-area-inset-right));
}

@media (max-width: 575.98px) {
  .pwa-install-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .pwa-install-actions {
    justify-content: flex-end;
  }
}

/* ---------- Modals ---------- */
.modal-dialog {
  margin: 0.75rem;
  max-width: calc(100vw - 1.5rem);
}

@media (min-width: 576px) {
  .modal-dialog {
    margin: 1.75rem auto;
    max-width: 500px;
  }
}

.modal-body,
.modal-title {
  overflow-wrap: break-word;
}

/* ---------- Forms / sell ---------- */
@media (max-width: 575.98px) {
  .form-control,
  .form-select {
    font-size: 16px; /* prevent iOS zoom */
  }
}

/* ---------- Chat ---------- */
@media (max-width: 575.98px) {
  .pm-chat-thread {
    max-height: 55vh;
  }

  .pm-chat-msg {
    max-width: 92%;
  }
}

/* ---------- Admin ---------- */
.admin-content .table-responsive {
  border-radius: 12px;
}

@media (max-width: 991.98px) {
  .admin-topbar {
    padding: 0.75rem 0.85rem;
    gap: 0.65rem;
  }

  .admin-topbar h1 {
    font-size: 1.15rem;
  }

  .admin-topbar p {
    display: none;
  }

  .admin-content {
    padding: 0.85rem;
  }

  .admin-chip {
    display: none;
  }
}

@media (max-width: 575.98px) {
  .admin-quick {
    grid-template-columns: 1fr;
  }
}

/* ---------- Utility helpers ---------- */
.pm-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pm-break {
  overflow-wrap: break-word;
  word-break: break-word;
}

.pm-no-hscroll {
  max-width: 100%;
  overflow-x: clip;
}

.min-w-0 {
  min-width: 0;
}

/* ---------- Breadcrumb / chips wrap ---------- */
.ld-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.4rem;
  align-items: center;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.ld-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.ld-thumbs {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  padding-bottom: 0.25rem;
}

/* ---------- Dashboard offcanvas ---------- */
.pm-dash-offcanvas .nav-link {
  color: var(--pm-ink);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}

.pm-dash-offcanvas .nav-link.active,
.pm-dash-offcanvas .nav-link:hover {
  background: rgba(11, 122, 75, 0.1);
  color: var(--pm-green-dark);
}

.pm-dash-offcanvas .pm-btn-outline {
  color: var(--pm-ink);
}

/* ---------- Pagination ---------- */
.pagination {
  flex-wrap: wrap;
  row-gap: 0.35rem;
}

.pagination .page-link {
  padding: 0.45rem 0.7rem;
}

@media (max-width: 575.98px) {
  .pagination .page-link {
    padding: 0.4rem 0.55rem;
    font-size: 0.85rem;
  }
}

/* ---------- Category / brand chips ---------- */
.pm-category-hero .pm-section-sub {
  overflow-wrap: break-word;
}

/* ---------- Auth forms stay full width of card ---------- */
.pm-auth__card .form-control,
.pm-auth__card .form-select,
.pm-auth__card .btn {
  max-width: 100%;
}

/* ---------- Home trust / how rows ---------- */
@media (max-width: 575.98px) {
  .pm-trust-row,
  .pm-how-row {
    gap: 0.75rem;
  }
}
