/* Shared mobile layout for marketing, auth, and app shells */

html, body {
  max-width: 100%;
  overflow-x: visible;
}

main,
.hm-home,
.rx-band,
.rx-wrap {
  max-width: 100%;
}

img, video, iframe, svg {
  max-width: 100%;
  height: auto;
}

.container,
.container.mx-auto {
  width: 100%;
  max-width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (max-width: 1024px) {
  /* —— Header chrome —— */
  body:not(.tx-app) header.tx-site-header,
  body:not(.tx-app) header.tx-topbar {
    padding: 0 !important;
    padding-top: env(safe-area-inset-top) !important;
    height: auto !important;
  }
  body:not(.tx-app) header.tx-header--pill .tx-header-inner {
    min-height: 52px !important;
    height: auto !important;
  }

  header:not(.tx-site-header):not(.tx-topbar) {
    padding: 0.65rem 0 !important;
    padding-top: max(0.65rem, env(safe-area-inset-top)) !important;
  }

  header .container,
  header .container.mx-auto {
    padding-left: max(1rem, env(safe-area-inset-left)) !important;
    padding-right: max(1rem, env(safe-area-inset-right)) !important;
  }

  header .flex.justify-between,
  header .flex.items-center {
    gap: 0.5rem !important;
    min-width: 0 !important;
  }

  header .logo-container {
    min-width: 0;
    flex-shrink: 1;
  }

  header .logo,
  header img.logo {
    width: 96px !important;
    max-width: 28vw !important;
    height: auto !important;
  }

  .header-cta {
    display: none !important;
  }

  .desktop-theme-toggle {
    display: none !important;
  }

  .mobile-menu-button {
    display: inline-flex !important;
    flex-shrink: 0 !important;
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    border-radius: 10px !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    z-index: 2;
  }

  .mobile-menu-button svg,
  .mobile-menu-button [data-lucide] {
    width: 16px !important;
    height: 16px !important;
  }

  header nav,
  header nav.hidden,
  header nav.lg\:block {
    display: none !important;
  }

  /* —— Mobile drawer —— */
  .mobile-menu {
    width: min(100vw, 380px) !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    height: 100vh !important;
    padding: 1.25rem !important;
    padding-top: max(1.25rem, env(safe-area-inset-top)) !important;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom)) !important;
    padding-right: max(1.25rem, env(safe-area-inset-right)) !important;
    box-sizing: border-box !important;
    overscroll-behavior: contain;
  }

  .mobile-menu-header {
    margin-bottom: 1.5rem !important;
    padding-bottom: 1rem !important;
    gap: 0.75rem;
  }

  .mobile-menu-header img {
    width: 108px !important;
    max-width: 55% !important;
    height: auto !important;
  }

  .mobile-close-btn {
    width: 44px !important;
    height: 44px !important;
    flex-shrink: 0;
  }

  .mobile-menu ul {
    gap: 0.4rem !important;
  }

  .mobile-menu ul li a {
    padding: 0.9rem 1rem !important;
    font-size: 0.95rem !important;
    justify-content: flex-start !important;
    text-align: left !important;
  }

  .mobile-menu ul li a i {
    display: inline-block !important;
    width: 1.25rem !important;
    text-align: center !important;
    color: var(--accent-primary, #2563eb) !important;
  }

  .mobile-cta {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
    margin-top: 1.25rem !important;
    padding-top: 1rem !important;
    border-top: 1px solid var(--border-color, rgba(15, 23, 42, 0.08));
  }

  .mobile-cta .nav-login,
  .mobile-cta .btn-primary {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
    box-sizing: border-box !important;
  }

  .mobile-cta .theme-toggle,
  #mobileThemeToggle.theme-toggle {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    bottom: auto !important;
    margin: 0.25rem auto 0 !important;
    width: 44px !important;
    height: 44px !important;
    flex-shrink: 0;
  }

  /* —— Footer —— */
  footer {
    margin-top: 3rem !important;
    padding: 2.25rem 0 1.25rem !important;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom)) !important;
  }

  footer .container,
  footer .container.mx-auto {
    padding-left: max(1rem, env(safe-area-inset-left)) !important;
    padding-right: max(1rem, env(safe-area-inset-right)) !important;
  }

  footer .grid,
  footer .grid.grid-cols-1,
  footer .grid.sm\:grid-cols-2,
  footer .grid.lg\:grid-cols-4 {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 1.5rem 1.25rem !important;
  }

  footer .grid > div:first-child {
    grid-column: 1 / -1;
  }

  footer .grid > div:first-child img {
    width: 110px !important;
    max-width: 50% !important;
    height: auto !important;
  }

  footer .grid > div:first-child p {
    font-size: 0.9rem !important;
    max-width: 36rem;
  }

  .footer-section-title {
    margin-bottom: 0.75rem !important;
  }

  .footer-link {
    padding: 0.45rem 0 0.45rem 0.15rem !important;
    font-size: 0.9rem !important;
  }

  .footer-link:hover {
    padding-left: 0.15rem !important;
  }

  .footer-link::before {
    display: none !important;
  }

  footer .copyright {
    padding-top: 1.25rem !important;
    margin-top: 1.25rem !important;
    font-size: 0.8rem !important;
  }

  .trinix-hero {
    padding: 6.25rem 0 2.5rem !important;
  }

  .hero-main-title,
  .page-hero h1 {
    font-size: clamp(2rem, 9vw, 2.6rem) !important;
    line-height: 1.05 !important;
  }

  .hero-description,
  .section-description,
  .page-hero p {
    font-size: 0.98rem !important;
    max-width: 100% !important;
  }

  .hero-cta-buttons {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
    margin-bottom: 1.5rem !important;
  }

  .hero-cta-buttons .btn-primary,
  .hero-cta-buttons .btn-secondary,
  .hero-cta-buttons a {
    width: 100% !important;
    justify-content: center !important;
  }

  .trust-indicators {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
    padding: 1rem 0 0 !important;
  }

  .trust-item {
    min-width: 0 !important;
    display: flex !important;
    align-items: baseline !important;
    justify-content: space-between !important;
    gap: 0.75rem !important;
    padding-bottom: 0.65rem !important;
    border-bottom: 1px solid var(--tx-border, rgba(15, 23, 42, 0.08));
  }

  .trust-item:last-child {
    border-bottom: 0 !important;
    padding-bottom: 0 !important;
  }

  .trust-number {
    font-size: 1.25rem !important;
  }

  .trust-label {
    text-align: right !important;
    font-size: 0.8rem !important;
  }

  .tx-stage {
    min-height: 0 !important;
    width: 100% !important;
    margin-top: 0.5rem;
  }

  .tx-browser,
  .tx-float {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    position: static !important;
    box-sizing: border-box;
  }

  .tx-products {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.65rem !important;
  }

  .swatch {
    height: 72px !important;
  }

  .features-section,
  .how-it-works-section,
  .pricing-section,
  .cta-section {
    padding: 3rem 0 !important;
  }

  .features-header,
  .how-it-works-header,
  .pricing-header {
    margin-bottom: 1.75rem !important;
  }

  .features-grid,
  .steps-grid,
  .pricing-grid,
  .template-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 1rem !important;
    margin-top: 1.25rem !important;
  }

  .step-connector {
    display: none !important;
  }

  .feature-card,
  .step-card,
  .pricing-card,
  .template-card {
    padding: 1.25rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .price,
  .featured-price {
    font-size: 2rem !important;
  }

  .pricing-section .pricing-card.featured {
    padding-top: 2.75rem !important;
  }

  .popular-badge {
    top: 12px !important;
    right: 12px !important;
    font-size: 0.65rem !important;
  }

  .cta-card {
    padding: 2rem 1.15rem !important;
    border-radius: 18px !important;
  }

  .cta-buttons {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  .cta-btn,
  .cta-btn-primary,
  .cta-btn-secondary,
  .btn-primary-large,
  .pricing-btn {
    width: 100% !important;
    justify-content: center !important;
  }

  .cta-trust {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.65rem !important;
  }

  .page-hero {
    padding: 6.5rem 0 1.5rem !important;
  }

  .store-cta {
    margin-left: 1rem !important;
    margin-right: 1rem !important;
    padding: 1.35rem !important;
  }

  .form-card {
    margin: 0 auto;
    width: 100% !important;
    max-width: 100% !important;
    padding: 1.5rem 1.15rem !important;
  }

  /* Auth screens only — do not offset header/drawer toggles */
  body:has(.form-card) > .theme-toggle,
  body:has(.auth-home) > .theme-toggle,
  .form-card ~ .theme-toggle,
  .auth-home ~ .theme-toggle {
    top: 0.85rem !important;
    right: 0.85rem !important;
    width: 42px !important;
    height: 42px !important;
  }

  .auth-home {
    top: 1rem !important;
    left: 1rem !important;
  }
}

@media (max-width: 640px) {
  header .logo,
  header img.logo {
    width: 88px !important;
    max-width: 34vw !important;
  }

  .mobile-menu-button {
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
  }

  .mobile-menu {
    width: 100vw !important;
    max-width: 100vw !important;
    border-left: 0 !important;
  }

  footer .grid,
  footer .grid.grid-cols-1,
  footer .grid.sm\:grid-cols-2,
  footer .grid.lg\:grid-cols-4 {
    grid-template-columns: 1fr !important;
    gap: 1.35rem !important;
  }

  footer .grid > div:first-child {
    grid-column: auto;
  }

  .tx-products {
    grid-template-columns: 1fr !important;
  }

  .hero-badge {
    font-size: 0.68rem !important;
  }

  .section-title,
  .cta-title {
    font-size: clamp(1.55rem, 7vw, 2rem) !important;
  }

  .how-it-works-cta .btn-primary-large {
    font-size: 0.95rem !important;
    padding: 0.9rem 1rem !important;
  }
}

/* App / dashboard mobile */
@media (max-width: 1024px) {
  .tx-app,
  body.tx-app {
    overflow-x: hidden !important;
  }

  .tx-app .tx-topbar,
  .tx-app header.tx-topbar {
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
  }

  .tx-app .tx-topbar .glass {
    padding: 0.4rem 0.65rem !important;
    gap: 0.35rem !important;
    font-size: 0.75rem !important;
    max-width: 58vw;
  }

  .tx-app .tx-topbar .glass .font-semibold:first-child {
    display: none !important;
  }

  .tx-app main {
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
    overflow-x: hidden !important;
  }

  .tx-app h1 {
    font-size: 1.55rem !important;
    line-height: 1.15 !important;
    word-break: break-word;
  }

  .tx-app .glass,
  .tx-app .empty-state {
    width: 100% !important;
    max-width: 100% !important;
  }

  .tx-app .overflow-x-auto,
  .tx-app .glass.overflow-hidden {
    max-width: 100%;
  }

  .tx-app table {
    min-width: 640px;
  }

  /* Mobile drawer only — do not fight desktop rail layout */
  #sidebar.sidebar,
  aside#sidebar.dashify-rail {
    width: min(18rem, 86vw) !important;
    max-width: 86vw !important;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

@media (max-width: 1023px) {
  /* Stack: content < overlay < sidebar < topbar (overlay must NEVER cover the drawer) */
  .tx-app .tx-topbar,
  .tx-app header.tx-topbar {
    z-index: 120 !important;
  }

  #sidebar.sidebar,
  aside#sidebar.dashify-rail,
  .tx-app #sidebar,
  .tx-app aside#sidebar {
    top: 0 !important;
    height: 100dvh !important;
    height: 100vh !important;
    z-index: 110 !important;
  }

  .tx-app main,
  .tx-app .tx-main,
  .tx-app main.lg\:ml-72 {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  .tx-drawer-overlay,
  #overlay,
  #overlay.tx-drawer-overlay {
    z-index: 100 !important;
  }

  #overlay.hidden,
  .tx-drawer-overlay.hidden {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  .tx-app #menuBtn,
  .tx-pass-toggle,
  .tx-auth-icon-btn {
    min-width: 44px !important;
    min-height: 44px !important;
  }

  body:not(.tx-app) .mobile-menu-button {
    min-width: 30px !important;
    min-height: 30px !important;
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
  }

  .tx-app .trinix-response-modal-dialog,
  .tx-app .panel-notif-modal-dialog,
  .tx-surface-modal {
    max-width: calc(100vw - 1.5rem) !important;
    max-height: calc(100dvh - 2rem) !important;
    overflow-y: auto !important;
  }

  body.drawer-open .tx-app main {
    pointer-events: none;
  }
}

@media (max-width: 640px) {
  .tx-app main .grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 760px) {
  input,
  select,
  textarea {
    max-width: 100%;
    font-size: 16px;
  }

  form,
  .tx-form,
  .rx-form,
  .form-card {
    width: 100%;
    max-width: 100%;
  }

  .form-card {
    padding: 1.25rem !important;
  }

  .rx-actions,
  .tx-form,
  .rx-form {
    align-items: stretch;
  }

  main .rx-btn,
  .rx-actions .rx-btn,
  .tx-form .tx-btn,
  .tx-panel-card .tx-btn,
  .tx-panel-card form button,
  form .btn-primary,
  form button[type="submit"] {
    width: 100%;
    max-width: 100%;
    white-space: normal;
    text-align: center;
    justify-content: center;
    min-height: 44px;
  }

  .tx-panel-card,
  main,
  .rx-wrap {
    overflow-x: auto;
  }

  .tx-table,
  .tx-app table,
  main table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tx-app table {
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .tx-app .tx-theme-btn {
    width: 44px !important;
    height: 44px !important;
  }

  .tx-app .tx-topbar img {
    height: 1.75rem !important;
  }
}

/* Marketing grids / plans stack cleanly */
@media (max-width: 1024px) {
  .rx-grid,
  .rx-plans,
  .rx-metrics,
  .rx-cols-3,
  .rx-split {
    grid-template-columns: 1fr !important;
  }

  .rx-hero,
  .rx-section,
  .rx-page {
    padding-left: max(1rem, env(safe-area-inset-left)) !important;
    padding-right: max(1rem, env(safe-area-inset-right)) !important;
  }

  .rx-actions {
    flex-wrap: wrap !important;
    gap: 0.65rem !important;
  }

  .rx-actions .rx-btn,
  .rx-hero .rx-btn {
    min-height: 44px !important;
  }
}

@media (max-width: 640px) {
  .rx-chip-row,
  .rx-hero .rx-chip-row {
    flex-wrap: wrap !important;
  }

  .rx-band {
    padding-block: clamp(2rem, 6vw, 3rem) !important;
  }

  .rx-wrap {
    width: min(1280px, calc(100% - 1.25rem)) !important;
  }

  .rx-hero {
    min-height: auto !important;
    padding-top: 3.5rem !important;
  }

  .hm-img-slot,
  .rx-media-blank,
  .rx-card img {
    max-width: 100% !important;
    height: auto;
  }

  .tx-auth-shell {
    grid-template-columns: 1fr !important;
  }

  .tx-auth-brand {
    min-height: auto !important;
    padding: 1.25rem !important;
  }

  .tx-auth-brand-copy h1 {
    font-size: clamp(1.35rem, 6vw, 1.75rem) !important;
  }
}
