/**
 * DeVito Showings — "Request a Tour" stepper (Stage 1).
 * Redfin/Zillow-style structured modal. Mobile-first, compact (95% mobile).
 * Matches the DeVito theme: #CE011F red, #1a2332 navy, DM Sans / Playfair Display.
 * @version 1.0.0
 */

/* ── Overlay + panel ───────────────────────────────────────── */
#devito-tour-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
#devito-tour-modal.is-open { display: flex; }

#devito-tour-modal .dtm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 12, 18, 0.55);
    backdrop-filter: blur(2px);
}

#devito-tour-modal .dtm-panel {
    position: relative;
    width: 100%;
    max-width: 460px;
    max-height: 92vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.3);
    -webkit-overflow-scrolling: touch;
    animation: dtm-rise 0.22s ease;
}
@keyframes dtm-rise { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (min-width: 640px) {
    #devito-tour-modal { align-items: center; }
    #devito-tour-modal .dtm-panel { border-radius: 16px; }
}

/* ── Header ────────────────────────────────────────────────── */
.dtm-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
}
.dtm-header h2 {
    font-family: "Playfair Display", Georgia, serif;
    font-size: 1.15rem;
    line-height: 1.2;
    margin: 0;
    color: #1a2332;
    flex: 1;
}
.dtm-prop {
    display: block;
    font-family: "DM Sans", system-ui, sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    color: #CE011F;
    margin-top: 2px;
}
.dtm-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    color: #555;
    font-size: 20px;
    line-height: 1;
}
.dtm-close:hover { background: #e5e7eb; }

/* ── Progress dots ─────────────────────────────────────────── */
.dtm-progress {
    display: flex;
    gap: 6px;
    padding: 10px 18px 0;
}
.dtm-progress span {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: #e5e7eb;
    transition: background 0.2s ease;
}
.dtm-progress span.is-active,
.dtm-progress span.is-done { background: #CE011F; }

/* ── Step body ─────────────────────────────────────────────── */
.dtm-body { padding: 14px 18px 20px; font-family: "DM Sans", system-ui, sans-serif; }
.dtm-step { display: none; }
.dtm-step.is-active { display: block; }
.dtm-step-title { font-size: 0.95rem; font-weight: 600; color: #1a2332; margin: 0 0 10px; }

/* Fields */
.dtm-field { margin-bottom: 12px; }
.dtm-field label { display: block; font-size: 0.8rem; font-weight: 600; color: #374151; margin-bottom: 4px; }
.dtm-field .req { color: #CE011F; }
.dtm-field input,
.dtm-field select,
.dtm-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.92rem;
    font-family: inherit;
    color: #111;
    background: #fff;
    box-sizing: border-box;
}
.dtm-field input:focus,
.dtm-field select:focus,
.dtm-field textarea:focus {
    outline: none;
    border-color: #CE011F;
    box-shadow: 0 0 0 3px rgba(206, 1, 31, 0.12);
}
.dtm-field textarea { resize: vertical; min-height: 56px; }
.dtm-field.has-error input,
.dtm-field.has-error select { border-color: #CE011F; background: #fff5f6; }
.dtm-row { display: flex; gap: 10px; }
.dtm-row .dtm-field { flex: 1; }

/* Time-slot chips */
.dtm-times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dtm-time {
    padding: 9px 4px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    color: #1a2332;
    text-align: center;
}
.dtm-time:hover { border-color: #CE011F; }
.dtm-time.is-selected { background: #CE011F; color: #fff; border-color: #CE011F; }

/* Agent toggle */
.dtm-toggle { display: flex; gap: 8px; }
.dtm-toggle button {
    flex: 1;
    padding: 9px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    color: #1a2332;
}
.dtm-toggle button.is-selected { background: #1a2332; color: #fff; border-color: #1a2332; }

/* Agent gate notice (shown when buyer says they already have an agent) */
.dtm-agent-notice {
    display: none;
    margin-top: 8px;
    background: #fff8e6;
    border: 1px solid #f3dca0;
    color: #6b4e00;
    font-size: 0.82rem;
    line-height: 1.45;
    padding: 9px 11px;
    border-radius: 8px;
}
.dtm-agent-notice.is-shown { display: block; }
.dtm-agent-notice a { color: #6b4e00; font-weight: 600; }

/* Other-homes dynamic entries */
.dtm-other-list { display: none; margin-top: 8px; }
.dtm-other-list.is-shown { display: block; }
.dtm-other-rows .dtm-other-input {
    width: 100%;
    padding: 9px 12px;
    margin-bottom: 8px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    box-sizing: border-box;
}
.dtm-other-rows .dtm-other-input:focus { outline: none; border-color: #CE011F; box-shadow: 0 0 0 3px rgba(206,1,31,0.12); }
.dtm-add-home {
    background: none;
    border: none;
    color: #CE011F;
    font-weight: 600;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    padding: 2px 0;
}
.dtm-add-home:hover { text-decoration: underline; }

/* Code entry */
.dtm-code-input {
    letter-spacing: 0.5em;
    text-align: center;
    font-size: 1.4rem !important;
    font-weight: 600;
}
.dtm-code-hint { font-size: 0.8rem; color: #6b7280; margin: 0 0 12px; }

/* Error + actions */
.dtm-error {
    display: none;
    background: #fff5f6;
    border: 1px solid #f3c2c8;
    color: #a8011a;
    font-size: 0.82rem;
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.dtm-error.is-shown { display: block; }

.dtm-actions { display: flex; gap: 10px; margin-top: 6px; }
.dtm-btn {
    flex: 1;
    padding: 12px;
    border-radius: 9px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
}
.dtm-btn--primary { background: #CE011F; color: #fff; }
.dtm-btn--primary:hover { background: #a8011a; }
.dtm-btn--primary:disabled { background: #d99; cursor: not-allowed; }
.dtm-btn--ghost { background: #fff; color: #1a2332; border-color: #d1d5db; flex: 0 0 auto; padding: 12px 16px; }
.dtm-btn--ghost:hover { background: #f3f4f6; }

.dtm-fine { font-size: 0.72rem; color: #9ca3af; line-height: 1.4; margin: 12px 0 0; }
.dtm-fine a { color: #6b7280; }

/* Chat router CTA link (rendered by showing-assistant.js handleRedirect) */
.dsw-cta-link {
    display: inline-block;
    font-weight: 600;
    color: #CE011F;
    text-decoration: none;
}
.dsw-cta-link:hover { text-decoration: underline; }

/* Success */
.dtm-success { text-align: center; padding: 8px 4px 4px; }
.dtm-success-icon {
    width: 52px; height: 52px; margin: 0 auto 12px;
    border-radius: 50%; background: #e8f6ec; color: #1a8a3a;
    display: flex; align-items: center; justify-content: center;
}
.dtm-success-icon svg { width: 28px; height: 28px; }
.dtm-success h3 { font-family: "Playfair Display", Georgia, serif; color: #1a2332; margin: 0 0 8px; font-size: 1.2rem; }
.dtm-success p { color: #4b5563; font-size: 0.9rem; line-height: 1.5; margin: 0 0 6px; }

/* ── Signing page (page-showing-sign.php / Stage 3) ─────────── */
/* The /sign page has no dark hero, so the transparent, fixed site header would float over
   the white card (faded logo overlapping the heading). Make it solid + in-flow here — same
   fix pattern as the /team page. Body class added via body_class in showing-sign.php. */
body.dvsign-page #site-header,
body.dvsign-page .header--transparent {
    position: relative !important;
    background: #14181f !important;
    box-shadow: 0 2px 14px rgba(0,0,0,.18);
}
.dvsign-shell { padding: 28px 16px 56px; background: #f6f7f7; min-height: 60vh; font-family: "DM Sans", system-ui, sans-serif; }
.dvsign-container { max-width: 640px; margin: 0 auto; }
.dvsign-card { background: #fff; border-radius: 14px; box-shadow: 0 2px 18px rgba(0,0,0,0.07); padding: 22px 20px 26px; }
.dvsign-card--error h1 { color: #a8011a; }
.dvsign-head h1 { font-family: "Playfair Display", Georgia, serif; color: #1a2332; font-size: 1.4rem; margin: 0 0 6px; }
.dvsign-meta { color: #CE011F; font-weight: 600; font-size: 0.9rem; margin: 0 0 10px; }
.dvsign-intro { color: #4b5563; font-size: 0.92rem; line-height: 1.5; margin: 0 0 16px; }

.dvsign-doc { border: 1px solid #e5e7eb; border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.dvsign-doc summary {
    cursor: pointer; padding: 12px 14px; font-weight: 600; color: #1a2332;
    background: #fafafa; list-style: none; font-size: 0.92rem;
}
.dvsign-doc summary::-webkit-details-marker { display: none; }
.dvsign-doc summary::after { content: "▾"; float: right; color: #9ca3af; }
.dvsign-doc[open] summary::after { content: "▴"; }
.dvsign-doc-body { padding: 4px 16px 14px; font-size: 0.86rem; line-height: 1.55; color: #374151; }
.dvsign-doc-body p { margin: 0 0 10px; }
.dvsign-doc-body .dsd-ack { font-weight: 600; color: #1a2332; }

.dvsign-accept { margin-top: 18px; border-top: 1px solid #eee; padding-top: 16px; }
.dvsign-name span { display: block; font-size: 0.82rem; font-weight: 600; color: #374151; margin-bottom: 4px; }
.dvsign-name input {
    width: 100%; padding: 11px 12px; border: 1px solid #d1d5db; border-radius: 8px;
    font-size: 1rem; font-family: "Playfair Display", Georgia, serif; box-sizing: border-box;
}
.dvsign-name input:focus { outline: none; border-color: #CE011F; box-shadow: 0 0 0 3px rgba(206,1,31,0.12); }
.dvsign-check { display: flex; gap: 9px; margin: 14px 0 16px; font-size: 0.84rem; color: #4b5563; line-height: 1.45; }
.dvsign-check input { margin-top: 3px; flex-shrink: 0; width: 18px; height: 18px; }
.dvsign-btn {
    width: 100%; padding: 14px; border: none; border-radius: 9px; background: #CE011F; color: #fff;
    font-size: 1rem; font-weight: 600; font-family: inherit; cursor: pointer;
}
.dvsign-btn:hover { background: #a8011a; }
.dvsign-btn:disabled { background: #d99; cursor: not-allowed; }
.dvsign-fine { font-size: 0.74rem; color: #9ca3af; line-height: 1.45; margin: 12px 0 0; text-align: center; }

.dvsign-error { display: none; background: #fff5f6; border: 1px solid #f3c2c8; color: #a8011a; font-size: 0.85rem; padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; }
.dvsign-error.is-shown { display: block; }

.dvsign-done { text-align: center; padding: 14px 4px 4px; }
.dvsign-done-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: #e8f6ec; color: #1a8a3a; display: flex; align-items: center; justify-content: center; }
.dvsign-done-icon svg { width: 30px; height: 30px; }
.dvsign-done h2 { font-family: "Playfair Display", Georgia, serif; color: #1a2332; margin: 0 0 8px; }
.dvsign-done p { color: #4b5563; font-size: 0.92rem; }

/* ── Inline PDF viewer (PDF.js) on the sign page ─────────────── */
.dvsign-pdfwrap { margin: 10px 0 4px; }
.dvsign-viewbtn {
    background: #fff; border: 1px solid #d1d5db; border-radius: 8px; padding: 9px 13px;
    font-size: 0.85rem; font-weight: 600; color: #CE011F; cursor: pointer; font-family: inherit;
}
.dvsign-viewbtn:hover { border-color: #CE011F; }
.dvsign-pdfcanvas { display: none; margin-top: 10px; background: #eceef1; border-radius: 8px; padding: 8px; }
.dvsign-pdfwrap.is-open .dvsign-pdfcanvas { display: block; }
.dvsign-pdfpage { display: block; width: 100%; height: auto; border: 1px solid #cbd5e1; box-shadow: 0 1px 6px rgba(0,0,0,0.12); margin: 0 auto 10px; border-radius: 3px; background: #fff; }
.dvsign-pdfpage:last-child { margin-bottom: 0; }
.dvsign-pdfloading, .dvsign-pdferr { font-size: 0.82rem; color: #6b7280; padding: 10px 4px; text-align: center; }
.dvsign-pdferr a, .dvsign-pdffallback { color: #CE011F; }
.dvsign-pdffallback { display: inline-block; margin-top: 8px; font-size: 0.78rem; font-weight: 600; text-decoration: none; }
.dvsign-pdfwrap:not(.is-open) .dvsign-pdffallback { display: none; }

/* ── Sign page: mockup-style document cards ─────────────────── */
.dvsign-who { font-size: 0.8rem; color: #6b7280; background: #f3f4f6; border-radius: 8px; padding: 8px 11px; margin: 0 0 14px; }
.dvsign-who strong { color: #1a2332; }
.dvsign-cobuyer { border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px 12px; margin: 0 0 14px; }
.dvsign-cobuyer-hd { font-size: 0.68rem; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.dvsign-cobuyer-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.82rem; padding: 3px 0; color: #1a2332; }
.dvsign-mut { color: #9ca3af; font-weight: 400; }
.dvsign-tag-pending { background: #fef3c7; color: #92400e; font-weight: 700; border-radius: 999px; padding: 2px 8px; font-size: 0.72rem; }
.dvsign-cobuyer-note { font-size: 0.72rem; color: #0b3d64; background: #eef6ff; border: 1px solid #cfe3ff; border-radius: 6px; padding: 7px 9px; margin-top: 6px; line-height: 1.45; }

/* ── Co-buyer invite share block ─────────────────────────────── */
.dvco-invite { margin-top: 8px; padding: 11px 12px; background: #f0f7ff; border: 1px solid #cfe3ff; border-radius: 8px; }
.dvco-invite-hd { font-size: 0.82rem; font-weight: 700; color: #0b3d64; margin-bottom: 3px; }
.dvco-invite-sub { font-size: 0.74rem; color: #375a75; line-height: 1.45; margin: 0 0 9px; }
.dvco-invite-row { display: flex; gap: 7px; }
.dvco-invite-url { flex: 1 1 auto; min-width: 0; padding: 8px 9px; border: 1px solid #cfe3ff; border-radius: 7px; font-size: 0.78rem; color: #1a2332; background: #fff; }
.dvco-copy { flex: 0 0 auto; padding: 8px 14px; border: none; border-radius: 7px; background: #1a2332; color: #fff; font-size: 0.8rem; font-weight: 600; font-family: inherit; cursor: pointer; }
.dvco-copy:hover { background: #0f1622; }
.dvco-invite-actions { display: flex; align-items: center; gap: 14px; margin-top: 9px; }
.dvco-text { font-size: 0.82rem; font-weight: 600; color: #CE011F; text-decoration: none; }
.dvco-qr-toggle { background: none; border: none; padding: 0; font-size: 0.82rem; font-weight: 600; color: #0b3d64; cursor: pointer; font-family: inherit; }
.dvco-qr { display: none; margin-top: 11px; padding: 10px; background: #fff; border: 1px solid #cfe3ff; border-radius: 8px; width: fit-content; }
.dvco-qr.is-open { display: block; }
.dvco-qr img, .dvco-qr canvas { display: block; }
.dvco-qr-fallback { font-size: 0.74rem; color: #375a75; margin: 0; }

/* Co-buyer stepper resend link */
.dvsign-linkbtn { display: block; width: 100%; margin-top: 10px; background: none; border: none; color: #CE011F; font-size: 0.82rem; font-weight: 600; font-family: inherit; cursor: pointer; }

.dvsign-doccard { border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.dvsign-doc-hd { display: flex; align-items: center; gap: 10px; }
.dvsign-doc-ic { width: 30px; height: 30px; border-radius: 8px; background: #f3f4f6; display: flex; align-items: center; justify-content: center; font-size: 15px; flex: 0 0 auto; }
.dvsign-doc-tt { font-size: 0.92rem; font-weight: 600; color: #1a2332; }
.dvsign-doc-tag { margin-left: auto; font-size: 0.68rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #fef3c7; color: #92400e; white-space: nowrap; }
.dvsign-doc-sum { font-size: 0.82rem; color: #0b3d64; background: #f0f7ff; border: 1px solid #cfe3ff; border-radius: 8px; padding: 9px 11px; margin: 10px 0 0; line-height: 1.5; }
.dvsign-doc-full { margin-top: 10px; }
.dvsign-doc-full > summary { cursor: pointer; font-size: 0.82rem; font-weight: 600; color: #CE011F; list-style: none; }
.dvsign-doc-full > summary::-webkit-details-marker { display: none; }
.dvsign-doc-full > summary::after { content: " ▾"; color: #9ca3af; }
.dvsign-doc-full[open] > summary::after { content: " ▴"; }
.dvsign-doc-full .dvsign-doc-body { padding: 10px 2px 2px; font-size: 0.84rem; line-height: 1.55; color: #374151; }
.dvsign-doc-full .dvsign-doc-body p { margin: 0 0 10px; }
.dvsign-doc-full .dvsign-doc-body .dsd-ack { font-weight: 600; color: #1a2332; }
