/* ==================================================================
   McCools Service Report — styling

   The sheet is sized for US Letter (8.5in x 11in), which is the size of
   the paper the original report is printed on. On screen the sheet sits
   on a grey background; when it is printed, only the sheet is printed.
   ================================================================== */

:root {
    --blue:        #092B9D;   /* the McCools blue used for the headings */
    --blue-strong: #173FC5;   /* the stronger blue on the box borders   */
    --blue-soft:   #CBD2E5;   /* the soft blue on the input borders     */
    --blue-pale:   #EEF2FA;   /* the fill behind the section headings   */
    --ink:         #1A2233;
    --muted:       #6B7280;
    --paper:       #FFFFFF;
    --desk:        #E8EBF0;
    --line:        #092B9D;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--desk);
    color: var(--ink);
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------------
   THE SHEET
   ------------------------------------------------------------------ */

.sheet {
    width: 8.5in;
    min-height: 11in;
    margin: 22px auto 96px;
    padding: 0.5in 0.68in 0.3in;
    background: var(--paper);
    box-shadow: 0 2px 18px rgba(0, 0, 0, .18);
    position: relative;
}

/* ---- header ---- */

.sheet-head {
    display: flex;
    align-items: flex-start;
    padding-bottom: .16in;
    position: relative;
}

.stamp {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 7px;
    color: var(--muted);
    letter-spacing: .2px;
    line-height: 1.2;
}

.brand {
    flex: 0 0 3.05in;
    margin-right: .23in;
    padding-top: .31in;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.brand-logo {
    width: 3.05in;
    height: auto;
    display: block;
}

.brand-tagline {
    align-self: flex-end;
    margin-top: 2px;
    text-align: right;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.1;
    color: #1B2A6B;
    letter-spacing: .1px;
    white-space: nowrap;
}

.contact {
    flex: 1 1 auto;
    color: var(--blue);
    font-size: 11px;
    line-height: 1.75;
    padding-top: .22in;
    white-space: nowrap;
}

.report-id {
    flex: 0 0 2.05in;
    text-align: right;
    padding-top: .15in;
}

.report-id h1 {
    margin: 0 0 .1in;
    font-size: 19px;
    font-weight: 800;
    color: var(--blue-strong);
    letter-spacing: .5px;
    text-transform: uppercase;
    white-space: nowrap;
}

.report-no {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 4px;
    font-size: 12px;
    color: var(--blue);
}

.report-no-label {
    font-weight: 700;
    white-space: nowrap;
}

/* The report number is the one number that must never be lost, so it
   gets a visible box of its own rather than a hairline underline. */
.report-id .report-no input {
    width: .72in;
    border: 1.5px solid var(--blue-soft);
    border-radius: 6px;
    background: #fff;
    color: var(--blue-strong);
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    padding: 3px 4px;
    line-height: 1.3;
}

.report-id .report-no input:hover,
.report-id .report-no input:focus {
    border-color: var(--blue);
    outline: none;
}

/* ---- field rows ---- */

.rows { margin-top: 0; }

.row {
    display: flex;
    align-items: center;
    gap: .07in;
    margin-bottom: 8px;
}

.row-label {
    width: 1.15in;
    flex: 0 0 1.15in;
    color: var(--blue);
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .2px;
}

.row-split { gap: .16in; }
.row-part { display: flex; align-items: center; gap: .07in; flex: 1 1 0; min-width: 0; }
.row-part:empty { flex: 0 0 40%; }

/* A field that stands on its own: the label above, the input under it,
   in a box. Used for the date / order no / job no, so each number has
   its own clear space and none of them can be pushed off the page.

   On paper the three blocks sit side by side — the same height they
   took before, but each number now has its own box. */
.row-blocks {
    display: flex;
    gap: .12in;
    margin-bottom: 8px;
}

.row-block {
    flex: 1 1 0;
    min-width: 0;
    padding: 5px 8px 6px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
}

.row-block .row-label {
    display: block;
    width: auto;
    flex: none;
    margin-bottom: 3px;
    font-size: 11px;
}

.row-block input { width: 100%; }

/* ---- inputs ---- */

input[type="text"],
input[type="date"],
input[type="search"],
select,
textarea {
    font-family: inherit;
    font-size: 12.5px;
    color: var(--ink);
    background: #fff;
    border: 1.5px solid var(--blue-soft);
    border-radius: 6px;
    padding: 7px 9px;
    line-height: 16px;
    width: 100%;
    min-width: 0;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(23, 63, 197, .35);
    outline-offset: 0;
    border-color: var(--blue-strong);
}

input::placeholder,
textarea::placeholder { color: #9AA3B2; }

/* the date picker arrow, styled to match */
input[type="date"] { padding-right: 6px; }
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: .75;
}

/* ---- job type checkboxes ---- */

.job-types {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1.5px solid var(--line);
    margin: .1in 0;
}

.job-type {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .1in;
    padding: 12px 4px;
    cursor: pointer;
    font-weight: 800;
    color: var(--blue);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .3px;
    user-select: none;
}

.job-type + .job-type { border-left: 1.5px solid var(--line); }
.job-type:hover { background: var(--blue-pale); }

.job-type input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--blue);
    cursor: pointer;
}

