/* User-facing mobile hardening. Loaded only from member templates. */

@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body,
  .main-wrap,
  .page-content,
  .container,
  .card,
  form {
    min-width: 0;
  }

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

  .site-header {
    max-width: 100vw;
  }

  .header-inner {
    min-width: 0;
    gap: 6px !important;
    padding-right: 16px !important;
    padding-left: 16px !important;
  }

  .header-logo {
    min-width: 0;
    margin-right: auto !important;
  }

  .logo-text {
    font-size: 16px !important;
  }

  .header-right {
    min-width: 0;
    gap: 6px !important;
  }

  .header-right .btn-sm {
    padding-right: 10px;
    padding-left: 10px;
  }

  .user-dropdown {
    right: -6px;
    min-width: min(200px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px);
  }

  .mobile-drawer {
    max-width: 100vw;
  }

  .mobile-nav {
    padding: 12px !important;
  }

  .credit-banner {
    flex-wrap: wrap;
    justify-content: flex-start !important;
    padding: 10px 14px !important;
    line-height: 1.5;
  }

  .site-footer {
    padding-right: 16px !important;
    padding-left: 16px !important;
  }

  .footer-links {
    flex-wrap: wrap;
    gap: 10px 16px !important;
  }

  .page-content {
    width: 100%;
  }

  .page-header,
  .page-header-left {
    min-width: 0;
    width: 100%;
  }

  .page-header-left h1,
  .page-header-left p,
  .card h1,
  .card h2,
  .card h3 {
    overflow-wrap: anywhere;
  }

  .page-header-actions,
  .history-header-actions,
  .dash-welcome-right {
    flex-wrap: wrap;
    width: 100%;
  }

  .page-header-actions .btn,
  .dash-welcome-right .btn {
    flex: 1 1 auto;
  }

  .btn {
    min-width: 0;
    max-width: 100%;
  }

  .table-wrap,
  .excel-preview-table-wrap,
  .external-table-wrap,
  .history-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap > .table {
    min-width: 640px;
  }

  .modal-backdrop,
  .modal-overlay {
    max-width: 100vw;
  }

  .modal,
  .modal-box,
  .auth-card {
    max-width: calc(100vw - 32px);
  }

  .modal-body {
    min-width: 0;
  }

  .modal-footer {
    flex-wrap: wrap;
  }

  .auth-wrap {
    align-items: flex-start !important;
    padding: 28px 16px !important;
  }

  .auth-card {
    padding: 28px 20px !important;
  }

  .auth-card h1 {
    overflow-wrap: anywhere;
  }

  .sendmsg-wrap {
    padding: 20px 16px;
  }

  .preview-col,
  .payment-summary {
    position: static;
  }

  .preview-wrap {
    padding: 16px;
  }

  .recipient-actions .btn,
  .send-actions-left .btn,
  .send-actions-right .btn,
  .provider-actions .btn,
  .provider-actions form {
    flex: 1 1 auto;
  }

  .special-chars-popup {
    position: fixed;
    right: 12px !important;
    bottom: 16px !important;
    left: 12px !important;
    width: auto;
    max-width: none;
    max-height: 70vh;
    transform: none;
  }

  .special-chars-popup::after {
    content: none;
  }

  .special-chars-content {
    max-height: 50vh;
  }

  .special-chars-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .recent-phone-popup {
    position: fixed;
    right: 12px !important;
    bottom: 16px !important;
    left: 12px !important;
    top: auto !important;
    width: auto;
    height: auto;
    max-width: none;
    max-height: 70vh;
  }

  .tooltip-panel {
    right: 0;
    left: auto;
    max-width: calc(100vw - 32px);
  }

  .msg-fixed-copy {
    align-items: flex-start;
  }

  .contacts-layout {
    height: calc(100vh - var(--nav-h));
    height: calc(100dvh - var(--nav-h));
    min-height: 0;
  }

  .contacts-main {
    min-width: 0;
  }

  .contacts-toolbar {
    align-items: stretch;
    padding: 12px;
  }

  .contacts-search {
    flex: 1 1 100%;
    min-width: 0;
    max-width: none;
  }

  .contacts-toolbar .toolbar-select {
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
  }

  .toolbar-total {
    width: 100%;
    margin-left: 0;
  }

  .contacts-toolbar .btn {
    flex: 1 1 100%;
  }

  .bulk-actions {
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .bulk-count {
    width: 100%;
  }

  .bulk-actions .btn {
    flex: 1 1 calc(50% - 6px);
  }

  .list-header,
  .contact-row {
    grid-template-columns: 34px minmax(0, 1fr) 94px 98px !important;
    padding-right: 10px;
    padding-left: 10px;
  }

  .contact-cell,
  .list-header-cell {
    padding-right: 4px;
    padding-left: 4px;
  }

  .contact-file-icon,
  .contact-name-sub {
    display: none;
  }

  .row-actions {
    opacity: 1;
  }

  .contacts-pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .contacts-pagination .pagination {
    flex-wrap: wrap;
  }

  .upload-modal-box,
  .modal-box {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .charge-layout {
    gap: 20px;
  }

  .payment-summary {
    padding: 20px;
  }

  .sched-tabs {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .cal-header {
    padding: 14px 16px;
  }

  .reserve-toolbar .btn {
    width: 100%;
  }

  .history-row-actions {
    flex-wrap: wrap;
  }

  .history-mobile-top {
    min-width: 0;
  }

  .emo-layout {
    height: 100vh;
    height: 100dvh;
  }

  .emo-body,
  .emo-main {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .external-header {
    align-items: stretch;
  }

  .provider-grid {
    grid-template-columns: 1fr;
  }

  .provider-actions {
    align-items: stretch;
  }

  .provider-actions .btn,
  .provider-actions form {
    width: 100%;
  }

  .history-filter-pills {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-filter-pill {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .dash-welcome-right .btn,
  .history-header-actions .btn,
  .history-balance-actions .btn {
    flex: 1 1 100%;
  }

  .filter-date-range {
    flex-wrap: wrap;
  }

  .filter-date-range span {
    display: none;
  }

  .qna-search-bar .form-control,
  .qna-search-bar .btn {
    flex: 1 1 100%;
    max-width: none !important;
  }

  .modal-footer .btn,
  .modal-footer button {
    flex: 1 1 auto;
  }

  .btn-modal-delete {
    width: 100%;
    margin-right: 0;
  }
}

@media (max-width: 480px) {
  .header-inner {
    padding-right: 12px !important;
    padding-left: 12px !important;
  }

  .header-right > .btn-sm {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 12px;
  }

  .hamburger {
    width: 34px !important;
    height: 34px !important;
  }

  .site-footer {
    margin-top: 48px !important;
    padding-top: 22px !important;
    padding-bottom: 22px !important;
  }

  .footer-links {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-card {
    padding: 24px 18px !important;
  }

  .page-header-actions .btn,
  .page-header .btn,
  .history-header-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .msg-type-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .msg-type-tab {
    min-width: 96px;
    padding-right: 8px;
    padding-left: 8px;
  }

  .recipient-actions,
  .send-actions-left,
  .send-actions-right {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .send-type-switch,
  .payment-methods {
    display: grid;
    grid-template-columns: 1fr;
  }

  .send-type-option,
  .payment-method {
    justify-content: center;
  }

  .reserve-time-group {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    width: 100%;
  }

  .phone-shell {
    width: min(200px, 100%);
  }

  .special-chars-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .excel-preview-header {
    align-items: stretch;
    flex-direction: column;
  }

  .excel-preview-header .btn {
    width: 100%;
  }

  .upload-template-download {
    display: block;
    margin-top: 6px;
    margin-left: 0 !important;
  }

  .package-grid {
    grid-template-columns: 1fr;
  }

  .package-card {
    padding: 18px 14px;
  }

  .summary-row {
    align-items: flex-start;
    gap: 12px;
  }

  #kit-bank-notice > div {
    grid-template-columns: 1fr !important;
  }

  .history-filter-pills {
    grid-template-columns: 1fr;
  }

  .history-mobile-row {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .history-mobile-actions .payment-table-btn {
    flex: 1 1 100%;
  }

  .terms-page-body {
    overflow-wrap: anywhere;
  }

  .terms-page-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .emo-body {
    flex-direction: column;
  }

  .emo-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .emo-chip {
    flex: 0 0 auto;
    padding-right: 10px;
    padding-left: 10px;
  }

  .emo-search form {
    flex-wrap: wrap;
  }

  .emo-search select,
  .emo-search input[type="text"] {
    flex: 1 1 100%;
  }

  .emo-search .btn {
    flex: 1 1 calc(50% - 3px);
  }

  .emo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
