/* =============================================================
   AskPerTask — Make Offer Modal  (apt-offer-modal.css)

   Loaded on:
     requests_view_page  → /requests/
     request_view_page   → /request/{slug}/
     requests_edit_page  → /account/requests/

   Tokens on :root so they apply both inside .hp-modal and on
   request cards rendered outside the modal context.
   ============================================================= */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --apt-om-text:        #1A1A1A;
  --apt-om-muted:       #6B7280;
  --apt-om-border:      #E5E7EB;
  --apt-om-bg-card:     #F9FAFB;
  --apt-om-blue:        #2D6CDF;
  --apt-om-blue-light:  #EAF1FD;
  --apt-om-green:       #1FA34A;
  --apt-om-green-light: #E8F7EE;
  --apt-om-orange:      #C4611A;
  --apt-om-orange-bg:   #FFF4EE;
  --apt-om-radius:      8px;
  --apt-om-radius-sm:   4px;
}

/* =============================================================
   MAKE-OFFER-MODAL-VISUAL-REDESIGN-1A

   Everything below that touches the modal SHELL (width/padding/title) is
   scoped with :has(.apt-offer-intro) — a class unique to this modal's own
   injected content — so it can never affect any other Fancybox/.hp-modal
   instance sitewide (login, register, delete-request, etc.). Everything
   scoped under .apt-om-card / .hp-form--offer-make is already naturally
   specific to this modal's own markup.
   ============================================================= */

/* ── Modal shell ────────────────────────────────────────────── */
.hp-modal:has(.apt-offer-intro) {
  width: min(640px, calc(100vw - 48px));
  max-width: 640px;
  box-sizing: border-box;
  padding: 28px 28px 24px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.hp-modal:has(.apt-offer-intro) .hp-modal__title {
  font-size: 1.25rem;
}

/* ── Intro section ─────────────────────────────────────────── */
.hp-modal .apt-offer-intro {
  margin-bottom: 20px;
}

.hp-modal .apt-offer-intro__lead {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--apt-om-muted);
  line-height: 1.4;
}

/* ── Request summary card: LEFT image / CENTER details / RIGHT requester ── */
.hp-modal .apt-om-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--apt-om-bg-card);
  border: 1px solid var(--apt-om-border);
  border-radius: var(--apt-om-radius);
  margin-bottom: 4px;
}

.hp-modal .apt-om-card--summary {
  align-items: stretch;
  gap: 16px;
  padding: 16px;
}

/* Thumbnail (left) */
.hp-modal .apt-om-card__image {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: var(--apt-om-radius-sm);
  overflow: hidden;
}

.hp-modal .apt-om-card--summary .apt-om-card__image {
  flex-basis: 84px;
  width: 84px;
  height: 84px;
}

.hp-modal .apt-om-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Card body (legacy — kept for any other consumer of .apt-om-card__body) */
.hp-modal .apt-om-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

/* Center column (new — request details) */
.hp-modal .apt-om-card__center {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

/* Right column — requester identity. Real data only: avatar, first
   name (or display_name), real verification/trust badges — same safe
   sources as class-apt-browse-pages.php's requester strip. No phone,
   email, or address is shown here or anywhere else in this modal. */
.hp-modal .apt-om-card__requester {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-width: 108px;
  padding-left: 16px;
  border-left: 1px solid var(--apt-om-border);
  text-align: center;
}

.hp-modal .apt-om-requester__avatar {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  object-fit: cover;
  display: block;
}

.hp-modal .apt-om-requester__name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--apt-om-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.hp-modal .apt-om-requester__badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
}

/* Badges row */
.hp-modal .apt-om-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.hp-modal .apt-om-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  line-height: 1.5;
}

.hp-modal .apt-om-badge--type {
  background: var(--apt-om-blue-light);
  color: var(--apt-om-blue);
}

.hp-modal .apt-om-badge--timing {
  background: var(--apt-om-orange-bg);
  color: var(--apt-om-orange);
}

/* Title — was single-line ellipsis at the old 64px-column width; the
   summary card now has real room, so allow a 2-line wrap instead. */
.hp-modal .apt-om-card__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--apt-om-text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Meta rows: category, location — single line with ellipsis; the full
   value is still available via the native title="" attribute. */
.hp-modal .apt-om-card__meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--apt-om-muted);
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp-modal .apt-om-card__meta .hp-icon {
  font-size: 0.7rem;
  flex-shrink: 0;
}

/* Budget */
.hp-modal .apt-om-card__budget {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--apt-om-text);
  margin-top: 2px;
}

.hp-modal .apt-om-card__budget strong {
  font-weight: 600;
}

/* ── Offer form (.hp-form--offer-make) ───────────────────────
   Field/button classes below are confirmed against the real rendered
   markup (hp-form__field, hp-form__field--number/--textarea, hp-form__
   footer, hp-form__button) — not guessed from other HivePress forms. */

