/**
 * Unity Money — global mobile / tablet responsive (load last)
 */

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

img,
video,
svg {
  max-width: 100%;
  height: auto;
}

/* iOS: 16px+ inputs avoid zoom on focus */
@media (max-width: 767px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Scrollable tables — all panels */
.table-wrap,
.dr-table-wrap,
.um-client-v2 .table-wrap,
.um-admin-v3 .table-wrap,
.um-body .table-wrap,
.content .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto !important;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  border-radius: 12px;
  box-shadow: inset 0 -1px 0 rgba(2, 132, 199, 0.12);
}

/* Scroll hint on small screens */
@media (max-width: 767px) {
  .table-wrap::before,
  .dr-table-wrap::before {
    content: "← Swipe sideways to see full table →";
    display: block;
    padding: 8px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #0369a1;
    background: linear-gradient(90deg, #e0f2fe, #ecfeff);
    border-bottom: 1px solid #bae6fd;
    text-align: center;
  }

  table.um-table {
    min-width: 560px;
    width: max-content;
    max-width: none;
  }

  table.um-table th,
  table.um-table td {
    padding: 10px 12px;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  table.um-table td.wrap-cell,
  table.um-table th.wrap-cell {
    white-space: normal;
    min-width: 140px;
  }
}

/* Prevent page blow-out */
.um-app-v3 .um-main,
.um-app-v3 .um-body,
.um-admin-v3 .content {
  max-width: 100%;
  overflow-x: clip;
  box-sizing: border-box;
}

/* Stack multi-column forms / filters */
@media (max-width: 767px) {
  .row-2,
  .form-row,
  .filter-row,
  .um-filter-bar,
  .settings-grid,
  .roi-form-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .row-2 > *,
  .form-row > *,
  .filter-row > * {
    width: 100% !important;
    max-width: none !important;
  }
}

/* Card / stat grids on phones */
@media (max-width: 767px) {
  .cards:not(.cards--dashboard),
  .um-client-v2 .cards:not(.cards--dashboard),
  .um-body .cards:not(.cards--dashboard),
  .um-admin-v3 .cards,
  .package-grid,
  .landing-grid,
  .landing-grid.three,
  .um-public-v3 .landing-grid,
  .um-public-v3 .landing-grid.three,
  .step-row,
  .profile-grid,
  .dr-glow-grid,
  .login-feature-grid {
    grid-template-columns: 1fr !important;
  }

  /* Dashboard stats: 2 compact columns (details in client-panel.css) */
  .cards--dashboard,
  .um-client-v2 .cards--dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
}

/* Buttons & actions */
@media (max-width: 520px) {
  .btn,
  .landing-btn,
  .um-public-v3 .landing-btn {
    min-height: 44px;
  }

  .landing-actions,
  .um-public-v3 .landing-actions,
  .um-cta-strip .landing-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .landing-actions .landing-btn,
  .um-public-v3 .landing-actions .landing-btn {
    width: 100%;
    justify-content: center;
  }

  .btn-group,
  .um-btn-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-group .btn,
  .um-btn-row .btn {
    width: 100%;
  }
}

/* Notification rows */
@media (max-width: 640px) {
  .notif-list .row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .notif-list .row > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* Modals */
@media (max-width: 767px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card,
  .dr-modal-card.modal-card,
  .um-client-v2 .dr-modal-card.modal-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 18px 18px 0 0 !important;
    margin: 0;
  }

  .modal-card .table-wrap {
    margin-left: -8px;
    margin-right: -8px;
  }
}

/* Wallet / long text */
@media (max-width: 767px) {
  .wallet-box,
  .code-display,
  pre,
  .tx-hash {
    word-break: break-all;
    overflow-wrap: anywhere;
    font-size: 0.8rem;
  }
}

/* Social share */
@media (max-width: 600px) {
  .social-share {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .share-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Investment hero */
@media (max-width: 767px) {
  .investment-hero,
  .um-client-v2 .investment-hero {
    flex-direction: column !important;
    align-items: stretch !important;
    text-align: left;
    gap: 12px;
  }

  .hero-pill {
    white-space: normal;
  }
}

/* Income subnav scroll */
@media (max-width: 767px) {
  .income-subnav,
  .income-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .income-subnav a,
  .income-tabs a {
    flex-shrink: 0;
  }
}

/* Direct referral tiers */
@media (max-width: 600px) {
  .dr-glow-grid {
    gap: 12px;
  }

  .dr-glow-card-inner {
    padding: 14px;
  }
}

/* Matrix modal */
@media (max-width: 767px) {
  .dr-matrix {
    padding: 12px !important;
  }

  .dr-matrix-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .dr-tree-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ===================== CLIENT APP (um-app-v3) ===================== */
@media (max-width: 767px) {
  .um-app-v3 {
    --um-bar-h: 56px;
  }

  .um-bar {
    padding: 8px 12px;
    gap: 8px;
  }

  .um-bar-logo img {
    height: 34px;
  }

  .um-main {
    padding: 14px 12px 20px;
  }

  .um-page-bar {
    margin-bottom: 14px;
    padding-bottom: 12px;
  }

  .um-page-bar h1 {
    font-size: 1.2rem;
  }

  .um-page-bar p {
    font-size: 0.82rem;
  }

  .um-body .card,
  .um-client-v2 .card {
    padding: 14px;
  }

  .um-support-fab {
    width: 48px;
    height: 48px;
    right: 12px;
    font-size: 1.25rem;
  }

  .client-hero__stats {
    width: 100%;
  }

  .client-hero__stat {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }
}

@media (max-width: 400px) {
  .client-hero__stat {
    flex: 1 1 100%;
  }
}

/* ===================== ADMIN (um-admin-v3) ===================== */
@media (max-width: 767px) {
  .um-admin-v3 {
    --um-admin-bar: auto;
  }

  .um-admin-bar {
    padding: 0 10px 8px;
  }

  .um-admin-bar-top {
    flex-wrap: wrap;
    height: auto;
    min-height: 52px;
    padding: 8px 0;
    gap: 8px;
  }

  .um-admin-bar-top .brand-logo img {
    height: 32px;
  }

  .um-admin-bar-actions {
    flex-wrap: wrap;
    gap: 8px;
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .um-admin-tabs {
    gap: 6px;
    padding-bottom: 6px;
  }

  .um-admin-tabs a {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .um-admin-v3 .content {
    padding: 12px 10px 24px;
  }

  .um-admin-page-head h1 {
    font-size: 1.2rem;
  }

  .um-admin-v3 .topbar .user-pill,
  .um-admin-bar .user-pill {
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  .roi-box,
  .roi-chips,
  .um-roi-actions {
    flex-direction: column;
    align-items: stretch !important;
  }

  .roi-chips a,
  .roi-chips button {
    width: 100%;
    text-align: center;
  }
}

/* Admin + client support chat */
@media (max-width: 899px) {
  .um-support-admin {
    grid-template-columns: 1fr !important;
    min-height: auto;
  }

  .um-support-inbox {
    max-height: 220px;
  }

  .um-support-admin .um-support-chat,
  .um-support-chat {
    height: min(60vh, 520px);
    min-height: 300px;
  }

  .um-support-compose {
    flex-direction: column;
    align-items: stretch;
  }

  .um-support-compose .btn {
    width: 100%;
  }
}

/* ===================== PUBLIC (um-public-v3) ===================== */
@media (max-width: 900px) {
  .um-public-v3 .um-nav-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    border-radius: 10px;
    color: #0369a1;
    font-size: 1.2rem;
    cursor: pointer;
  }

  .um-public-v3 .landing-nav {
    flex-wrap: wrap;
    align-items: center;
  }

  .um-public-v3 .landing-nav nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 10px 0 4px;
    border-top: 1px solid #e2e8f0;
    margin-top: 4px;
  }

  .um-public-v3 .landing-nav nav.is-open {
    display: flex;
  }

  .um-public-v3 .landing-nav nav a {
    padding: 10px 4px;
  }

  .um-public-v3 .landing-nav nav .landing-btn {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }

  .um-public-v3 .hero-panel,
  .um-public-v3 .um-hero-panel {
    grid-template-columns: 1fr !important;
  }

  .um-public-v3 .landing-section.split {
    grid-template-columns: 1fr !important;
  }

  .um-public-v3 .feature-list div {
    grid-template-columns: auto 1fr;
  }
}

@media (max-width: 767px) {
  .um-public-v3 .landing-brand img {
    width: 118px;
  }

  .um-public-v3 .hero-copy h1,
  .um-public-v3 .landing-hero h1 {
    font-size: clamp(1.45rem, 5.5vw, 2.1rem);
    line-height: 1.15;
  }

  .um-public-v3 .hero-copy p {
    font-size: 0.95rem;
  }

  .um-public-v3 .login-shell,
  .um-public-v3.login-landing .auth-shell {
    padding: 16px 12px;
  }

  .um-public-v3 .auth-card,
  .auth-card {
    padding: 20px 16px;
    border-radius: 16px;
  }

  .um-public-v3 .login-intro {
    padding: 20px 16px;
  }

  .code-input {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
  }

  .code-input input {
    flex: 1;
    min-width: 0;
  }

  .um-public-v3 .landing-footer {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }

  .um-public-v3 .um-cta-strip {
    margin-left: 12px;
    margin-right: 12px;
    padding: 24px 16px;
  }

  .profile-band,
  .profile-head {
    grid-template-columns: 1fr !important;
    text-align: center;
  }

  .profile-actions {
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* Pair-clock: full width on mobile (see client-panel.css) */
.um-client-v2 .pair-clock-section,
.um-client-v2 .pair-clock-grid,
.um-client-v2 .pair-clock-card,
.um-client-v2 .pair-clock-body {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Safe areas (notched phones) */
@supports (padding: max(0px)) {
  .um-dock {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .um-bar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .um-main {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
