/* Fyrdor internal app styling */

/* Offline hub */
.hub-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0 1rem; }
.job-row { padding: 0.6rem 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.job-row:last-child { border-bottom: none; }
.job-row .ref { font-weight: 600; }

/* Signature pad: fixed display size so the drawing buffer (scaled for retina)
   never changes the on-screen box. touch-action:none stops the page panning
   while the finger draws, which is what threw the ink off-position. */
.sigpad {
    display: block;
    width: 100%;
    height: 170px;
    border: 1px solid #5E7A8A;
    border-radius: 6px;
    background: #fff;
    touch-action: none;
    cursor: crosshair;
}

:root {
    --red: #b3261e;          /* kept for FAIL / error states only */
    --red-dark: #8c1d17;
    --navy: #03244B;         /* Fyrdor brand navy - primary accent */
    --navy-dark: #021a37;
    --steel: #5E7A8A;        /* Fyrdor brand steel-blue */
    --charcoal: #2b2b2e;
    --bg: #f6f5f3;
    --card: #ffffff;
    --line: #e3e1dd;
    --text: #2b2b2e;
    --muted: #807c76;
    --ok: #2e7d32;
}

* { box-sizing: border-box; }

/* Anything with the hidden attribute must actually hide, whatever
   other display rules apply (this was the "Other" box bug). */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
}

/* ---------- layout ---------- */

.topbar {
    background: #fff;
    color: var(--navy);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1.2rem;
}
.brand { display: flex; align-items: center; text-decoration: none; }
.brand-logo { height: 60px; display: block; }
.auth-logo { display: block; max-width: 240px; margin: 1rem auto 0.5rem; }
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.topbar nav a { color: var(--navy); text-decoration: none; }
.topbar nav a:hover { color: var(--navy-dark); }
.topbar nav a.btn { color: #fff; }            /* keep button text white */
.topbar nav a.btn:hover { color: #fff; }

main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1.2rem; }
footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 2rem 0; }

h1 { font-size: 1.5rem; margin: 0.2rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.8rem; }
.muted { color: var(--muted); font-weight: normal; }
.empty { color: var(--muted); padding: 2rem 0; }

/* ---------- cards & forms ---------- */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.1rem 1.2rem;
    margin-bottom: 1.2rem;
}
.columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.2rem;
    align-items: start;
    margin-bottom: 1.2rem;
}
.columns .card { margin-bottom: 0; }

label { display: block; margin-bottom: 0.8rem; font-weight: 600; font-size: 0.9rem; }
input, textarea, select {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.55rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    font-weight: normal;
    background: #fff;
}
input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--navy);
    outline-offset: 1px;
    border-color: var(--navy);
}

.btn {
    display: inline-block;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.55rem 1.1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--navy-dark); }
.btn-small { padding: 0.35rem 0.8rem; font-size: 0.85rem; }

.hint { font-size: 0.85rem; color: var(--muted); margin-bottom: 0; }
.warn { color: var(--red-dark); }

