/*
 * Public estimate signing page (PropertyWorks payments — Phase 1).
 * Self-contained, on-brand (MLPW) styles for /pw/estimate/{token}. Independent of the app theme
 * tokens (this is a public, customer-facing document opened from an email on any device), so all
 * colors are literal brand values matching the estimate PDF: Pine, Moss, Clay, Rust, Cream, Charcoal.
 * Mobile-first; the layout caps at a readable document width on larger screens.
 */

:root {
    --pwe-pine: #2c3e2d;
    --pwe-moss: #5a6b4c;
    --pwe-clay: #8b6f47;
    --pwe-rust: #b5651d;
    --pwe-rust-dark: #8e4f15;
    --pwe-cream: #f5f1e8;
    --pwe-charcoal: #1f2422;
    --pwe-stone: #57534c;
    --pwe-line: #d9d4c7;
}

.pwe-shell {
    min-height: 100vh;
    background: var(--pwe-cream);
    color: var(--pwe-charcoal);
    font-family: 'Open Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.pwe-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px 64px;
    box-sizing: border-box;
}

/* ---- Theme immunity ----
 * This is a public, customer-facing document opened from an email on ANY device, so it must read
 * identically regardless of the viewer's saved app theme. The app applies [data-theme="dark"]/.dark
 * to <html> from that preference, and structra-theme.css's global dark-mode heading rule
 * ([data-theme="dark"] h1, specificity 0,1,1) out-specifies our single-class heading selectors —
 * which would paint our brand headings in the dark-mode (light) text color on these white cards,
 * making them nearly invisible. Re-assert the brand heading color with a .pwe-shell scope (0,2,0)
 * so it wins in both themes. (Body copy already wins via .pwe-status .pwe-muted.) */
.pwe-shell h1, .pwe-shell h2, .pwe-shell h3, .pwe-shell h4, .pwe-shell h5, .pwe-shell h6 {
    color: var(--pwe-pine);
}

/* Same leak, for <p>/<label> elements: structra-theme.css also restyles bare body/p/a/label in dark
 * mode ([data-theme="dark"] p|label, specificity 0,1,1), which out-specifies our single-class color
 * rules and washes out the form field labels, consent text, and fine print. Re-assert each class's
 * intended brand color with a .pwe-shell scope (0,2,0). (Spans/divs inherit the shell color and are
 * unaffected; only <p>/<label>/<a> have competing global dark rules.) */
.pwe-shell .pwe-label,
.pwe-shell .pwe-consent,
.pwe-shell .pwe-scope__item { color: var(--pwe-charcoal); }
.pwe-shell .pwe-muted,
.pwe-shell .pwe-fineprint,
.pwe-shell .pwe-canvas-hint,
.pwe-shell .pwe-party__line,
.pwe-shell .pwe-head__contact,
.pwe-shell .pwe-head__doc-meta,
.pwe-shell .pwe-option__desc,
.pwe-shell .pwe-option__list { color: var(--pwe-stone); }
.pwe-shell .pwe-discount { color: var(--pwe-moss); }

/* ---- Generic ---- */
.pwe-muted { color: var(--pwe-stone); font-size: 0.92rem; line-height: 1.5; }
.pwe-dot { margin: 0 0.35rem; color: var(--pwe-stone); }
.pwe-center { text-align: center; }

.pwe-card {
    background: #fff;
    border: 1px solid var(--pwe-line);
    border-radius: 12px;
    padding: 32px 24px;
    box-shadow: 0 6px 20px rgba(31, 36, 34, 0.06);
}

/* ---- Status (loading / not found / expired / signed) ---- */
.pwe-status { margin-top: 8vh; }
.pwe-status__icon {
    width: 64px; height: 64px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 32px; line-height: 1; margin-bottom: 16px;
}
.pwe-status__icon--ok { background: rgba(90, 107, 76, 0.15); color: var(--pwe-pine); }
.pwe-status__icon--warn { background: rgba(181, 101, 29, 0.14); color: var(--pwe-rust); }
.pwe-status__title { font-family: 'Poppins', sans-serif; font-size: 1.4rem; font-weight: 700; color: var(--pwe-pine); margin: 0 0 8px; }
/* The status screens' primary message is the focal text — use the dark charcoal (not the muted
   stone) so it reads at full contrast on the white card. */
