/* Force desktop layout for PNG export, override all responsive/mobile styles */
.force-desktop-layout, .force-desktop-layout * {
    width: unset !important;
    min-width: unset !important;
    max-width: unset !important;
    font-size: unset !important;
    box-sizing: border-box !important;
}
.force-desktop-layout {
    width: 800px !important;
    min-width: 800px !important;
    max-width: 800px !important;
    padding: 30px 40px 20px 40px !important;
    font-size: 1em !important;
    border: 1px solid #333 !important;
    margin: 30px auto !important;
    background: #fff !important;
    box-sizing: border-box !important;
}
.force-desktop-layout table,
.force-desktop-layout .footer-table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    margin-top: 18px !important;
}
.force-desktop-layout th,
.force-desktop-layout td {
    font-size: 1em !important;
    padding: 10px 8px !important;
    border: 1px solid #bbb !important;
    word-break: break-word !important;
    text-align: center !important;
}
.force-desktop-layout th {
    background: #f5f5f5 !important;
    color: #1a3896 !important;
}
.force-desktop-layout .footer-table td {
    border: 1px solid #bbb !important;
    text-align: left !important;
    font-size: 1em !important;
    padding: 10px 8px !important;
}
.force-desktop-layout .footer-table .label {
    color: #1a3896 !important;
    font-weight: bold !important;
}
.force-desktop-layout .footer-table .value {
    border-bottom: 1px solid #1a3896 !important;
    min-width: 100px !important;
    display: inline-block !important;
}
.force-desktop-layout .header {
    flex-wrap: nowrap !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
}
.force-desktop-layout .logo {
    width: 120px !important;
    max-width: 120px !important;
}
.force-desktop-layout .qr {
    width: 100px !important;
    max-width: 100px !important;
}
.force-desktop-layout .title h1 {
    font-size: 2em !important;
}
.force-desktop-layout .title h2 {
    font-size: 1.2em !important;
}
.force-desktop-layout .invoice-info {
    flex-wrap: nowrap !important;
    font-size: 1em !important;
}
.force-desktop-layout table, .force-desktop-layout th, .force-desktop-layout td {
    font-size: 1em !important;
}
.force-desktop-layout .contact {
    font-size: 1em !important;
}
.force-desktop-layout #goods-tip, .force-desktop-layout #save-png-btn, .force-desktop-layout #reset-invoice-btn {
    display: none !important;
}
/* Force desktop layout for PNG export */
.force-desktop-layout {
    width: 800px !important;
    max-width: 98vw !important;
    padding: 30px 40px 20px 40px !important;
    font-size: 1em !important;
    border: 1px solid #333 !important;
    box-sizing: border-box !important;
}
@media (max-width: 600px) {
    .force-desktop-layout {
        width: 800px !important;
        min-width: 800px !important;
        max-width: 98vw !important;
        font-size: 1em !important;
        padding: 30px 40px 20px 40px !important;
    }
}
.editable:not(.show-placeholder), .value:not(.show-placeholder) {
    color: #222 !important;
    font-style: normal !important;
}
.show-placeholder {
    color: #bbb !important;
    font-style: italic !important;
}
.edit-dots {
    border-bottom: 1.5px dotted #1a3896;
    padding-bottom: 1px;
}
.hide-edit-dots {
    border-bottom: none !important;
}
/* Pencil icon for edit */
.edit-pencil {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    margin-left: 4px;
    vertical-align: middle;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.edit-pencil:hover {
    opacity: 1;
}
.edit-pencil.hide-pencil {
    display: none !important;
}
/* Make editable fields visually distinct */
.editable {
        border-bottom: 1.5px dotted #1a3896;
        cursor: pointer;
        transition: background 0.2s;
}
.editable:active, .editable:focus {
        background: #e6f0ff;
}
@media (hover: hover) and (pointer: fine) {
    .editable:hover {
        background: #e6f0ff;
    }
}
.edit-btn {
    background: none;
    border: none;
    padding: 0 2px;
    margin-left: 2px;
    cursor: pointer;
    vertical-align: middle;
    outline: none;
}
.edit-btn svg {
    display: inline;
    pointer-events: none;
}
/* Hide edit buttons when printing or saving as PNG (html2canvas) */
.edit-btn, .edit-btn * {
    -webkit-print-color-adjust: exact;
}
@media print {
    .edit-btn { display: none !important; }
}
.html2canvas-container .edit-btn {
    display: none !important;
}
/* Responsive tip message */
#goods-tip {
    max-width: 95vw;
    word-break: break-word;
}

