/* ==========================================================================
   BuildMart POS - Style & Global Layout Configuration
   ========================================================================== */

:root {
    --primary: #0f172a;
    --accent: #f27a1a;
    --bg-main: #f8fafc;
    --border-color: #cbd5e1;
    --text-main: #1e293b;
    --font-kh: 'Kantumruy Pro', 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-kh);
}

body {
    background-color: #f1f5f9;
    color: var(--text-main);
    overflow-x: hidden;
}

.pos-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ផ្នែកខាងឆ្វេង៖ បញ្ជីទំនិញ */
.product-catalog-panel {
    width: 63%;
    background: white;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.catalog-header h2 {
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: 700;
}

/* ប្រអប់ Excel Auto Importer Dropzone */
.excel-dropzone {
    background: #f8fafc;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 0.85rem;
    text-align: center;
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
}
.excel-dropzone.dragover {
    border-color: var(--accent);
    background: #fff3e6;
}
.excel-dropzone p {
    font-size: 0.85rem;
    color: #475569;
}
.excel-dropzone label {
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}
.dropzone-icon {
    font-size: 1.3rem;
    display: block;
    margin-bottom: 0.15rem;
}
.btn-download-json {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-top: 0.5rem;
    font-weight: 600;
}

.search-wrapper input {
    width: 100%;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    margin-bottom: 1rem;
}
.search-wrapper input:focus {
    border-color: var(--accent);
}

.table-scroll-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.catalog-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.catalog-table th {
    background: #f1f5f9;
    padding: 0.75rem;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid var(--border-color);
}
.catalog-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}
.catalog-code {
    background: #e2e8f0;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Inter';
    font-weight: 600;
}
.badge {
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.8rem;
}
.catalog-price {
    font-weight: 600;
    color: var(--primary);
}

/* គ្រាប់ចុចគ្រប់គ្រងបរិមាណតាមជួរ */
.table-action-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}
.input-row-qty {
    width: 45px;
    padding: 0.3rem;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-weight: 600;
}
.btn-row-add {
    background: #10b981;
    color: white;
    border: none;
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
.btn-row-add:hover { background: #059669; }
.btn-row-bulk {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
}

/* ផ្នែកខាងស្តាំ៖ វិក្កយបត្រ */
.checkout-sidebar {
    width: 37%;
    background: #edf2f7;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.customer-box h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}
.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.input-row input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
    outline: none;
}

/* ទម្រង់សន្លឹកវិក្កយបត្រ */
.invoice-sheet {
    background: white;
    flex: 1;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}
.brand-side h1 { font-size: 1.2rem; color: var(--primary); }
.store-name { font-size: 0.9rem; font-weight: bold; }
.store-sub { font-size: 0.75rem; color: #64748b; }
.meta-side { text-align: right; font-size: 0.8rem; }

.invoice-customer-card {
    background: #f8fafc;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.invoice-items-wrapper { flex: 1; }
.invoice-items-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.invoice-items-table th { border-bottom: 1px solid var(--text-main); padding: 0.4rem 0; text-align: left; }
.invoice-items-table td { padding: 0.5rem 0; border-bottom: 1px dashed #e2e8f0; }

.qty-action-container { display: flex; align-items: center; justify-content: center; gap: 0.25rem; }
.btn-qty-adj { background: #cbd5e1; border: none; width: 20px; height: 20px; border-radius: 3px; cursor: pointer; font-weight: bold; }

.invoice-summary-box {
    border-top: 2px solid var(--primary);
    padding-top: 0.5rem;
    margin-top: 0.75rem;
}
.summary-line { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 0.35rem; }
.discount-input-wrapper input { width: 50px; text-align: center; padding: 0.2rem; }
.grand-total-line { font-size: 1.1rem; font-weight: 700; color: var(--accent); border-top: 1px solid #e2e8f0; padding-top: 0.35rem; }

.invoice-footer { text-align: center; font-size: 0.75rem; margin-top: 0.75rem; color: #64748b; }

.btn-print-invoice {
    width: 100%; background: var(--accent); color: white; border: none; padding: 0.75rem; font-weight: 700; border-radius: 6px; cursor: pointer; margin-top: 0.75rem;
}
.btn-print-invoice:hover { background: var(--primary); }

/* ប៊ូតុងបើកផ្ទាំងបន្ថែមទំនិញ */
.btn-open-modal {
    background: var(--primary); color: white; border: none; padding: 0.5rem 1rem; border-radius: 6px; font-weight: 600; font-size: 0.85rem; cursor: pointer;
}
.btn-open-modal:hover { background: var(--accent); }

/* ផ្ទាំងរចនា Modal Popup */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-card { background: white; width: 100%; max-width: 480px; border-radius: 8px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); overflow: hidden; animation: slideUp 0.2s ease-out; }
@keyframes slideUp { from { transform: translateY(20px); } to { transform: translateY(0); } }

.modal-card-header { background: var(--primary); color: white; padding: 1rem; display: flex; justify-content: space-between; align-items: center; }
.modal-card-header h3 { font-size: 1rem; }
.btn-close-modal-x { background: transparent; color: white; border: none; font-size: 1.5rem; cursor: pointer; }

#addProductForm { padding: 1.25rem; }
.form-group { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: #334155; text-align: left; }
.form-group input { padding: 0.6rem; border: 1px solid var(--border-color); border-radius: 4px; font-size: 0.9rem; outline: none; }
.form-group input:focus { border-color: var(--accent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.modal-card-footer { padding: 1rem 0 0 0; display: flex; justify-content: flex-end; gap: 0.5rem; }
.btn-cancel { background: #e2e8f0; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; font-weight: 500; }
.btn-submit { background: var(--accent); color: white; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; font-weight: 600; }

/* ប្រព័ន្ធគ្រប់គ្រងសម្រាប់ការបោះពុម្ពវិក្កយបត្រ (Print Layout) */
@media print {
    body, .pos-container { background: white; height: auto; display: block; }
    .no-print { display: none !important; }
    .checkout-sidebar { width: 100%; padding: 0; background: transparent; }
    .invoice-sheet { box-shadow: none; padding: 0; overflow: visible; }
    .print-only { display: inline !important; }
}
.print-only { display: none; }