.pwe-status .pwe-muted { color: var(--pwe-charcoal); }
.pwe-status__contact { margin-top: 16px; font-size: 0.85rem; }

/* ---- Document ---- */
.pwe-doc {
    background: #fff;
    border: 1px solid var(--pwe-line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(31, 36, 34, 0.06);
}

.pwe-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
    padding: 24px;
    border-bottom: 3px solid var(--pwe-pine);
}
.pwe-head__name { font-family: 'Poppins', serif; font-weight: 700; font-size: 1.25rem; color: var(--pwe-pine); }
.pwe-head__contact { font-size: 0.82rem; color: var(--pwe-stone); margin-top: 4px; }
.pwe-head__doc { text-align: right; flex-shrink: 0; }
.pwe-head__doc-label { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--pwe-clay); font-weight: 600; }
.pwe-head__doc-num { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1.3rem; color: var(--pwe-rust); }
.pwe-head__doc-meta { font-size: 0.8rem; color: var(--pwe-stone); margin-top: 2px; }

.pwe-parties {
    display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 20px 24px;
    background: var(--pwe-cream);
    border-bottom: 1px solid var(--pwe-line);
}
.pwe-party__label { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--pwe-rust); font-weight: 700; }
.pwe-party__name { font-weight: 600; font-size: 1rem; margin-top: 3px; }
.pwe-party__line { font-size: 0.88rem; color: var(--pwe-stone); }
.pwe-party--right { text-align: right; }

/* "Open in Google Maps" link on the crew-contract page's job-site block. Scoped under .pwe-shell so the
   global dark-mode <a> rule in structra-theme.css can't wash it out (same theme-immunity concern as the
   other brand colors above). */
.pwe-shell .pwe-maps-link { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 5px; font-size: 0.88rem; font-weight: 600; color: var(--pwe-rust); text-decoration: none; }
.pwe-shell .pwe-maps-link:hover { color: var(--pwe-rust-dark); text-decoration: underline; }

.pwe-section { padding: 22px 24px; border-bottom: 1px solid var(--pwe-line); }
.pwe-section__title { font-family: 'Poppins', sans-serif; font-size: 0.95rem; font-weight: 600; color: var(--pwe-pine); margin: 0 0 12px; }

.pwe-scope { margin: 0; padding-left: 18px; }
.pwe-scope__item { font-size: 0.92rem; line-height: 1.55; margin-bottom: 6px; color: var(--pwe-charcoal); }

/* ---- Pricing option cards ---- */
.pwe-options { display: flex; flex-direction: column; gap: 12px; }
.pwe-option {
    display: flex; align-items: center; gap: 14px;
    width: 100%; text-align: left;
    background: #fff; border: 2px solid var(--pwe-line); border-radius: 10px;
    padding: 16px; cursor: pointer; font: inherit; color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.pwe-option:hover { border-color: var(--pwe-clay); }
.pwe-option--selected { border-color: var(--pwe-pine); background: rgba(90, 107, 76, 0.06); box-shadow: 0 2px 10px rgba(44, 62, 45, 0.1); }
.pwe-option__check {
    width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
    border: 2px solid var(--pwe-line);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 14px; font-weight: 700;
}
.pwe-option--selected .pwe-option__check { background: var(--pwe-pine); border-color: var(--pwe-pine); }
.pwe-option__body { flex: 1; min-width: 0; }
.pwe-option__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pwe-option__label { font-weight: 600; font-size: 1rem; color: var(--pwe-pine); }
.pwe-option__desc { font-size: 0.85rem; color: var(--pwe-stone); margin-top: 3px; line-height: 1.45; }
.pwe-option__price { text-align: right; flex-shrink: 0; }
.pwe-option__list { display: block; font-size: 0.8rem; color: var(--pwe-stone); text-decoration: line-through; }
.pwe-option__net { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1.15rem; color: var(--pwe-rust); }
.pwe-badge { font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; color: #fff; background: var(--pwe-rust); padding: 2px 8px; border-radius: 999px; }
.pwe-discount { margin: 12px 0 0; font-size: 0.85rem; color: var(--pwe-moss); font-weight: 600; }

/* ---- Deposit & validity callout ----
 * Prominent (not hidden in the collapsible terms): mirrors the estimate PDF's "Payment Terms &
 * Deposit" callout — cream panel with a rust accent bar. Uses div/span (not p/label) so the global
 * dark-mode body rules in structra-theme.css don't out-specify these brand colors. */
.pwe-deposit { background: var(--pwe-cream); border-left: 4px solid var(--pwe-rust); border-radius: 8px; padding: 16px 18px; }
.pwe-deposit__row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pwe-deposit__pct { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1.25rem; color: var(--pwe-rust-dark); }
.pwe-deposit__label { font-size: 0.95rem; color: var(--pwe-charcoal); }
.pwe-deposit__validity { margin-top: 8px; font-size: 0.88rem; color: var(--pwe-stone); }

/* ---- Signature panel ---- */
.pwe-sign { padding: 22px 24px; }
.pwe-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--pwe-charcoal); margin-bottom: 6px; }
.pwe-input {
    width: 100%; box-sizing: border-box;
    padding: 12px 14px; font: inherit; font-size: 1rem;
    border: 1px solid var(--pwe-line); border-radius: 8px; background: #fff; color: var(--pwe-charcoal);
}
.pwe-input:focus { outline: none; border-color: var(--pwe-pine); box-shadow: 0 0 0 3px rgba(44, 62, 45, 0.12); }

