/* Shared responsive layout safety.
   Explicit horizontal scrollers keep their own overflow behavior. */

html,
body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

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

@media (max-width: 900px) {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  main,
  header,
  footer,
  section,
  article,
  aside,
  nav,
  form,
  fieldset,
  .container,
  .card,
  .panel,
  .modal,
  .modal-card,
  .admin-main,
  .admin-content,
  .admin-panel,
  .admin-section,
  .dashboard-content {
    min-width: 0;
    max-width: 100%;
  }

  :where(
    .hero-grid,
    .layout,
    .grid,
    .form-grid,
    .detail-grid,
    .profile-head-grid,
    .contact-grid,
    .chat-layout,
    .search-page-layout,
    .admin-layout,
    .admin-grid,
    .dashboard-grid,
    .stats,
    .plans,
    .footer-grid
  ) > * {
    min-width: 0;
    max-width: 100%;
  }

  input,
  select,
  textarea,
  button {
    max-width: 100%;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-width: 0;
  }

  pre,
  code,
  .email,
  .phone,
  .profile-id,
  .transaction-id,
  .message-text,
  .notification-text,
  .admin-table td {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .modal,
  .upi-modal,
  .image-modal,
  .gallery-modal,
  .admin-modal {
    max-width: 100vw;
    padding-inline: clamp(10px, 4vw, 24px);
  }

  .modal-card,
  .upi-modal-card,
  .image-modal-content,
  .gallery-modal-content,
  .admin-modal-card {
    width: min(100%, 680px);
    max-width: 100%;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  :where(
    .carousel,
    .carousel-track,
    .profile-carousel,
    .profile-cards,
    .cards-scroll,
    .horizontal-scroll,
    .scroll-row,
    .image-gallery,
    .gallery-thumbnails,
    .tabs-scroll,
    .filter-tabs,
    .admin-table-wrap,
    .table-responsive
  ) {
    max-width: 100%;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 560px) {
  .container {
    width: 100%;
    max-width: 100%;
    padding-inline: 14px;
  }

  h1,
  .hero h1,
  .page-hero h1 {
    font-size: clamp(2rem, 10vw, 2.65rem);
    overflow-wrap: anywhere;
  }

  h2 {
    font-size: clamp(1.55rem, 7vw, 2.15rem);
    overflow-wrap: anywhere;
  }

  .btn,
  button,
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .form-actions,
  .card-actions,
  .profile-actions,
  .modal-actions,
  .admin-actions,
  .toolbar-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 768px) {
  .footer .footer-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 24px 18px !important;
    align-items: start !important;
  }

  .footer .footer-grid > div:first-child {
    grid-column: 1 / -1 !important;
    text-align: center !important;
    align-items: center !important;
  }

  .footer .footer-grid > div:nth-child(2),
  .footer .footer-grid > div:nth-child(3) {
    width: 100% !important;
    min-width: 0 !important;
    text-align: left !important;
  }
}

@media (max-width: 768px) {
    .search-box .form-grid .field:first-child {
        display: none !important;
    }
}

@media (max-width: 768px) {
  .footer .footer-grid {
    padding-left: 18px !important;
    padding-right: 18px !important;
    box-sizing: border-box !important;
  }

  .footer .footer-grid > div:nth-child(2) {
    padding-left: 8px !important;
  }

  .footer .footer-grid > div:nth-child(3) {
    padding-left: 8px !important;
  }
}