.hp-modal .hp-form--offer-make {
  margin-top: 4px;
}

.hp-modal .hp-form--offer-make .hp-form__field {
  margin-bottom: 22px;
}

.hp-modal .hp-form--offer-make .hp-form__field:last-child {
  margin-bottom: 0;
}

/* Field label */
.hp-modal .hp-form--offer-make .hp-field__label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--apt-om-text);
  margin-bottom: 4px;
}

/* Field description / helper text */
.hp-modal .hp-form--offer-make .hp-field__description {
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: var(--apt-om-muted);
  line-height: 1.4;
}

/* Amount / price field — the offer's headline number, so it gets its
   own visual weight instead of matching a generic text input. */
.hp-modal .hp-form--offer-make .hp-form__field--number input[type="number"] {
  height: 56px;
  padding: 0 16px;
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--apt-om-text);
  background: #fff;
  border: 1.5px solid var(--apt-om-border);
  border-radius: var(--apt-om-radius-sm);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hp-modal .hp-form--offer-make .hp-form__field--number input[type="number"]:focus {
  border-color: var(--apt-om-blue);
  box-shadow: 0 0 0 3px var(--apt-om-blue-light);
}

/* Message textarea — comfortable height, same input chrome as the price
   field so the two primary fields read as one consistent form. */
.hp-modal .hp-form--offer-make .hp-form__field--textarea textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--apt-om-text);
  background: #fff;
  border: 1.5px solid var(--apt-om-border);
  border-radius: var(--apt-om-radius-sm);
  outline: none;
  resize: vertical;
  box-sizing: border-box;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hp-modal .hp-form--offer-make .hp-form__field--textarea textarea:focus {
  border-color: var(--apt-om-blue);
  box-shadow: 0 0 0 3px var(--apt-om-blue-light);
}

/* Server-round-trip validation errors — HivePress adds this class to a
   field after a failed AJAX validation. Gives it the same red-border
   treatment used across the rest of the AskPerTask forms instead of a
   default/browser-looking outline. */
.hp-modal .hp-form--offer-make input.hp-field--invalid,
.hp-modal .hp-form--offer-make textarea.hp-field--invalid {
  border-color: #DC2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
}

/* Error message banner (server-round-trip errors) */
.hp-modal .hp-form--offer-make .hp-form__messages[data-component="messages"]:not(:empty) {
  padding: 12px 14px;
  border-radius: var(--apt-om-radius-sm);
  font-size: 0.85rem;
  margin-bottom: 18px;
  border: 1px solid #FECACA;
  background: #FEF2F2;
  color: #DC2626;
}

/* Footer / CTA hierarchy: Submit Offer (primary, real HivePress button)
   stacked above Cancel (secondary — see .apt-offer-actions-secondary
   below, a sibling block after the form, styled to sit directly under
   the submit button). */
.hp-modal .hp-form--offer-make .hp-form__footer {
  margin-top: 4px;
  padding-top: 4px;
}

.hp-modal .hp-form--offer-make .hp-form__button {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100% !important;
  height: 52px;
  background: var(--apt-om-green) !important;
  color: #fff !important;
  font-size: 1rem;
  font-weight: 600;
  border: none !important;
  border-radius: var(--apt-om-radius) !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: background 0.15s ease;
}

.hp-modal .hp-form--offer-make .hp-form__button:hover {
  background: #168238 !important;
}

.hp-modal .hp-form--offer-make .hp-form__button:disabled,
.hp-modal .hp-form--offer-make .hp-form__button[data-state="loading"] {
  background: #9CA3AF !important;
  cursor: not-allowed;
}

/* Secondary Cancel action — closes the modal via Fancybox's own
   [data-fancybox-close] trigger; see build_secondary_actions_html(). */
.hp-modal .apt-offer-actions-secondary {
  margin-top: 10px;
}

.hp-modal .apt-offer-cancel {
  display: block;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: none;
  color: var(--apt-om-muted);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
}

.hp-modal .apt-offer-cancel:hover {
  color: var(--apt-om-text);
}

/* ── Modal title polish ─────────────────────────────────────── */
.hp-modal .hp-modal__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--apt-om-text);
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--apt-om-border);
}

/* ── Request owner state (R-4.3-D) ──────────────────────────── */

/* Card label — non-interactive, muted */
.apt-offer-owner--card {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--apt-om-muted);
  padding: 2px 6px;
  background: var(--apt-om-bg-card);
  border: 1px solid var(--apt-om-border);
  border-radius: var(--apt-om-radius-sm);
  line-height: 1.4;
  white-space: nowrap;
}

/* Page helper text container */
.apt-offer-owner {
  padding: 10px 0 4px;
}

