/* ===================================================================
   BP Gas Station — Invoice Generator
   Roadside forecourt aesthetic: BP heritage green, signal yellow,
   condensed signage type on warm paper.
   =================================================================== */

:root {
    --green: #00622e;
    --green-deep: #004520;
    --green-bright: #009b48;
    --yellow: #ffd500;
    --blue: #0088b6;
    --blue-ink: #006885;
    --paper: #f4f2ea;
    --card: #ffffff;
    --ink: #182a1f;
    --ink-soft: #5b6b60;
    --line: #dcd8c8;
    --danger: #c0392b;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(24, 42, 31, 0.08);
    --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
    --font-body: "Barlow", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    background-color: var(--paper);
    background-image:
        repeating-linear-gradient(-45deg,
            rgba(24, 42, 31, 0.025) 0 2px,
            transparent 2px 14px);
    color: var(--ink);
    line-height: 1.55;
    min-height: 100vh;
}

/* ============ SIGN HEADER ============ */

.sign-header {
    background: linear-gradient(160deg, var(--green) 0%, var(--green-deep) 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.sign-header::after {
    /* big ghost helios-ish burst */
    content: "";
    position: absolute;
    right: -70px;
    top: -70px;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(255, 213, 0, 0.22) 0%,
        rgba(0, 155, 72, 0.28) 45%,
        transparent 70%);
    pointer-events: none;
}

.sign-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: 1.6rem 1.25rem 1.9rem;
    position: relative;
    z-index: 1;
}

.sign-topline {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--yellow);
    margin-bottom: 0.4rem;
}

.sign-station { color: rgba(255, 255, 255, 0.75); font-weight: 600; }

.sign-header h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2.5rem, 8vw, 4rem);
    line-height: 0.95;
    text-transform: uppercase;
    letter-spacing: 0.015em;
}

.sign-sub {
    margin-top: 0.5rem;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.95rem;
}

.sign-stripe {
    height: 8px;
    background: repeating-linear-gradient(-45deg,
        var(--yellow) 0 18px,
        var(--green-deep) 18px 36px);
}

/* ============ LAYOUT ============ */

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 7.5rem;  /* room for sticky action bar */
    display: grid;
    gap: 1.25rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.4rem 1.25rem;
}

.card-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}

.card-head h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.55rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex: 1;
}

.step-chip {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.95rem;
    background: var(--yellow);
    color: var(--green-deep);
    padding: 0.15rem 0.55rem;
    border-radius: 6px;
    letter-spacing: 0.06em;
}

/* ============ FIELDS ============ */

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.field.full { grid-column: 1 / -1; }

.field label {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--ink-soft);
    margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"] {
    width: 100%;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    color: var(--ink);
    background: #fbfaf5;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    min-height: 48px;               /* touch target */
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

input:focus {
    outline: none;
    border-color: var(--green-bright);
    box-shadow: 0 0 0 3px rgba(0, 155, 72, 0.18);
}

input.invalid { border-color: var(--danger); }

.hint {
    display: block;
    font-size: 0.8rem;
    color: var(--ink-soft);
    margin-top: 0.3rem;
}

/* ============ ITEMS ============ */

.items-header {
    display: grid;
    grid-template-columns: 2rem 1.2fr 1fr 0.8fr 0.8fr 2.5rem;
    gap: 0.6rem;
    padding: 0 0.25rem 0.4rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--ink-soft);
}

.item-row {
    display: grid;
    grid-template-columns: 2rem 1.2fr 1fr 0.8fr 0.8fr 2.5rem;
    gap: 0.6rem;
    align-items: center;
    padding: 0.45rem 0.25rem;
    border-top: 1px dashed var(--line);
}

.item-num {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--green-bright);
    text-align: center;
}

.item-row .mobile-label { display: none; }

.btn-remove {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: #faeae8;
    color: var(--danger);
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s;
}

.btn-remove:hover { background: #f5d5d1; }

.items-total {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 0.75rem;
    margin-top: 0.9rem;
    padding-top: 0.9rem;
    border-top: 2px solid var(--ink);
}

.items-total span {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.items-total strong {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.8rem;
    color: var(--green);
}

/* ============ PHOTOS ============ */

.dropzone {
    border: 2px dashed var(--green-bright);
    border-radius: var(--radius);
    background: #f2f8f0;
    padding: 1.6rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
    background: #e5f3e2;
    border-color: var(--green);
    outline: none;
}

.dropzone-icon { font-size: 2rem; margin-bottom: 0.3rem; }

.photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 1rem;
}

.photo-thumb {
    position: relative;
    width: 86px;
    height: 86px;
}

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    border: 1.5px solid var(--line);
}

.photo-thumb button {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
}

/* ============ HELP ============ */

.help {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    color: var(--ink-soft);
}

.help summary {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 1.05rem;
    color: var(--ink);
    cursor: pointer;
}

.help ol { margin: 0.9rem 0 0.2rem 1.2rem; display: grid; gap: 0.45rem; }

/* ============ BUTTONS & ACTION BARS ============ */

