/**
 * Client Portal — mobile UX (phones first; tablets usable).
 * Behavior playbook aligned with rewindmediaevents.com mobile patterns.
 * Brand colors/fonts stay as-is.
 */

html.portal-mobile-ux {
  overflow-x: hidden;
}

html.portal-mobile-ux body {
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* Offline / unreachable banner */
.portal-net-banner {
  display: none;
  position: sticky;
  top: 0;
  z-index: 300;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0));
  background: #17183b;
  color: #fdf5e6;
  font-family: Montserrat, system-ui, sans-serif;
  font-size: 0.8125rem;
  line-height: 1.4;
  border-bottom: 2px solid #fdc90d;
}

html.portal-mobile-ux.portal-offline .portal-net-banner,
html.portal-mobile-ux.portal-net-error .portal-net-banner {
  display: flex;
}

.portal-net-banner strong {
  font-family: "Josefin Sans", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: #fdc90d;
}

.portal-net-banner button {
  flex-shrink: 0;
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.85rem;
  border: 1.5px solid #27cbe3;
  border-radius: 10px;
  background: transparent;
  color: #27cbe3;
  font-family: Montserrat, system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* Section jump chips (booking page) */
.portal-jump-nav {
  display: none;
  position: sticky;
  top: 0;
  z-index: 80;
  gap: 0.5rem;
  padding: 0.5rem 0;
  margin: 0 0 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  background: linear-gradient(180deg, var(--bg, #0d0e24) 70%, transparent);
}

html.portal-mobile-ux .portal-jump-nav.is-ready {
  display: flex;
}

.portal-jump-nav a {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(245, 240, 234, 0.12));
  background: var(--surface, #161736);
  color: var(--text-muted, #a09db0);
  font-family: Montserrat, system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.portal-jump-nav a:focus-visible,
.portal-jump-nav a.is-active {
  border-color: var(--coral, #f25c5c);
  color: var(--cream, #fdf5e6);
  outline: none;
}

/* External handoff note (Stripe / DocuSeal) */
.portal-handoff-note {
  display: none;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(39, 203, 227, 0.35);
  background: rgba(39, 203, 227, 0.08);
  color: var(--text-muted, #a09db0);
  font-size: 0.85rem;
  line-height: 1.5;
}

html.portal-mobile-ux .portal-handoff-note {
  display: block;
}

.portal-handoff-note strong {
  color: var(--cyan, #27cbe3);
  font-weight: 600;
}

/* Toast-style action errors (replace silent / alert failures) */
.portal-action-toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 400;
  display: none;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(242, 92, 92, 0.95);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

html.portal-mobile-ux .portal-action-toast.is-visible {
  display: block;
}

.portal-action-toast--warn {
  background: rgba(253, 201, 13, 0.95);
  color: #17183b;
}

.portal-action-toast--ok {
  background: rgba(151, 204, 4, 0.95);
  color: #0d0e24;
}

/* Sticky primary CTA bar on phones */
.portal-sticky-cta {
  display: none;
}

@media (max-width: 768px) {
  html.portal-mobile-ux {
    /* Prevent iOS zoom on focus */
  }

  html.portal-mobile-ux input,
  html.portal-mobile-ux textarea,
  html.portal-mobile-ux select {
    font-size: 16px !important;
  }

  html.portal-mobile-ux .btn,
  html.portal-mobile-ux button:not(.portal-net-banner button) {
    min-height: 48px;
  }

  html.portal-mobile-ux .page {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  /* Proposal / quote lines → stacked cards (no sideways scroll) */
  html.portal-mobile-ux .proposal-table {
    display: block;
    width: 100%;
  }

  html.portal-mobile-ux .proposal-table thead {
    display: none;
  }

  html.portal-mobile-ux .proposal-table tbody,
  html.portal-mobile-ux .proposal-table tfoot {
    display: block;
    width: 100%;
  }

  html.portal-mobile-ux .proposal-table tr {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px 12px;
    width: 100%;
    margin-bottom: 8px;
    padding: 12px 14px;
    border: 1px solid var(--border, rgba(245, 240, 234, 0.12));
    border-radius: 10px;
    background: var(--bg, #0d0e24);
  }

  html.portal-mobile-ux .proposal-table td {
    display: block;
    border: none;
    padding: 0;
  }

  html.portal-mobile-ux .proposal-table td:first-child {
    flex: 1 1 60%;
    font-weight: 600;
  }

  html.portal-mobile-ux .proposal-table td.amount {
    flex: 0 0 auto;
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  html.portal-mobile-ux .proposal-table tfoot tr {
    border-color: var(--coral, #f25c5c);
    background: var(--surface-2, #1e2045);
  }

  /* Chat / email composers: full-width comfortable */
  html.portal-mobile-ux .chat-thread,
  html.portal-mobile-ux .revision-thread {
    max-height: min(50vh, 360px);
  }

  html.portal-mobile-ux .doc-sheet {
    padding: 14px;
  }

  html.portal-mobile-ux .doc-sheet-header {
    flex-direction: column;
    align-items: flex-start;
  }

  html.portal-mobile-ux .doc-sheet-meta[style*="text-align:right"] {
    text-align: left !important;
  }

  /* Sticky CTA when pay/approve exist */
  html.portal-mobile-ux .portal-sticky-cta.is-ready {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(13, 14, 36, 0.94);
    border-top: 1px solid var(--border, rgba(245, 240, 234, 0.12));
    backdrop-filter: blur(8px);
  }

  html.portal-mobile-ux .portal-sticky-cta .btn {
    flex: 1;
    min-height: 48px;
    text-decoration: none;
  }

  /* Login card: safer keyboard room */
  html.portal-mobile-ux main {
    padding: 20px 12px 32px;
    align-items: flex-start;
  }

  html.portal-mobile-ux .card {
    margin-top: 12px;
  }

  html.portal-mobile-ux .header .brand-name {
    font-size: 0.95rem;
  }

  html.portal-mobile-ux .header .brand img {
    height: 40px;
  }

  html.portal-mobile-ux .client-name {
    font-size: 1.35rem;
    word-break: break-word;
  }

  /* Partial pay row: stack cleanly */
  html.portal-mobile-ux #partial-amount {
    width: 100% !important;
    max-width: none;
    min-height: 48px;
  }
}

@media (min-width: 769px) {
  html.portal-mobile-ux .portal-sticky-cta {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.portal-mobile-ux * {
    scroll-behavior: auto !important;
  }
}
