/* ═══════════════════════════════════════════════════════════════════
   Phone layout for the entry screens (Sale Invoice / Bullion, Sale Bill,
   Purchase, Orders, Quotation-Proforma-Challan, Credit / Debit Note).
   Each item line of table.prod-table becomes a card; cells get their
   column name from js/entry-mobile.js (data-label).
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 760px) {
    table.prod-table, table.prod-table tbody { display: block; width: 100%; }
    table.prod-table thead { display: none; }

    table.prod-table tr {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px 10px;
        position: relative;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 12px 12px 12px;
        margin-bottom: 10px;
        box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
    }
    table.prod-table td {
        display: block;
        padding: 0 !important;
        border: none !important;
        min-width: 0 !important;
        width: auto !important;
    }
    table.prod-table td::before {
        content: attr(data-label);
        display: block;
        font-size: .62rem;
        font-weight: 700;
        color: #94a3b8;
        text-transform: uppercase;
        letter-spacing: .04em;
        margin-bottom: 3px;
    }
    table.prod-table td:not([data-label])::before,
    table.prod-table td[data-label=""]::before { display: none; }

    /* Serial-number cell: not needed on a card */
    table.prod-table td:first-child:not(:has(input, select, button)) { display: none; }

    /* Item name and remark across the whole card */
    table.prod-table td.td-product,
    table.prod-table td:has(.prod-name-input),
    table.prod-table td:has(.row-remark) { grid-column: 1 / -1; }
    table.prod-table td.td-product { padding-right: 40px !important; }

    /* Inputs: full cell width, tappable, 16px so iOS doesn't zoom */
    table.prod-table td input,
    table.prod-table td select {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
        font-size: 16px !important;
        padding: 8px 9px !important;
        border: 1.5px solid #e2e8f0 !important;
        border-radius: 8px !important;
        background: #f8fafc;
    }
    /* beats the desktop ".prod-table .prod-name-input{min-width:280px!important}" */
    table.prod-table td input.prod-name-input,
    table.prod-table td input.row-remark { min-width: 0 !important; font-weight: 700; }
    table.prod-table td > div { flex-wrap: nowrap; }
    table.prod-table td > div > input { flex: 1 1 auto; }

    /* Delete button in the card's top-right corner */
    table.prod-table td:has(.del-row-btn) { position: absolute; top: 10px; right: 10px; }
    table.prod-table td:has(.del-row-btn)::before { display: none; }
    table.prod-table .del-row-btn { width: 32px; height: 32px; }

    /* Item grid container shouldn't scroll sideways any more */
    .ep-card-body:has(> table.prod-table) { overflow-x: visible !important; }

    /* Add Item / New Product buttons: full width, stacked */
    .ep-card-body:has(> table.prod-table) .add-row-btn {
        width: 100%; justify-content: center; margin-left: 0 !important; margin-top: 8px;
    }

    /* Two-block cards (Invoice Summary): stack the blocks */
    .ep-card-body > .fg.fg2 > div:not(.ff) { grid-column: 1 / -1; }

    /* Spot payment lines: account on its own row, mode + amount + remove below */
    table:has(> tbody#spotPayBody) thead { display: none; }
    table:has(> tbody#spotPayBody), #spotPayBody { display: block; width: 100%; }
    #spotPayBody tr {
        display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px; gap: 6px;
        border: 1px solid #e2e8f0; border-radius: 10px; padding: 8px; margin-bottom: 8px;
    }
    #spotPayBody td { display: block; padding: 0 !important; min-width: 0; }
    #spotPayBody td:first-child { grid-column: 1 / -1; }
    #spotPayBody td[colspan] { grid-column: 1 / -1; border: none; }
    #spotPayBody select, #spotPayBody input { width: 100%; font-size: 16px; }
    #spotPayFoot { flex-wrap: wrap; justify-content: space-between !important; gap: 8px !important; }

    /* No sideways sliding: nothing on an entry page may be wider than the screen */
    .ep, .ep-body, .ep-card { max-width: 100vw; overflow-x: clip; }
    .ep-card-body { overflow-x: clip !important; }
    .ac-list { max-width: calc(100vw - 16px) !important; min-width: 0 !important; }

    /* Footer buttons stay comfortable on small screens */
    .ep-footer { padding: 10px 12px !important; }
    .ep-body { padding: 10px !important; }
    .ep-card-body { padding: 12px !important; }
}

/* Phones: two number fields per row so amounts like 5,00,000.00 fit */
@media (max-width: 520px) {
    table.prod-table tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