.btn {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    border-radius: 999px;
    padding: 0.75rem 1.5rem;
    min-height: 48px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--green);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 98, 46, 0.35);
}
.btn-primary:hover { background: var(--green-deep); }

.btn-ghost {
    background: transparent;
    color: var(--green);
    border: 1.5px solid var(--green-bright);
    padding: 0.4rem 1rem;
    min-height: 40px;
    font-size: 0.95rem;
}
.btn-ghost:hover { background: #eef6ec; }

.btn-dark { background: var(--ink); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }

.btn-big { width: 100%; max-width: 420px; font-size: 1.25rem; }

.action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 0.7rem;
    padding: 0.9rem 1.25rem calc(0.9rem + env(safe-area-inset-bottom));
    background: rgba(244, 242, 234, 0.92);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    z-index: 50;
}

/* ===================================================================
   INVOICE DOCUMENT (screen preview + print)
   =================================================================== */

#invoiceView { background: #8a8f8b; min-height: 100vh; padding: 1.5rem 0.5rem 7rem; }

.invoice-doc {
    max-width: 850px;
    margin: 0 auto;
    background: #fff;
    color: #000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    font-family: var(--font-body);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.inv-headbar {
    background-color: #439539;
    color: #fff;
    padding: 1rem 2rem;
}

.inv-headbar h1 {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.inv-body { padding: 0.5rem 2rem 2.5rem; }

.inv-blueline { height: 4px; background-color: var(--blue); margin-bottom: 1.8rem; }

.inv-top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.8rem;
}

.inv-block h3 {
    color: var(--blue-ink);
    font-size: 0.9rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 0.45rem;
    letter-spacing: 0.02em;
}

.inv-block p { font-size: 0.9rem; font-weight: 600; line-height: 1.45; }

.inv-meta { text-align: right; }
.inv-meta p { font-size: 0.9rem; font-weight: 700; color: var(--blue-ink); }

.inv-officer, .inv-comments { margin-bottom: 1.8rem; }

.inv-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }

.inv-table th {
    border: 2px solid var(--blue);
    color: var(--blue-ink);
    padding: 0.5rem;
    text-transform: uppercase;
    font-weight: 800;
    font-size: 0.88rem;
    text-align: center;
}

.inv-table td {
    border: 2px solid var(--blue);
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.inv-totalrow {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
}

.inv-totallabel {
    color: var(--blue-ink);
    font-weight: 800;
    font-size: 1rem;
    text-transform: uppercase;
}

.inv-totalbox {
    border: 2px solid var(--blue);
    padding: 0.5rem;
    text-align: center;
    font-weight: 800;
    font-size: 1rem;
    min-width: 110px;
    display: inline-block;
}

.inv-attachments { margin-top: 3rem; }

.inv-attachments h3 {
    color: var(--blue-ink);
    text-transform: uppercase;
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 0.8rem;
}

.inv-attachgrid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.inv-attachgrid img { width: 100%; border: 1px solid #ddd; }

/* ============ MOBILE ============ */

@media (max-width: 640px) {
    .field-grid { grid-template-columns: 1fr; }

    .items-header { display: none; }

    .item-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem 0.75rem;
        background: #fbfaf5;
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 0.9rem;
        margin-top: 0.8rem;
        position: relative;
    }

    .item-row .cell { display: flex; flex-direction: column; }

    .item-row .cell-date, .item-row .cell-plate { grid-column: 1 / -1; }

    .item-row .mobile-label {
        display: block;
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.09em;
        color: var(--ink-soft);
        margin-bottom: 0.25rem;
    }

    .item-num {
        position: absolute;
        top: -11px;
        left: 12px;
        background: var(--yellow);
        color: var(--green-deep);
        border-radius: 6px;
        padding: 0 0.5rem;
        font-size: 0.85rem;
        line-height: 1.5;
    }

    .btn-remove {
        position: absolute;
        top: -11px;
        right: 12px;
        width: auto;
        height: auto;
        padding: 0 0.6rem;
        font-size: 0.8rem;
        line-height: 1.7;
        border-radius: 6px;
    }

    .invoice-actions .btn { padding: 0.75rem 1rem; font-size: 0.95rem; }

    .inv-headbar { padding: 0.8rem 1.1rem; }
    .inv-headbar h1 { font-size: 1.7rem; }
    .inv-body { padding: 0.4rem 1.1rem 1.6rem; }
    .inv-meta { text-align: left; }
    .inv-table th, .inv-table td { padding: 0.4rem 0.25rem; font-size: 0.8rem; }
}

/* Desktop: hide per-cell labels & row wrappers act as plain grid cells */
@media (min-width: 641px) {
    .item-row .cell { display: contents; }
}

/* ============ PRINT ============ */

@media print {
    body { background: #fff; }
    #appView, .action-bar, .no-print { display: none !important; }
    #invoiceView { padding: 0; background: #fff; }
    .invoice-doc { box-shadow: none; max-width: none; }
    .inv-attachments { page-break-before: always; }
}