.apt-offer-owner__note {
  margin: 0 0 4px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--apt-om-text);
  line-height: 1.4;
}

.apt-offer-owner__sub {
  margin: 0;
  font-size: 0.8rem;
  color: var(--apt-om-muted);
  line-height: 1.4;
}

/* ── Offer count badge (R-4.3-E) ────────────────────────────── */

/* Wrapper used when count > 0 — stacks "Your request" + count badge */
.apt-offer-owner-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

/* Card pill link */
.apt-offer-count--card {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--apt-om-blue);
  background: var(--apt-om-blue-light);
  padding: 2px 7px;
  border-radius: var(--apt-om-radius-sm);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.apt-offer-count--card:hover {
  opacity: 0.82;
  color: var(--apt-om-blue);
  text-decoration: none;
}

/* Page inline anchor (inside .apt-offer-owner on single request page) */
.apt-offer-count--page {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--apt-om-blue);
  text-decoration: none;
  margin-top: 6px;
}

.apt-offer-count--page:hover {
  text-decoration: underline;
  color: var(--apt-om-blue);
}

/* ── Existing offer guard (R-4.3-C) ─────────────────────────── */

/* Card icon button — green tint signals "already done" */
.apt-offer-existing--card {
  color: var(--apt-om-green) !important;
  pointer-events: auto;
}

.apt-offer-existing--card:hover {
  opacity: 0.8;
}

/* Page full-width button wrapper */
.apt-offer-existing-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Page button — reuses HivePress primary button classes; no extra override needed.
   The wrapper controls the note layout. */
.apt-offer-existing--page {
  text-align: center;
}

/* Helper note below the page button */
.apt-offer-existing__note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--apt-om-muted);
  text-align: center;
  line-height: 1.4;
}

/* ── Pending offer state (R-7A) ─────────────────────────────── */

/* Card icon — amber clock, non-interactive */
.apt-offer-pending--card {
  color: var(--apt-om-orange) !important;
  pointer-events: none;
  cursor: default;
}

/* Page status block */
.apt-offer-pending--page {
  padding: 10px 0 4px;
}

.apt-offer-pending__title {
  margin: 0 0 4px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--apt-om-text);
  line-height: 1.4;
}

.apt-offer-pending__note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--apt-om-muted);
  line-height: 1.4;
}

/* ── Ineligible mode state (R-4.1-G) ────────────────────────────
   Shown to a logged-in user whose helper/vendor mode does not match
   the request type — advisory copy + link, no offer form. */

/* Card icon — muted info glyph, non-interactive styling but still a link */
.apt-offer-ineligible--card {
  color: var(--apt-om-muted) !important;
}

.apt-offer-ineligible--card:hover {
  opacity: 0.8;
}

/* Page helper text container */
.apt-offer-ineligible--page {
  padding: 10px 0 4px;
}

.apt-offer-ineligible__note {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--apt-om-muted);
  line-height: 1.45;
}

.apt-offer-ineligible__link {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--apt-om-blue);
  text-decoration: none;
}

.apt-offer-ineligible__link:hover {
  text-decoration: underline;
  color: var(--apt-om-blue);
}

/* ── Offer confirmation state ────────────────────────────────── */

/* Allow the message container to display our injected panel cleanly. */
.hp-modal .hp-form__messages--success {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
}

.hp-modal .apt-offer-confirm {
  padding: 16px 0 8px;
  text-align: center;
}

.hp-modal .apt-offer-confirm__icon {
  font-size: 2.8rem;
  color: var(--apt-om-green);
  margin-bottom: 14px;
  line-height: 1;
}

.hp-modal .apt-offer-confirm__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--apt-om-text);
  margin: 0 0 8px;
}

.hp-modal .apt-offer-confirm__body {
  font-size: 0.9rem;
  color: var(--apt-om-text);
  margin: 0 0 6px;
}

.hp-modal .apt-oc__price {
  font-size: 0.92rem;
  color: var(--apt-om-text);
  margin: 0 0 6px;
}

.hp-modal .apt-oc__price strong {
  font-weight: 700;
}

.hp-modal .apt-offer-confirm__next {
  font-size: 0.8rem;
  color: var(--apt-om-muted);
  margin: 0 auto 20px;
  line-height: 1.5;
  max-width: 30ch;
}

.hp-modal .apt-offer-confirm__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hp-modal .apt-offer-confirm__btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--apt-om-radius);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: none;
  line-height: 1.4;
  box-sizing: border-box;
  transition: opacity 0.15s;
}

.hp-modal .apt-offer-confirm__btn:hover {
  opacity: 0.85;
  text-decoration: none;
}

.hp-modal .apt-offer-confirm__btn--primary {
  background: var(--apt-om-blue);
  color: #fff;
}

