:root {
    --primary-color: #0056b3; /* Azul JM Plásticos */
    --accent-color: #004494;
    --success-color: #28a745;
    --highlight-bg: #e3f2fd;
    --border-color: #dee2e6;
}

body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f8f9fa; color: #333; margin: 0; padding-bottom: 100px; }

/* Header */
header { background-color: #fff; padding: 15px 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); position: sticky; top: 0; z-index: 1000; }
.header-content { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
h1 { margin: 0; color: var(--primary-color); font-size: 1.5rem; text-align: center; text-transform: uppercase; letter-spacing: 1px; }

.controls { display: flex; gap: 10px; margin-top: 5px; }
.search-box { flex: 1; }
.search-box input { width: 100%; padding: 12px; border: 1px solid #ced4da; border-radius: 6px; font-size: 1rem; box-sizing: border-box; }

.btn-reset { padding: 0 20px; background-color: #dc3545; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; }

/* Tabela */
.container { max-width: 1200px; margin: 20px auto; background: #fff; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); overflow: hidden; }

.category-block { border-bottom: 1px solid #eee; }
.category-header { background-color: var(--primary-color); color: white; padding: 12px 15px; font-weight: bold; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.category-subtotal { background: rgba(255,255,255,0.2); padding: 4px 8px; border-radius: 4px; font-size: 0.9em; }

table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid #eee; }
th { background-color: #e9ecef; color: #495057; font-size: 0.85rem; text-transform: uppercase; font-weight: 700; }

/* Colunas Específicas */
.col-img { width: 50px; text-align: center; }
.col-ref { width: 80px; text-align: center; color: #6c757d; font-weight: bold; }
.col-desc { font-weight: 500; }
.col-emb { width: 80px; text-align: center; color: #6c757d; font-size: 0.9em; }
.col-price { width: 100px; text-align: right; font-weight: bold; color: var(--primary-color); }
.col-qty { width: 80px; text-align: center; }
.col-total { width: 110px; text-align: right; font-weight: bold; color: var(--success-color); }

/* Inputs */
input[type="number"] { width: 60px; padding: 8px; border: 1px solid #ced4da; border-radius: 4px; text-align: center; font-size: 1.1em; }
input[type="number"]:focus { border-color: var(--primary-color); outline: none; background-color: #fff; box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.25); }

tr.active-row { background-color: var(--highlight-bg); }

/* Imagens */
.product-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; cursor: zoom-in; border: 1px solid #dee2e6; }
.image-modal { display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.9); justify-content: center; align-items: center; }
.modal-content { max-width: 90%; max-height: 90vh; border-radius: 5px; }
.close-modal { position: absolute; top: 20px; right: 35px; color: #fff; font-size: 40px; font-weight: bold; cursor: pointer; }

/* Footer */
.total-bar { position: fixed; bottom: 0; left: 0; right: 0; background-color: #fff; padding: 15px 20px; box-shadow: 0 -2px 10px rgba(0,0,0,0.1); display: flex; justify-content: space-between; align-items: center; z-index: 1000; border-top: 1px solid #dee2e6; }
.totals-group { display: flex; gap: 20px; }
.total-item { display: flex; flex-direction: column; }
.total-item span { font-size: 0.75rem; text-transform: uppercase; color: #6c757d; }
.total-item strong { font-size: 1.3rem; color: var(--primary-color); }
#grand-total-final { color: var(--success-color); }

.action-group { display: flex; gap: 10px; }
.btn-whatsapp, .btn-print { padding: 10px 20px; border-radius: 50px; border: none; font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 5px; color: white; transition: opacity 0.2s; }
.btn-whatsapp { background-color: #28a745; }
.btn-print { background-color: #6c757d; }
.btn-whatsapp:hover, .btn-print:hover { opacity: 0.9; }

/* Mobile */
@media (max-width: 768px) {
    .col-img, .col-ref, .col-emb { display: none; }
    .btn-whatsapp span, .btn-print span.mobile-hide { display: none; }
    .btn-whatsapp::after { content: " Enviar"; }
    .category-header { font-size: 0.9rem; }
}

/* Impressão */
.print-header, .print-summary { display: none; }
@media print {
    header, .total-bar, .controls, .image-modal, .btn-print, .btn-whatsapp { display: none !important; }
    body { background: white; font-size: 11px; font-family: Arial, sans-serif; }
    .container { box-shadow: none; padding: 0; }
    
    .print-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 15px; }
    .print-logo-area { display: flex; align-items: center; gap: 15px; }
    .print-logo-area img { height: 50px; }
    .company-info h2 { margin: 0; font-size: 14px; color: #000; }
    .company-info p { margin: 2px 0; font-size: 10px; color: #333; }
    
    table { width: 100%; border-collapse: collapse; font-size: 10px; }
    thead { display: table-header-group; }
    th { background-color: #eee !important; color: #000 !important; border: 1px solid #000; padding: 4px; -webkit-print-color-adjust: exact; }
    td { border: 1px solid #000; padding: 4px; }
    
    /* Mostrar colunas importantes no print */
    .col-ref { display: table-cell; width: 10%; text-align: center; }
    .col-desc { width: 45%; }
    .col-emb { display: table-cell; width: 10%; text-align: center; }
    .col-price { width: 10%; text-align: right; }
    .col-qty { width: 10%; text-align: center; }
    .col-total { width: 15%; text-align: right; color: #000 !important; }
    .col-img { display: none !important; } /* Esconde foto no print */

    input[type="number"] { border: none; background: transparent; text-align: center; font-weight: bold; padding: 0; width: auto; font-size: 10px; }
    
    /* Limpeza de vazios */
    body.printing-clean .category-block { display: none; margin-bottom: 10px; page-break-inside: avoid; }
    body.printing-clean .category-block.has-items { display: block; }
    body.printing-clean .category-header { background-color: #ccc !important; color: #000 !important; border: 1px solid #000; padding: 4px; -webkit-print-color-adjust: exact; }
    body.printing-clean .category-subtotal { display: none; }
    body.printing-clean tbody tr:not(.active-row) { display: none; }

    .print-summary { display: block; margin-top: 15px; float: right; width: 250px; border: 1px solid #000; padding: 8px; page-break-inside: avoid; }
    .print-row { display: flex; justify-content: space-between; margin-bottom: 4px; }
    .print-row.big { border-top: 1px solid #000; padding-top: 4px; font-weight: bold; font-size: 12px; margin-top: 4px; }
}