.pwe-canvas-wrap { position: relative; }
.pwe-canvas {
    width: 100%; height: 180px; display: block;
    border: 1px dashed var(--pwe-clay); border-radius: 8px; background: #fffdf8;
    touch-action: none; cursor: crosshair;
}
.pwe-canvas-baseline {
    position: absolute; left: 24px; right: 24px; bottom: 46px;
    border-bottom: 1px solid var(--pwe-line); pointer-events: none;
}
.pwe-canvas-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.pwe-canvas-hint { font-size: 0.8rem; }

.pwe-consent { display: flex; gap: 10px; align-items: flex-start; margin: 18px 0; font-size: 0.9rem; line-height: 1.5; cursor: pointer; }
.pwe-consent input { margin-top: 3px; width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--pwe-pine); }

.pwe-fineprint { font-size: 0.76rem; color: var(--pwe-stone); margin: 14px 0 0; line-height: 1.5; }

.pwe-alert { padding: 12px 14px; border-radius: 8px; font-size: 0.88rem; margin-bottom: 14px; }
.pwe-alert--error { background: rgba(181, 101, 29, 0.12); color: var(--pwe-rust-dark); border: 1px solid rgba(181, 101, 29, 0.3); }

/* ---- Buttons ---- */
.pwe-btn {
    font: inherit; font-weight: 600; border-radius: 8px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid transparent; padding: 12px 18px; transition: background 0.15s, opacity 0.15s;
}
.pwe-btn:disabled { opacity: 0.6; cursor: default; }
.pwe-btn--primary { background: var(--pwe-rust); color: #fff; font-size: 1rem; }
.pwe-btn--primary:hover:not(:disabled) { background: var(--pwe-rust-dark); }
.pwe-btn--ghost { background: transparent; color: var(--pwe-stone); border-color: var(--pwe-line); padding: 8px 14px; font-size: 0.85rem; }
.pwe-btn--ghost:hover { color: var(--pwe-charcoal); border-color: var(--pwe-clay); }
.pwe-btn--block { width: 100%; margin-top: 4px; }

.pwe-foot { padding: 18px 24px; background: var(--pwe-pine); color: var(--pwe-cream); font-size: 0.82rem; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; }
.pwe-foot .pwe-dot { color: rgba(245, 241, 232, 0.6); }

/* ---- Spinner ---- */
.pwe-spinner {
    width: 40px; height: 40px; border-radius: 50%;
    border: 4px solid var(--pwe-line); border-top-color: var(--pwe-pine);
    animation: pwe-spin 0.8s linear infinite; margin: 8vh auto 16px;
}
.pwe-spinner--sm { width: 16px; height: 16px; border-width: 2px; margin: 0; }
@keyframes pwe-spin { to { transform: rotate(360deg); } }

/* ---- Responsive ---- */
@media (max-width: 540px) {
    .pwe-head { flex-direction: column; }
    .pwe-head__doc { text-align: left; }
    .pwe-parties { flex-direction: column; }
    .pwe-party--right { text-align: left; }
    .pwe-option { flex-wrap: wrap; }
    .pwe-option__price { text-align: left; width: 100%; padding-left: 38px; }
}
