/* Shared small-screen safeguards. Loaded after page-specific styles. */
*, *::before, *::after { box-sizing: border-box; }
html { max-width: 100%; }
body { max-width: 100%; overflow-x: clip; }
img, video, iframe, svg { max-width: 100%; }
img, video { height: auto; }
input, select, textarea { max-width: 100%; }
@media (max-width: 900px) {
  .business-profile-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .business-profile-shell { width: min(100% - 24px, 1100px); margin-inline: auto; }
  .business-profile-actions { flex-wrap: wrap; }
  .products-gallery { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)) !important; }
}
@media (max-width: 600px) {
  .business-profile-shell { width: calc(100% - 24px); }
  .business-profile-hero { min-height: 220px; }
  .business-profile-card { min-width: 0; padding: 16px; }
  .business-profile-actions > * { flex: 1 1 100%; text-align: center; }
  .products-gallery { grid-template-columns: minmax(0, 1fr) !important; }
  .product-public-card { min-width: 0; }
  .product-card-actions { flex-direction: column; }
  .product-card-actions button { width: 100%; }
  .header-inner { flex-wrap: wrap; }
  .header-actions { flex-wrap: wrap; }
  .mz-footer-bottom { flex-wrap: wrap; }
}
.product-card-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.product-card-actions button { flex: 1 1 125px; min-height: 44px; }
.product-enquire-btn { cursor: pointer; }
.product-inquiry-dialog { width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 32px); overflow-y: auto; border: 0; border-radius: 14px; padding: 24px; box-shadow: 0 20px 80px #0004; }
.product-inquiry-dialog::backdrop { background: #0009; }
.product-inquiry-heading { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.product-inquiry-heading h2 { margin: 0 0 12px; font-size: 1.4rem; }
.product-inquiry-heading button { background: transparent; border: 0; font-size: 28px; cursor: pointer; }
.product-inquiry-form label { display: block; font-weight: 700; margin: 14px 0 6px; }
.product-inquiry-form textarea { display: block; width: 100%; padding: 12px; font: inherit; border: 1px solid #aab8ae; border-radius: 8px; resize: vertical; }
.product-inquiry-help { color: #52635a; font-size: .875rem; }
.product-inquiry-error { color: #b3261e; }
.product-inquiry-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.product-inquiry-actions button { min-height: 44px; padding: 9px 16px; border-radius: 8px; cursor: pointer; border: 1px solid #196b43; }
.product-inquiry-actions [type=submit] { background: #196b43; color: white; }
.product-inquiry-actions [type=submit]:disabled { opacity: .6; cursor: wait; }

/* Product enquiry matches the Add to order button and stays centered on all screens. */
.product-card-actions .product-enquire-btn { margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; }
.product-card-actions .order-now-btn, .product-card-actions .product-enquire-btn { flex: 1 1 0; min-width: 0; }
.product-inquiry-dialog { position: fixed; inset: 0; margin: auto; max-width: calc(100vw - 24px); max-height: min(90dvh, 700px); }
.product-inquiry-dialog:not([open]) { display: none; }
.product-inquiry-dialog[open] { display: block; }
.product-inquiry-dialog .product-inquiry-form { margin: 0; }
@media (max-width: 600px) {
  .product-card-actions .order-now-btn, .product-card-actions .product-enquire-btn { flex: 1 1 100%; }
  .product-inquiry-dialog { padding: 18px; }
}
.customer-enquiry-thread { border: 1px solid #dce8df; border-radius: 12px; padding: 12px; margin: 10px 0; background: #fbfdfb; overflow-wrap: anywhere; }
.customer-enquiry-thread p { white-space: pre-wrap; margin: 8px 0; }
.customer-enquiry-answer { padding: 10px 12px; background: #edf8f0; border-left: 3px solid #148a46; border-radius: 8px; }

/* Responsive layout enhancements shared across the entire website. */
:root { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html { scroll-padding-top: 90px; }
body { min-width: 0; }
main, section, article, aside, .card, .dashboard-grid > *, .app-frame > *, .main-area, .chart-wrap { min-width: 0; }
img, picture, video, canvas, svg { max-width: 100%; }
img { object-fit: contain; }
input, textarea, select, button { font: inherit; }
button, a, input, select { touch-action: manipulation; }
button, [role=button], .quick-action { min-height: 36px; }
#analytics { scroll-margin-top: 105px; }
#analytics .chart-wrap { width: 100%; overflow: hidden; }
#analytics .chart-wrap svg { width: 100%; height: auto; display: block; }
#analytics .chart-labels { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
#analytics .card-title-row { flex-wrap: wrap; gap: 10px; }
#ownerDateMenu { max-width: min(95vw, 340px); z-index: 20; }
#ownerDateMenu[hidden] { display: none !important; }
#ownerDateMenu input, #ownerDateMenu select { min-width: 0; width: 100%; }
@media (max-width: 1180px) {
  .dashboard-grid, .dashboard-layout, .main-content { min-width: 0; }
  .performance-card > * { min-width: 0; }
}
@media (max-width: 768px) {
  .main-area { width: 100%; max-width: 100%; }
  .app-topbar, .top-main, .top-actions { min-width: 0; }
  .top-search { min-width: 0; }
  .top-search input { min-width: 0; width: 100%; }
  .performance-card, .dashboard-grid, .right-rail { width: 100%; }
  #analytics .metric-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  #analytics .click-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
  .card-title-row > h2, .card-title-row > h3 { min-width: 0; overflow-wrap: anywhere; }
  .table-responsive, .table-wrapper { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
@media (max-width: 480px) {
  .main-area { padding: 12px 10px; }
  .stats-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .quick-actions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #analytics .metric-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #analytics .click-metrics { grid-template-columns: minmax(0, 1fr); }
  .welcome-actions, .card-title-row { flex-wrap: wrap; }
  .welcome-actions > *, .card-title-row > button { max-width: 100%; }
  .action-tiles, .nearby-grid, .farm-overview-grid, .recommend-grid, .resource-grid { grid-template-columns: minmax(0, 1fr); }
}