/* ---- equipment grid ---- */

.equip {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1.5px solid var(--line);
    margin-bottom: .25in;
}

.equip-cell {
    display: flex;
    align-items: center;
    gap: .08in;
    padding: 4px 8px;
    min-width: 0;
    height: .455in;
}

.equip-cell:nth-child(odd)  { border-right: 1.5px solid var(--line); }
.equip-cell:nth-child(-n+4) { border-bottom: 1.5px solid var(--line); }

.equip-label {
    flex: 0 0 1.12in;
    color: var(--blue);
    font-weight: 800;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .2px;
}

.equip-cell input { flex: 1 1 auto; }

/* ---- remarks ---- */

.remarks { margin-top: .15in; }

.section-title {
    margin: 0 0 4px;
    font-size: 11.5px;
    font-weight: 800;
    line-height: 1.15;
    color: var(--blue);
    text-transform: uppercase;
    letter-spacing: .3px;
}

.textarea-box { position: relative; }

.textarea-box textarea {
    width: 100%;
    height: .49in;
    min-height: .49in;
    resize: vertical;
    line-height: 1.45;
    padding: 10px .32in 6px 9px;
    overflow: auto;
}

/* the little pencil in the corner, like the PDF */
.textarea-box::after {
    content: "";
    position: absolute;
    right: 9px;
    bottom: 9px;
    width: 14px;
    height: 14px;
    pointer-events: none;
    opacity: .5;
    background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E") no-repeat center/contain;
}

/* ---- signatures ---- */

.signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .22in;
    margin-top: .16in;
}

.sig-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--blue);
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .2px;
    margin-bottom: 2px;
    min-height: 20px;
}

.tech-select {
    width: auto;
    max-width: 1.55in;
    margin: 0;
    padding: 2px 5px;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--blue);
    text-transform: none;
    letter-spacing: 0;
}

.sig-dots {
    height: 16px;
    margin-bottom: 8px;
    border-bottom: 2px dotted var(--blue);
}

.sig-box {
    position: relative;
    border: 1.5px solid var(--line);
    height: .87in;
    background: #fff;
    overflow: hidden;
}

.sig-box-inner { position: relative; height: 100%; }

.sig-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}

.tech-signature {
    position: absolute;
    left: 6px;
    bottom: 8px;
    max-width: calc(100% - 12px);
    max-height: calc(100% - 16px);
    object-fit: contain;
    object-position: left bottom;
}

.sig-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #A6AEBC;
    font-size: 11px;
    pointer-events: none;
}

.sig-clear {
    position: absolute;
    top: 4px;
    right: 4px;
    border: 1px solid var(--blue-soft);
    background: #fff;
    color: var(--blue);
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    display: none;
}

.sig-clear.show { display: block; }

.sig-name {
    position: absolute;
    right: 8px;
    bottom: 6px;
    font-size: 10px;
    color: var(--muted);
}

.sig-caption {
    text-align: center;
    color: var(--blue);
    font-weight: 800;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .3px;
    margin-top: 4px;
}

/* ---- terms ---- */

.terms { margin-top: .22in; }

.terms-text {
    margin: 3px 0 0;
    font-size: 10px;
    line-height: 1.35;
    color: #26304A;
    text-align: justify;
}

/* ---- footer ---- */

.sheet-foot {
    position: absolute;
    left: .68in;
    right: .68in;
    bottom: .3in;
    padding-top: .07in;
    border-top: 1px solid var(--blue-soft);
    display: grid;
    grid-template-columns: 2fr 2fr 1.25fr 1.85fr;
    gap: .12in;
}

/* room for the footer, so the terms never run into it */
.sheet > .terms { margin-bottom: .5in; }

.foot-col { font-size: 10.5px; color: var(--blue); line-height: 1.55; white-space: nowrap; }
.foot-head { font-weight: 700; }
.foot-sub { color: #33406A; }
.foot-right { text-align: right; }

.ico { margin-right: 3px; }

/* ------------------------------------------------------------------
   THE TOOLBAR
   ------------------------------------------------------------------ */

.toolbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: #12203F;
    border-top: 3px solid var(--blue-strong);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .18);
}