.hp-modal .apt-offer-confirm__btn--primary:hover {
  color: #fff;
}

.hp-modal .apt-offer-confirm__btn--secondary {
  background: var(--apt-om-bg-card);
  color: var(--apt-om-blue);
  border: 1px solid var(--apt-om-border);
}

.hp-modal .apt-offer-confirm__btn--secondary:hover {
  color: var(--apt-om-blue);
}

.hp-modal .apt-offer-confirm__btn--close {
  background: transparent;
  color: var(--apt-om-muted);
  font-size: 0.82rem;
  font-weight: 400;
  padding: 6px;
}

.hp-modal .apt-offer-confirm__btn--close:hover {
  color: var(--apt-om-text);
  background: var(--apt-om-bg-card);
  opacity: 1;
}

/* ── View Profile alongside Accept Offer (R-4.3-F) ─────────── */

/* Flex row so View Profile and Accept Offer sit side by side   */
.hp-offer--view-block .hp-offer__actions--primary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
}

/* Secondary link appearance — less prominent than the primary button */
.apt-view-profile {
  font-size: 0.875rem;
  color: var(--apt-om-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: color 0.15s;
}

.apt-view-profile:hover {
  color: var(--apt-om-blue);
  text-decoration: none;
}

.apt-view-profile .hp-icon {
  font-size: 0.8rem;
}

/* ── Accept Offer confirmation overlay (R-5.2-A) ────────────── */

/* Full-screen fixed container — sits above everything */
.apt-accept-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.apt-accept-overlay[hidden] {
  display: none;
}

/* Semi-transparent backdrop */
.apt-accept-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

/* Dialog box */
.apt-accept-dialog {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: var(--apt-om-radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
  padding: 28px 24px 24px;
  width: 100%;
  max-width: 400px;
  box-sizing: border-box;
}

.apt-accept-dialog__title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--apt-om-text);
}

.apt-accept-dialog__lead {
  margin: 0 0 18px;
  font-size: 0.9rem;
  color: var(--apt-om-muted);
  line-height: 1.5;
}

/* Summary table */
.apt-accept-summary {
  margin: 0 0 22px;
  padding: 14px 16px;
  background: var(--apt-om-bg-card);
  border: 1px solid var(--apt-om-border);
  border-radius: var(--apt-om-radius-sm);
}

.apt-accept-summary__row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--apt-om-border);
}

.apt-accept-summary__row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.apt-accept-summary__row:first-child {
  padding-top: 0;
}

.apt-accept-summary__label {
  flex: 0 0 90px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--apt-om-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.apt-accept-summary__value {
  flex: 1;
  font-size: 0.88rem;
  color: var(--apt-om-text);
  font-weight: 500;
  word-break: break-word;
}

/* Action buttons */
.apt-accept-dialog__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.apt-accept-dialog__btn {
  display: block;
  width: 100%;
  padding: 11px 16px;
  border-radius: var(--apt-om-radius);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: none;
  line-height: 1.4;
  box-sizing: border-box;
  transition: opacity 0.15s;
  font-family: inherit;
}

.apt-accept-dialog__btn:hover {
  opacity: 0.85;
  text-decoration: none;
}

.apt-accept-dialog__btn--primary {
  background: var(--apt-om-blue);
  color: #fff !important;
}

.apt-accept-dialog__btn--primary:hover {
  color: #fff !important;
}

.apt-accept-dialog__btn--cancel {
  background: transparent;
  color: var(--apt-om-muted);
  border: 1px solid var(--apt-om-border);
  font-size: 0.85rem;
  font-weight: 500;
}

.apt-accept-dialog__btn--cancel:hover {
  color: var(--apt-om-text);
  background: var(--apt-om-bg-card);
  opacity: 1;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media ( max-width: 640px ) {
  .hp-modal:has(.apt-offer-intro) {
    width: calc(100vw - 24px);
    padding: 20px 18px 18px;
    max-height: 92vh;
  }

  .hp-modal .apt-om-card {
    flex-direction: column;
    gap: 8px;
  }

  .hp-modal .apt-om-card__image {
    width: 100%;
    height: 120px;
    flex: none;
  }

  .hp-modal .apt-om-card--summary .apt-om-card__image {
    width: 100%;
    height: 120px;
  }

  .hp-modal .apt-om-card__title {
    white-space: normal;
  }

  /* Requester column drops below the request details as a horizontal
     row instead of a narrow right-hand column. */
  .hp-modal .apt-om-card__requester {
    flex-direction: row;
    max-width: none;
    padding-left: 0;
    padding-top: 12px;
    border-left: none;
    border-top: 1px solid var(--apt-om-border);
    justify-content: flex-start;
    text-align: left;
  }

  .hp-modal .apt-om-requester__badges {
    justify-content: flex-start;
  }
}
