@import url('responsive-admin-mobile.css');

/* Responsive adjustments for public pages that reuse the marketing shell
   plus dense authenticated surfaces that need phone-specific behavior. */

@media (max-width: 720px) {
  app-legal-page .nav-wrap,
  app-affiliate-program .nav-wrap {
    width: calc(100% - 24px) !important;
    height: auto !important;
    min-height: 56px;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 8px 0;
  }

  app-legal-page .brand,
  app-affiliate-program .brand {
    flex: 0 0 auto;
  }

  app-legal-page .nav-actions,
  app-affiliate-program .nav-actions {
    min-width: 0;
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 6px !important;
  }

  app-legal-page .nav-actions .text-button,
  app-affiliate-program .nav-actions .text-button {
    max-width: 44vw;
    padding-inline: 8px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px !important;
  }

  app-legal-page .nav-actions .black-button,
  app-affiliate-program .nav-actions .black-button {
    min-height: 44px !important;
    padding-inline: 11px !important;
    white-space: nowrap;
    font-size: 11px !important;
  }

  app-legal-page main {
    padding-top: 36px !important;
  }

  app-legal-page article,
  app-affiliate-program main > section {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  app-legal-page article > h1,
  app-affiliate-program main > section:first-child h1 {
    overflow-wrap: anywhere;
  }

  app-legal-page article section {
    padding: 20px 16px !important;
  }

  app-legal-page .footer-main,
  app-affiliate-program .footer-main {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  app-affiliate-program main > section:first-child {
    padding-top: 44px !important;
  }

  app-affiliate-program main > section:first-child h1 {
    font-size: clamp(38px, 11vw, 52px) !important;
    line-height: 1.04 !important;
  }

  app-affiliate-program .footer-bottom {
    align-items: flex-start !important;
    flex-direction: column;
    gap: 10px !important;
  }

  /* Affiliate dashboard: turn the wide referral table into readable cards. */
  app-affiliate-dashboard table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    border-collapse: separate !important;
  }

  app-affiliate-dashboard table thead {
    display: none !important;
  }

  app-affiliate-dashboard table tbody {
    display: grid !important;
    gap: 10px;
    padding: 12px;
  }

  app-affiliate-dashboard table tr {
    display: block !important;
    min-width: 0;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 16px;
    padding: 8px 10px;
    background: rgba(250, 250, 250, 0.72);
  }

  .dark app-affiliate-dashboard table tr {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.035);
  }

  app-affiliate-dashboard table td {
    display: grid !important;
    grid-template-columns: minmax(88px, 34%) minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    width: 100% !important;
    min-width: 0;
    padding: 8px 2px !important;
    border: 0 !important;
    overflow-wrap: anywhere;
  }

  app-affiliate-dashboard table td::before {
    color: #737373;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    line-height: 1.4;
    text-transform: uppercase;
  }

  app-affiliate-dashboard table td:nth-child(1)::before { content: 'Customer'; }
  app-affiliate-dashboard table td:nth-child(2)::before { content: 'Attributed'; }
  app-affiliate-dashboard table td:nth-child(3)::before { content: 'Plan'; }
  app-affiliate-dashboard table td:nth-child(4)::before { content: 'Subscription'; }
  app-affiliate-dashboard table td:nth-child(5)::before { content: 'Commission'; }
  app-affiliate-dashboard table td:nth-child(6)::before { content: 'Commission status'; }

  app-affiliate-dashboard table td[colspan] {
    display: block !important;
    padding: 18px 8px !important;
  }

  app-affiliate-dashboard table td[colspan]::before {
    content: none !important;
  }

  /* Admin data stays dense, but scroll is contained inside the card and the
     identifying first column remains visible while the user pans horizontally. */
  app-platform-admin-command-center .overflow-x-auto {
    max-width: calc(100vw - 40px);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
    scrollbar-width: auto;
  }

  app-platform-admin-command-center .data-table th,
  app-platform-admin-command-center .data-table td {
    padding: .7rem .75rem !important;
  }

  app-platform-admin-command-center .data-table th:first-child,
  app-platform-admin-command-center .data-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    box-shadow: 1px 0 0 rgba(0, 0, 0, 0.06);
  }

  app-platform-admin-command-center .data-table th:first-child {
    background: #f7f7f8 !important;
  }

  app-platform-admin-command-center .data-table td:first-child {
    background: #ffffff !important;
  }

  .dark app-platform-admin-command-center .data-table th:first-child {
    background: #252527 !important;
  }

  .dark app-platform-admin-command-center .data-table td:first-child {
    background: #1c1c1e !important;
  }

  app-platform-admin-command-center .search {
    max-width: none !important;
    min-height: 44px !important;
    font-size: 16px !important;
  }

  app-platform-admin-command-center .action {
    min-height: 40px !important;
  }

  /* Admin status actions and alert controls must wrap instead of clipping. */
  app-admin-status button {
    min-height: 44px;
  }

  app-admin-status input,
  app-admin-status textarea,
  app-admin-status select {
    font-size: 16px !important;
  }

  app-admin-status .max-h-\[420px\] .flex.gap-2 {
    flex-wrap: wrap;
  }

  /* Post detail: platform tabs no longer compete with the title on phones. */
  app-post-detail [role='tablist'] {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  app-post-detail [role='tablist']::-webkit-scrollbar {
    display: none;
  }

  app-post-detail [role='tablist'] > button {
    flex: 0 0 44px;
    width: 44px !important;
    height: 44px !important;
  }

  app-post-detail *:has(> [role='tablist']) {
    flex-direction: column !important;
    gap: 12px;
  }

  app-post-detail section:first-of-type {
    min-height: min(520px, 58dvh) !important;
  }

  /* Consultant keeps more usable chat width on narrow devices. */
  app-consultant .max-w-\[85\%\] {
    max-width: 92% !important;
  }

  app-consultant textarea {
    font-size: 16px !important;
  }

  /* Support header remains readable at 320px and respects safe areas. */
  app-support > div {
    padding-top: max(1.25rem, env(safe-area-inset-top)) !important;
    padding-bottom: max(2rem, env(safe-area-inset-bottom)) !important;
  }

  app-support button {
    min-height: 44px;
  }
}

@media (max-width: 390px) {
  app-legal-page .nav-actions .text-button,
  app-affiliate-program .nav-actions .text-button {
    display: none !important;
  }

  app-legal-page .nav-actions,
  app-affiliate-program .nav-actions {
    flex: 0 0 auto;
  }

  app-legal-page article,
  app-affiliate-program main > section {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  app-affiliate-dashboard table td {
    grid-template-columns: minmax(76px, 31%) minmax(0, 1fr);
    gap: 8px;
  }

  app-admin-status > div {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  app-platform-admin-command-center .overflow-x-auto {
    max-width: calc(100vw - 32px);
  }
}