/* form section headings + conditional sections */
form h2 { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line); }
form h2:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.reveal { background: #faf9f7; border-left: 3px solid var(--red); padding: 0.7rem 0.9rem; border-radius: 0 6px 6px 0; margin-bottom: 0.8rem; }
label.checkbox { font-weight: normal; }
label.checkbox input { display: inline; width: auto; margin-right: 0.4rem; }
.addr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 480px) { .addr-grid { grid-template-columns: 1fr; } }
.legal { font-size: 0.85rem; color: var(--charcoal); background: #fff8d6; border: 1px solid #eadf9e; border-radius: 6px; padding: 0.7rem 0.9rem; }

/* ---------- flash messages ---------- */

.flash {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 600;
}
.flash-ok { background: #e6f4ea; color: var(--ok); border: 1px solid #bcdfc5; }
.flash-error { background: #fdeceb; color: var(--red-dark); border: 1px solid #f3c1be; }

/* ---------- tables ---------- */

table.jobs, table.history { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.jobs th, table.jobs td, table.history td {
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
}
table.jobs th { background: #faf9f7; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
table.jobs tr:last-child td, table.history tr:last-child td { border-bottom: none; }
a.ref { font-weight: 700; color: var(--navy); text-decoration: none; }
a.ref:hover { text-decoration: underline; }
.finished { opacity: 0.65; }

/* ---------- job detail ---------- */

.job-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 0.9rem; }
dt { font-weight: 600; font-size: 0.85rem; color: var(--muted); }
dd { margin: 0; font-size: 0.95rem; }

/* ---------- status badges ---------- */

.badge {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 99px;
    font-size: 0.78rem;
    font-weight: 700;
    background: #eceae6;
    color: var(--charcoal);
    white-space: nowrap;
}
.badge-big { font-size: 0.95rem; padding: 0.3rem 0.9rem; }

.badge[data-status="Booking received"] { background: #fdeceb; color: var(--red-dark); }
.badge[data-status="Scheduled"],
.badge[data-status="Booked in"],
.badge[data-status="Contractor assigned"] { background: #e8f0fe; color: #1a56b0; }
.badge[data-status="Inspection completed"],
.badge[data-status="Work completed"] { background: #fef3e0; color: #9c6500; }
.badge[data-status="Report sent"],
.badge[data-status="Quote sent"],
.badge[data-status="Final invoice sent"] { background: #f3e8fd; color: #6b2fb3; }
.badge[data-status="Awaiting decision"] { background: #fff8d6; color: #8a7400; }
.badge[data-status="Quote accepted"],
.badge[data-status="Deposit received"],
.badge[data-status="Paid in full"],
.badge[data-status="Closed - passed"] { background: #e6f4ea; color: var(--ok); }
.badge[data-status="Archived"],
.badge[data-status="Closed"],
.badge[data-status="Cancelled"] { background: #eceae6; color: var(--muted); }

/* ---------- inspection (mobile-first) ---------- */

.small { font-size: 0.8rem; }
.insp-head { margin-bottom: 0.8rem; }
.insp-head > div:first-child { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.progress { height: 8px; background: var(--line); border-radius: 99px; margin: 0.5rem 0 0.2rem; overflow: hidden; }
.progress-bar { height: 100%; background: var(--steel); border-radius: 99px; transition: width 0.3s; }

.insp-form fieldset.pf-item { border: none; border-top: 1px solid var(--line); margin: 0 -1.2rem; padding: 0.9rem 1.2rem 0.7rem; }
.insp-form fieldset.pf-item legend { font-weight: 600; font-size: 0.95rem; padding: 0.9rem 0 0.4rem; float: left; width: 100%; }

/* big segmented Pass / Fail / N/A buttons */
.seg { display: flex; gap: 0.5rem; clear: both; margin-bottom: 0.5rem; }
.seg-opt { flex: 1; position: relative; margin: 0; }
.seg-opt input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg-opt span { display: block; text-align: center; padding: 0.7rem 0.4rem; border: 2px solid var(--line); border-radius: 8px; font-weight: 700; background: #fff; }
.seg-opt input:checked + span { border-color: var(--charcoal); background: var(--charcoal); color: #fff; }
.seg-opt.pass input:checked + span { border-color: var(--ok); background: var(--ok); }
.seg-opt.fail input:checked + span { border-color: var(--red); background: var(--red); }
.seg-opt.na input:checked + span { border-color: var(--muted); background: var(--muted); }
.pf-note { font-weight: normal; }

/* gap measurement rows */
.mm-row { display: grid; grid-template-columns: 1fr 5.5rem 7rem; gap: 0.5rem; align-items: center; padding: 0.35rem 0; border-top: 1px solid var(--line); }
.mm-label { font-size: 0.9rem; font-weight: 600; }
.mm-input { margin: 0; text-align: center; }
.seg-mini { margin: 0; }
.seg-mini .seg-opt span { padding: 0.5rem 0.3rem; }

/* photos */
.photo-btn { display: block; border: 2px dashed var(--steel); border-radius: 8px; padding: 0.9rem; text-align: center; color: var(--navy); font-weight: 700; cursor: pointer; }
.photo-btn input { display: none; }
.thumbs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.6rem 0; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.item-photos { margin: 0 -1.2rem; padding: 0.5rem 1.2rem 0.7rem; background: #faf9f7; border-bottom: 1px solid var(--line); }
.mm-photos { padding: 0.4rem 0 0.6rem; border-bottom: 1px solid var(--line); }
.item-photo-btns { display: flex; gap: 0.5rem; }
.photo-btn-sm { padding: 0.5rem 0.4rem; font-size: 0.82rem; flex: 1; }

/* navigation + outcomes + defects */
.insp-nav { display: flex; gap: 0.7rem; margin-top: 1.2rem; }
.insp-nav .btn-big { flex: 1; }
.btn-big { padding: 0.9rem 1.2rem; font-size: 1.05rem; }
.btn-grey { background: var(--muted); }
.btn-grey:hover { background: var(--charcoal); }
.btn-skip { width: 100%; margin-top: 0.7rem; }

.outcome { display: flex; gap: 0.7rem; align-items: flex-start; border: 2px solid var(--line); border-radius: 8px; padding: 0.7rem 0.9rem; font-weight: normal; cursor: pointer; }
.outcome input { width: auto; margin-top: 0.25rem; }
.outcome:has(input:checked) { border-color: var(--navy); background: #eef3f8; }

.defect { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.defect:last-child { border-bottom: none; }
.badge.sev-critical { background: var(--red); color: #fff; }
.badge.sev-high { background: #fdeceb; color: var(--red-dark); }
.badge.sev-medium { background: #fff8d6; color: #8a7400; }
.badge.sev-low { background: #eceae6; color: var(--muted); }

.flash ul { margin: 0.4rem 0 0; padding-left: 1.2rem; font-weight: normal; }

/* ---------- agree checkbox + terms page ---------- */
label.check { font-weight: normal; display: block; margin: 0.8rem 0; line-height: 1.4; }
label.check input { width: auto; display: inline; margin-right: 0.4rem; }
.terms-page { max-width: 820px; }
.terms-page h1 { font-size: 1.4rem; margin-top: 1.4rem; }
.terms-page h2 { font-size: 1.05rem; margin-top: 1.3rem; }
.terms-page li { margin-bottom: 0.3rem; }

/* ---------- quote builder ---------- */
.qline { display: grid; grid-template-columns: 1fr 60px 90px; gap: 0.5rem; margin-bottom: 0.5rem; align-items: center; }
.qline input { margin-top: 0; }
.qhead { font-weight: 600; font-size: 0.8rem; color: var(--muted); }
.quote-totals { margin-left: auto; max-width: 320px; }
.quote-totals tr td:last-child { text-align: right; }
.quote-totals .total td { font-weight: 700; border-top: 2px solid var(--line); font-size: 1.05rem; }

/* ---------- login / setup ---------- */

.auth-box { max-width: 420px; margin: 3rem auto 0; }
.auth-box h1 { text-align: center; }

/* ---------- phones ---------- */

@media (max-width: 640px) {
    table.jobs th:nth-child(6), table.jobs td:nth-child(6),
    table.jobs th:nth-child(7), table.jobs td:nth-child(7) { display: none; }
}