@media (max-width: 600px) {
    #goods-tip {
        font-size: 1em;
        padding: 7px 4vw;
        top: 4px;
        border-radius: 6px;
        max-width: 98vw;
    }
}
body {
    font-family: 'Khmer OS', 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background: #fff;
}
.invoice-container {
    width: 800px;
    max-width: 98vw;
    margin: 30px auto;
    border: 1px solid #333;
    padding: 30px 40px 20px 40px;
    background: #fff;
    box-sizing: border-box;
}
.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
}
.logo {
    width: 120px;
    max-width: 30vw;
}
.qr {
    width: 100px;
    max-width: 25vw;
}

/* Constrain uploaded images for print/A4 export */
#logo-img, #qr-img {
    display: block;
    height: auto;
    max-width: 100%;
    object-fit: contain;
}

/* Upload buttons appearance */
#logo-upload-btn, #qr-upload-btn {
    font-size: 0.9em;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
}
.title {
    text-align: center;
    flex: 1 1 200px;
    min-width: 180px;
}
.title h1 {
    font-size: 2em;
    color: #1a3896;
    margin: 0;
}
.title h2 {
    font-size: 1.2em;
    margin: 0;
    color: #1a3896;
}
.contact {
    margin-top: 10px;
    font-size: 1em;
}
.invoice-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-top: 10px;
    font-size: 1em;
}
.invoice-info span {
    margin-left: 30px;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    table-layout: fixed;
    word-break: break-word;
}
th, td {
    border: 1px solid #1a3896;
    padding: 6px 2px;
    text-align: center;
    font-size: 1em;
    word-break: break-word;
}
th {
    background: #fff;
    color: #1a3896;
}
.footer-table td {
    border: none;
    text-align: left;
    font-size: 1em;
}
.footer-table .label {
    color: #1a3896;
    font-weight: bold;
}
.footer-table .value {
    border-bottom: 1px solid #1a3896;
    min-width: 100px;
    display: inline-block;
}
.signatures {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-top: 30px;
}
.sign {
    text-align: center;
    width: 30%;
}
.red {
    color: #d00;
    font-weight: bold;
}
.blue {
    color: #1a3896;
}

@media (max-width: 600px) {
    .invoice-container {
        padding: 8px 2vw 8px 2vw;
        width: 100vw;
        min-width: 0;
    }
    .header {
        flex-direction: column;
        align-items: stretch;
    }
    .logo, .qr {
        width: 80px;
        max-width: 40vw;
        margin: 0 auto 10px auto;
    }
    .title {
        min-width: 0;
    }
    table, th, td {
        font-size: 0.95em;
        padding: 4px 1px;
    }
    .footer-table td {
        font-size: 0.95em;
        display: block;
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 10px;
    }

    /* Signature pad responsive styles */
    #buyer-signature, #seller-signature {
        width: 100% !important;
        min-width: 120px;
        max-width: 100vw;
        height: 120px !important;
        display: block;
        margin: 10px 0 8px 0;
        background: #fff;
        border: 2px solid #888;
        border-radius: 8px;
        touch-action: none;
    }
    #clear-buyer-signature, #clear-seller-signature {
        width: 100%;
        margin-bottom: 12px;
        font-size: 1.1em;
        padding: 10px 0;
        border-radius: 6px;
        background: #f5f5f5;
        border: 1px solid #bbb;
    }
}
