/**
 * V3 phone/tablet presentation overrides.
 * Desktop (≥1024px portal, ≥768px forms) stays on existing Tailwind/page CSS.
 */

.portal-back-to-quotes {
  display: none;
}

/* JS toggles .hidden on #headerDrafts; make it win over .flex at all widths. */
#headerDrafts.hidden {
  display: none !important;
}

/* —— Quote Portal: list / detail below 1024px —— */
@media (max-width: 1023px) {
  #quotePortalPanel {
    min-height: auto;
    overflow: visible;
  }

  .portal-split-section {
    overflow: visible;
    flex: none;
    height: auto;
  }

  .portal-split {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .quote-archive-pane {
    width: 100% !important;
    height: auto;
    min-height: 70vh;
  }

  .quote-detail-pane {
    display: none !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto;
    overflow: visible;
    padding: 1.25rem;
  }

  .quote-card,
  .quote-card * {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(68, 53, 227, 0.12);
  }

  #quotePortalPanel.portal-mobile-detail .portal-list-chrome {
    display: none !important;
  }

  #quotePortalPanel.portal-mobile-detail .quote-archive-pane {
    display: none !important;
  }

  #quotePortalPanel.portal-mobile-detail .quote-detail-pane {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 70vh;
    flex: 1 1 auto;
  }

  #quotePortalPanel.portal-mobile-detail .portal-back-to-quotes {
    display: inline-flex !important;
  }
}

@media (min-width: 1024px) {
  .portal-back-to-quotes {
    display: none !important;
  }
}

/* —— Search / filter wrap below 768px —— */
@media (max-width: 767px) {
  .portal-search-toolbar {
    flex-wrap: wrap;
    white-space: normal;
    overflow: visible;
  }

  #search {
    min-width: 0;
    width: 100%;
  }

  #destFilter,
  #sortFilter {
    width: 100%;
  }

  /* Quote detail actions */
  #detailPane > header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  #detailPane > header > div.flex {
    flex-wrap: wrap;
    width: 100%;
    align-items: stretch;
  }

  #viewPdfBtn,
  .det-action-btn {
    width: 100%;
    margin-left: 0 !important;
    min-height: 44px;
    justify-content: center;
    font-size: 14px;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  /* Quote-entry inputs: ≥16px to avoid iOS focus zoom */
  #quoteForm input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
  #quoteForm select,
  #quoteForm textarea,
  #quoteForm .input-field {
    font-size: 16px !important;
  }

  .quote-table th,
  .quote-table td {
    min-width: 9.5rem;
  }

  .quote-table input:not([type="hidden"]),
  .quote-table select,
  .quote-table textarea {
    font-size: 16px !important;
    min-height: 44px;
    padding: 0.5rem 0.65rem;
  }

  #quoteForm .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
  }

  #quoteForm .overflow-x-auto::before {
    content: "Swipe sideways for all columns";
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 0.5rem;
  }

  #quoteForm {
    padding-bottom: 5.5rem;
  }

  .quote-submit-bar {
    position: sticky;
    bottom: 0;
    z-index: 30;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-left: -1rem;
    margin-right: -1rem;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
  }

  #submitBtn {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  header .max-w-7xl {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

/* Destination quote pages share header.html — stack cleanly on phones without changing desktop. */
@media (max-width: 1023px) {
  .quote-entry-header-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand user"
      "back back";
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0.5rem;
    height: auto !important;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .quote-entry-brand {
    grid-area: brand;
    min-width: 0;
    flex: none !important;
  }

  .quote-entry-back {
    grid-area: back;
    width: 100%;
    min-height: 44px;
    justify-content: center;
    margin-top: 0 !important;
    font-size: 11px;
  }

  .quote-entry-user {
    grid-area: user;
    min-width: 0;
  }

  .quote-entry-user #who {
    max-width: 8.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .quote-entry-user a[data-signout] {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}