.toolbar-inner {
    max-width: 8.5in;
    margin: 0 auto;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-brand {
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .3px;
}

.toolbar-spacer { flex: 1 1 auto; }

.toolbar-status {
    color: #9FB4E8;
    font-size: 12px;
    min-width: 64px;
    text-align: right;
}

.btn {
    border: 0;
    border-radius: 7px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.btn-primary { background: var(--blue-strong); color: #fff; }
.btn-primary:hover { background: #0D339E; }
.btn-ghost { background: transparent; color: #C7D4F2; border: 1px solid #3A4E7E; }
.btn-ghost:hover { background: #1B2C52; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---- toast ---- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 66px;
    transform: translateX(-50%) translateY(14px);
    background: #12203F;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 60;
    max-width: 90vw;
    text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: #8E1B1B; }

/* ------------------------------------------------------------------
   PHONE AND TABLET
   ------------------------------------------------------------------ */

@media (max-width: 900px) {
    html, body { overflow-x: hidden; }

    .sheet {
        width: 100%;
        min-height: 0;
        margin: 0 0 78px;
        padding: 14px 14px 18px;
        box-shadow: none;
        overflow-x: hidden;
    }

    /* The header is a flex ROW on paper (logo | contacts | report no).
       On a phone that row is far wider than the screen, and the sheet
       hides the overflow, so the phone numbers and the report number
       were cut off. Stack it here instead: the header becomes a column,
       every block full width, and the contacts are allowed to wrap. */
    .sheet-head {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        text-align: left;
    }

    .brand {
        flex: 0 0 auto;
        width: 100%;
        margin-right: 0;
        padding-top: 14px;
    }

    .contact {
        flex: 0 0 auto;
        width: 100%;
        padding-top: 0;
        white-space: normal;
        line-height: 1.6;
    }

    .report-id {
        flex: 0 0 auto;
        width: 100%;
        text-align: left;
        padding-top: 0;
    }

    .brand-logo { width: min(100%, 320px); }
    .report-id h1 { font-size: 18px; }
    .report-no { justify-content: flex-start; }
    .report-id .report-no input { width: 1.15in; font-size: 15px; }

    /* A split row holds a LABEL and an INPUT inside each half. The
       label goes on its own line so the input gets the full width
       instead of being squeezed to nothing. */
    .row { flex-wrap: wrap; }
    .row-label { flex: 0 0 100%; width: 100%; margin-bottom: 3px; }
    .row-split { gap: 10px; }
    .row-part { flex: 1 1 100%; flex-wrap: wrap; }
    .row-part .row-label { flex: 0 0 100%; width: 100%; margin-bottom: 3px; }
    .row-part:empty { display: none; }

    /* The standalone blocks stack the same way: label above, input
       below, full width, so nothing falls off the side. */
    .row-blocks {
        display: block;
        margin-bottom: 8px;
    }
    .row-block {
        margin-bottom: 8px;
        padding: 6px 9px 7px;
    }
    .row-block:last-child { margin-bottom: 0; }
    .row-block .row-label {
        display: block;
        width: auto;
        flex: none;
        margin-bottom: 4px;
    }

    .job-types { grid-template-columns: 1fr; }
    .job-type { justify-content: flex-start; padding: 10px 12px; }
    .job-type + .job-type { border-left: 0; border-top: 1px solid var(--line); }

    .equip { grid-template-columns: 1fr; }
    .equip-cell { border-right: 0 !important; border-bottom: 1px solid var(--blue-soft); }
    .equip-cell:last-child { border-bottom: 0; }
    .equip-label { flex: 0 0 auto; min-width: 6.2em; }

    .signatures { grid-template-columns: 1fr; gap: 16px; }
    .sig-box { height: 130px; }

    /* The footer must never sit on top of the terms. On a phone the
       sheet is tall, so let the footer flow after the content instead of
       being pinned to the bottom of it. */
    .sheet-foot {
        position: static;
        margin-top: 16px;
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .foot-right { text-align: left; }
    .foot-col { white-space: normal; word-break: break-word; }
    .sheet > .terms { margin-bottom: 0; }

    .toolbar-inner { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
    .toolbar-brand { display: none; }
    .toolbar-status { text-align: left; min-width: 0; }
    .btn { flex: 1 1 40%; padding: 7px 8px; font-size: 12px; }
    .btn-primary { flex: 1 1 100%; }
}

@media (max-width: 480px) {
    .sheet-foot { grid-template-columns: 1fr; }
    .terms-text { font-size: 9px; }
}

/* ------------------------------------------------------------------
   PRINT — only the sheet comes out, at exactly Letter size.
   ------------------------------------------------------------------ */

@page {
    size: Letter portrait;
    margin: 0;
}

@media print {
    html, body {
        background: #fff;
        margin: 0;
        padding: 0;
    }

    .toolbar, .toast { display: none !important; }

    .sheet {
        width: 8.5in;
        height: 11in;
        min-height: 11in;
        margin: 0;
        padding: 0.5in 0.68in 0.3in;
        box-shadow: none;
        border: 0;
    }

    /* Keep the boxes and the sheet the same colour as on screen. */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    input, textarea, select {
        border-color: var(--blue-soft) !important;
    }

    /* The typed value is what matters on paper, not the box around it. */
    .sig-placeholder { display: none !important; }
    .sig-clear { display: none !important; }
}
