/* css/document.css - rules shared by /invois and /sebutharga. Each page keeps its own rules in an inline <style> after this file. */

/* --- UI HEADER --- */
.top-bar {
    background: white;
    height: 60px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-sub {
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 10px;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0;
}

/* Six actions plus the brand and language toggle do not fit one row on
   a phone (resit needs ~460px, invois/sebutharga ~510px). The overflow
   is not cosmetic: a document wider than the viewport makes mobile
   Chrome widen the layout viewport, and the position:fixed footer
   follows it, pushing "Kongsi PDF" off-screen (reported 2026-08-22).
   Wrap the actions onto their own full-width row instead. */
@media (max-width: 600px) {
    .top-bar {
        height: auto;
        flex-wrap: wrap;
        padding: 10px 12px;
        row-gap: 8px;
    }

    .top-actions {
        flex: 1 1 100%;
        justify-content: space-between;
        gap: 6px;
    }
}

@media (max-width: 480px) {
    /* Six equal columns, each an icon with its name underneath: several of the
       icons are near-identical document shapes, and people could not tell which
       one led to the receipt page without words. */
    .top-actions {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        align-items: stretch;
        gap: 4px;
    }

    .icon-btn {
        flex-direction: column;
        justify-content: flex-start;
        gap: 3px;
        padding: 7px 1px 5px;
        font-size: 10px;
        line-height: 1.15;
        text-align: center;
    }

    .icon-btn svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    /* The history count floats like the Produk dot, so it cannot resize its button. */
    .icon-btn.primary > span:last-child {
        position: absolute;
        top: 2px;
        right: 2px;
        padding: 1px 4px !important;
        font-size: 9px !important;
        line-height: 1;
    }

    .brand {
        font-size: 1rem;
    }

    .brand-sub {
        padding: 2px 7px;
        margin-left: 4px;
    }

    .lang-toggle {
        margin-left: 6px;
    }

    .lang-toggle-btn {
        padding: 4px 7px;
    }
}

@media (min-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr 400px;
        align-items: start;
    }

    .preview-col {
        position: sticky;
        top: 80px;
        order: 2;
    }

    .form-col {
        order: 1;
    }
}

@media (min-width: 768px) {
    .engage-row {
        grid-template-columns: 1fr 400px;
        align-items: stretch;
    }
}

.btn-main:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn-main .dl-icon {
    width: 18px;
    height: 18px;
    display: block;
}

/* --- INVOICE CANVAS --- */
/* True A4 proportions: aspect-ratio + height:auto means a short
   invoice still fills a full A4-shaped sheet (content top-anchored,
   white space below, like a real printed page), while a long invoice
   (many items) naturally grows taller than the ratio to fit its
   content - the PDF export then paginates that extra height instead
   of shrinking everything onto one page. Padding is percentage-based
   (~15mm-equivalent margins) so it scales with the canvas's actual
   rendered width instead of a fixed px value that under/over-shoots
   at different preview-column widths. */
/* Grid items default to min-width: auto, which held the document at about 365px
   wide on any smaller phone. */
.preview-col,
.form-col {
    min-width: 0;
}

#invoice-canvas {
    position: relative;
    margin: 0 auto;
    width: 100%;
    aspect-ratio: 210 / 297;
    height: auto;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    padding: 6% 7%;
    font-size: 12px;
    line-height: 1.5;
    color: #1f2937;
    font-family: 'Inter', sans-serif;
}

/* --- FORM CARD LABELS --- */
.card-label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 10px;
    text-transform: uppercase;
}

#inv-input-list {
    /* No inner scroll box: a 300px scroller inside a scrolling page traps the
       thumb on phones and showed only ~3 item cards. The page scrolls instead. */
    margin-bottom: 10px;
}

.btn-catalog {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.btn-additem {
    width: 100%;
    padding: 10px;
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
}

.history-card-shop {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
    padding-right: 30px;
}

/* --- TOAST --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--primary);
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* --- A4 INVOICE PREVIEW (structure adapted from the approved mockup) ---
   Sheet look (background, aspect-ratio, padding) now lives on
   #invoice-canvas above; this is just the full-width content wrapper
   so the header/table/totals/bank box span the sheet's inner width. */
.inv4-sheet {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

.inv4-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.inv4-logo {
    display: none;
    margin-bottom: 8px;
}

.inv4-shop {
    font-weight: 700;
    font-size: 15px;
    color: var(--primary);
}

.inv4-shopmeta {
    color: #6b7280;
    font-size: 11px;
    margin-top: 2px;
}

.inv4-header-right {
    text-align: right;
}

.inv4-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #111827;
}

.inv4-no {
    color: #6b7280;
    font-size: 11px;
    margin-top: 2px;
}

.inv4-no b {
    color: #111827;
}

.inv4-dates {
    margin-top: 8px;
    text-align: right;
    font-size: 11px;
    line-height: 1.6;
    color: #374151;
}

.inv4-dates b {
    color: #111827;
}

.inv4-subheader {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-top: 18px;
}

.inv4-box {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    background: #f8fafc;
}

.inv4-billto-box {
    flex: 1;
}

.inv4-box-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    font-weight: 700;
    margin-bottom: 3px;
}

.inv4-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 18px;
    font-size: 11px;
}

.inv4-table thead th {
    border-bottom: 2px solid #e5e7eb;
    color: #6b7280;
    text-align: left;
    font-weight: 600;
    padding: 6px 4px;
}

.inv4-table tbody td {
    border-bottom: 1px solid #f3f4f6;
    padding: 6px 4px;
}

.inv4-totals-wrap {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.inv4-totals {
    width: 240px;
    font-size: 11px;
}

.inv4-total-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.inv4-total-row>span:first-child {
    color: #6b7280;
}

.inv4-total-row>span:last-child {
    white-space: nowrap;
}

.inv4-neg {
    color: #b91c1c;
}

.inv4-total-final {
    border-top: 2px solid #111827;
    margin-top: 6px;
    padding-top: 8px;
    font-weight: 800;
    font-size: 14px;
    color: var(--primary);
}

.inv4-total-final>span:first-child {
    color: var(--primary);
}

.inv4-note {
    margin-top: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 11px;
}

/* Brand line, matching index.html. The canvas is already a true A4 page,
   so the sheet takes the flexible height and this sits at the page foot. */
.inv4-brand {
    margin-top: auto;
    padding-top: 12px;
    text-align: center;
    color: #a8b4c4;
    font-size: 8px;
}

.inv4-brand.is-hidden {
    display: none;
}
