/*
 * EMH: client area (estimate, invoice, contract, statement and portal pages)
 * readable on a phone. Loaded on every client page by emh_client_mobile_helper.php.
 */

/* Lines of an estimate / invoice as full-width blocks (App_items_table::html_full_width_list) */
.emh-items { border-top: 1px solid #e5e7eb; margin-bottom: 15px; }
.emh-item { border-bottom: 1px solid #e5e7eb; }
.emh-item-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 20px;
    background: #faf6f1; padding: 10px 12px; }
.emh-item-img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; flex: 0 0 auto; }
.emh-item-title { flex: 1 1 260px; min-width: 0; font-weight: 600; color: #1f2937;
    white-space: normal; overflow-wrap: anywhere; }
.emh-item-nums { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-left: auto; }
.emh-num { display: flex; flex-direction: column; align-items: flex-end; min-width: 56px; }
.emh-num-label { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: .02em; }
.emh-num-value { white-space: nowrap; color: #111827; }
.emh-item-desc { padding: 10px 12px 14px; color: #424242; white-space: normal;
    overflow-wrap: anywhere; line-height: 1.55; }
.emh-item-desc img { max-width: 100%; height: auto; }

/* Invoice custom fields (e.g. "Situation Facture") are printed outside the white card */
.emh-invoice-cf { padding: 8px 15px 0; }

@media (max-width: 767px) {
    /* Line blocks: figures under the title, spread across the width */
    .emh-item-nums { margin-left: 0; width: 100%; justify-content: space-between; }
    .emh-num { align-items: flex-start; }

    /* The company logo filled the whole first screen */
    .estimate-html-logo img, .invoice-html-logo img, .contract-html-logo img,
    .estimate-html-logo, .invoice-html-logo, .contract-html-logo { max-width: 150px; height: auto; }

    /* Client details under the company details: left-aligned like them */
    .transaction-html-info-col-right, .transaction-html-info-col-right .text-right,
    .transaction-html-info-col-right address { text-align: left !important; }
    .transaction-html-info-col-right { margin-top: 12px; }

    /* Long words, e-mails and links wrap instead of widening the page */
    body.customers { overflow-wrap: break-word; }

    /* Tables wrap their text instead of scrolling sideways (Bootstrap sets nowrap) */
    .table-responsive > .table > thead > tr > th,
    .table-responsive > .table > tbody > tr > th,
    .table-responsive > .table > tbody > tr > td,
    .table-responsive > .table > tfoot > tr > td { white-space: normal; }

    /* Totals: label and amount stay on one line each */
    #subtotal td, #total td, .table.text-right td { padding-left: 4px; padding-right: 4px; }

    /* Pictures and tables pasted in notes, terms or contract text never exceed the screen */
    .customers img { max-width: 100%; height: auto; }
    .invoice-html-note table, .invoice-html-terms-and-conditions table,
    .estimate-html-note table, .estimate-html-terms-and-conditions table { max-width: 100%; }

    /* Payments received: the four columns share the card's width */
    .invoice-html-payments .table th, .invoice-html-payments .table td { padding: 6px 4px; }

    /* Action buttons (download, accept, decline, pay) wrap onto a second row */
    .action-button { margin-bottom: 6px; }

    /* Signing window: full width on a phone */
    #identityConfirmationModal .modal-dialog { margin: 8px; }
    #identityConfirmationModal .control-label.col-sm-2 { padding-top: 0; }
}
