/* --- LAYOUT DE 3 COLUMNAS --- */
.pos-layout {
    display: grid; grid-template-columns: 1fr 340px 340px; gap: 20px;
    padding: 20px; flex: 1; overflow: hidden;
}
.products-section, .cart-section, .checkout-section { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

/* --- COLUMNA 1: Panel de Productos --- */
.search-bar { margin-bottom: 16px; }
.search-bar input { width: 100%; font-size: 1.05rem; padding: 12px 16px; background-color: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); transition: all 0.2s ease; }
.search-bar input:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; overflow-y: auto; padding-bottom: 20px; }
.product-card { background-color: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 14px; cursor: pointer; transition: all 0.2s ease; display: flex; flex-direction: column; justify-content: space-between; min-height: 130px; }
.product-card:hover { border-color: var(--brand-primary); box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.product-card.out-of-stock { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.product-sku { font-family: var(--font-mono); font-size: 0.75rem; color: var(--brand-primary); font-weight: 700; margin-bottom: 4px; }
.product-name { font-size: 0.9rem; font-weight: 600; color: var(--text-main); margin-bottom: 12px; line-height: 1.3; }
.product-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.product-price { font-weight: 800; font-size: 1.05rem; color: var(--text-main); }
.product-stock { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); background-color: var(--bg-base); padding: 4px 8px; border-radius: var(--radius-sm); }

/* --- Títulos compartidos --- */
.cart-section { padding: 0; }
.checkout-section { padding: 0; justify-content: space-between; }
.cart-section h2, .checkout-section h2 { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--border-color); font-size: 1.1rem; flex-shrink: 0; }

/* --- COLUMNA 2: Panel de la Cesta --- */
.cart-items-container { flex: 1; overflow-y: auto; padding: 10px 20px; }
.cart-list { list-style: none; margin: 0; padding: 0; }
.empty-cart-msg { text-align: center; color: var(--text-muted); padding: 40px 0; font-style: italic; }
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.item-info { flex: 1; }
.item-name { font-size: 0.85rem; font-weight: 600; color: var(--text-main); display: block; margin-bottom: 4px; }
.item-price { font-size: 0.8rem; color: var(--text-muted); }
.item-actions { display: flex; align-items: center; gap: 10px; }
.qty-control { display: flex; align-items: center; background-color: var(--bg-base); border-radius: var(--radius-sm); border: 1px solid var(--border-color); }
.qty-btn { background: none; border: none; padding: 4px 8px; cursor: pointer; font-weight: bold; color: var(--text-main); }
.qty-btn:hover { background-color: var(--border-color); }
.item-qty { font-size: 0.85rem; font-weight: 600; min-width: 20px; text-align: center; }
.remove-btn { color: var(--brand-accent); background: none; border: none; cursor: pointer; font-size: 1.2rem; padding: 4px; }

/* --- COLUMNA 3: Resumen y Pago --- */
.checkout-content { flex: 1; overflow-y: auto; padding: 20px; }
.summary-block { margin-bottom: 20px; }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 0.95rem; color: var(--text-muted); }
.total-row { font-size: 1.3rem; font-weight: 800; color: var(--text-main); margin-bottom: 0; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-color); }
.total-amount { color: var(--brand-primary); }

/* --- Botón "Procesar Venta" Premium --- */
.checkout-footer { padding: 20px; border-top: 1px solid var(--border-color); background-color: var(--bg-surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.btn-large { width: 100%; padding: 18px; font-size: 1.15rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; border-radius: var(--radius-lg); transition: all 0.3s ease; }

#btnProcessSale {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
}
#btnProcessSale:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
}
#btnProcessSale:disabled {
    background: var(--bg-surface-hover);
    color: var(--text-muted);
    border: 2px dashed var(--border-color);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.8;
}

/* UI DTE (Boleta/Factura Switch) */
.dte-section { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px dashed var(--border-color); }
.dte-toggle { display: flex; background-color: var(--bg-base); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 4px; margin-bottom: 12px; }
.dte-toggle input[type="radio"] { display: none; }
.dte-toggle label { flex: 1; text-align: center; padding: 8px 12px; margin-bottom: 0; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.85rem; font-weight: 700; color: var(--text-muted); transition: all 0.2s ease; }
.dte-toggle input[type="radio"]:checked + label { background-color: var(--bg-surface); color: var(--brand-primary); box-shadow: var(--shadow-card); }

/* --- Buscador Integrado de Clientes --- */
.client-search-box { animation: fadeIn 0.3s ease; margin-top: 16px; }
.integrated-search {
    display: flex; align-items: stretch; background-color: var(--bg-surface);
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    overflow: hidden; height: 44px; transition: border-color 0.2s, box-shadow 0.2s;
}
.integrated-search:focus-within { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15); }
.search-icon-prefix { display: flex; align-items: center; justify-content: center; padding-left: 12px; color: var(--text-muted); }

.integrated-search input {
    flex: 1; min-width: 0;
    border: none; background: transparent; padding: 0 10px;
    color: var(--text-main); font-size: 0.95rem; font-family: var(--font-family);
}
.integrated-search input:focus { outline: none; box-shadow: none; }

.btn-icon-clear { background: transparent; border: none; font-size: 1.4rem; color: var(--text-muted); cursor: pointer; padding: 0 10px; flex-shrink: 0; transition: color 0.2s; display: flex; align-items: center;}
.btn-icon-clear:hover { color: var(--brand-accent); }
.btn-icon-clear.hidden { display: none !important; }

.btn-search-action {
    background-color: var(--bg-surface-hover); border: none;
    border-left: 1px solid var(--border-color); padding: 0 14px;
    color: var(--brand-primary); font-weight: 700; font-size: 0.85rem;
    cursor: pointer; flex-shrink: 0; transition: all 0.2s;
}
.btn-search-action:hover { background-color: var(--brand-primary); color: #ffffff; }

/* --- Mensajes y Tarjeta de Cliente --- */
.client-feedback { font-size: 0.85rem; margin-top: 8px; font-weight: 600; color: var(--brand-accent); }

.assigned-client-card {
    background: rgba(14, 165, 233, 0.05); border: 1px solid rgba(14, 165, 233, 0.3);
    border-radius: var(--radius-md); padding: 12px 16px; margin-top: 12px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    animation: fadeIn 0.3s ease;
}
.assigned-client-card.hidden { display: none; }
.assigned-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.assigned-name { font-weight: 700; color: var(--text-main); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.assigned-rut { font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px;}
.assigned-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.btn-modern-link { background: none; border: 1px solid var(--brand-primary); color: var(--brand-primary); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 0.75rem; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.btn-modern-link:hover { background: var(--brand-primary); color: #fff; }

/* --- Módulo de Pagos --- */
.payment-section { margin-bottom: 10px; }
.payment-select { width: 100%; padding: 12px; border-radius: var(--radius-md); border: 1px solid var(--border-color); background-color: var(--bg-base); color: var(--text-main); font-size: 0.95rem; font-weight: 600; margin-bottom: 10px; cursor: pointer; }
.payment-select:focus { border-color: var(--brand-primary); outline: none; }
.voucher-container { transition: all 0.3s ease; }
.voucher-container input { width: 100%; padding: 12px; border-radius: var(--radius-md); border: 1px solid var(--brand-secondary); background-color: var(--bg-surface); color: var(--text-main); font-size: 0.95rem; font-family: var(--font-mono); }
.voucher-container input:focus { outline: none; box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); }

/* --- Modal Base --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; transition: opacity 0.2s ease; }
.modal-overlay.hidden { display: none; opacity: 0; }
.modal-card { background: var(--bg-surface); border-radius: var(--radius-lg); width: 100%; max-width: 450px; padding: 28px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); border: 1px solid var(--border-color); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.btn-close-modal { background: none; border: none; font-size: 1.8rem; color: var(--text-muted); cursor: pointer; line-height: 1; padding: 0; margin-left: 12px; }
.btn-close-modal:hover { color: var(--brand-accent); }
.btn-icon-action { background: var(--bg-base); border: 1px solid var(--border-color); color: var(--text-muted); border-radius: var(--radius-sm); padding: 4px 6px; cursor: pointer; display: flex; align-items: center; transition: all 0.2s; }
.btn-icon-action:hover { color: var(--brand-primary); border-color: var(--brand-primary); }

/* --- Botones Sólidos del Modal --- */
.btn-primary-solid { background: var(--brand-primary); color: #fff; border: none; padding: 10px 16px; border-radius: var(--radius-md); font-weight: 600; cursor: pointer; transition: all 0.2s; font-size: 0.9rem; }
.btn-primary-solid:hover { background: #0284c7; }
.btn-primary-solid:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary-solid { background: var(--bg-surface-hover); color: var(--text-main); border: 1px solid var(--border-color); padding: 10px 16px; border-radius: var(--radius-md); font-weight: 600; cursor: pointer; transition: all 0.2s; font-size: 0.9rem; }
.btn-secondary-solid:hover { background: var(--border-color); }

/* --- Formularios y Estados del Modal (View vs Edit) --- */
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-body label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Modo Lectura (Sobrio con sombra sutil y borde finito) */
.input-readonly {
    width: 100%;
    background-color: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
    color: var(--text-main) !important;
    padding: 10px 12px !important;
    font-size: 0.95rem; font-family: inherit; font-weight: 600;
    cursor: default; transition: all 0.2s ease;
}

/* Modo Edición (Activo e iluminado) */
.input-editable {
    width: 100%; background-color: var(--bg-base) !important; border: 1px solid var(--brand-primary) !important;
    border-radius: var(--radius-md) !important; color: var(--text-main) !important; padding: 10px 12px !important;
    font-size: 0.95rem; font-family: inherit; font-weight: 400; cursor: text;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15) !important; transition: all 0.2s ease;
}
.input-editable:focus { outline: none; box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.3) !important; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

/* --- APROBACIONES (NUEVO) --- */
.approval-bar { background: #f59e0b; color: white; padding: 12px 24px; text-align: center; font-weight: 700; cursor: pointer; font-size: 0.95rem; box-shadow: 0 2px 4px rgba(0,0,0,0.1); transition: background 0.2s; }
.approval-bar:hover { background: #d97706; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.7); display: flex; align-items: center; justify-content: center; z-index: 9999; backdrop-filter: blur(4px); }
.modal-card { background: var(--bg-surface); padding: 32px; border-radius: var(--radius-lg); width: 100%; max-width: 900px; border: 1px solid var(--border-color); box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); max-height: 90vh; display: flex; flex-direction: column; }
.btn-approve { background: #10b981; color: white; border: none; padding: 6px 12px; border-radius: var(--radius-sm); font-size: 0.75rem; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.btn-approve:hover { background: #059669; }
.btn-reject { background: #ef4444; color: white; border: none; padding: 6px 12px; border-radius: var(--radius-sm); font-size: 0.75rem; font-weight: 700; cursor: pointer; transition: all 0.2s; margin-left: 8px; }
.btn-reject:hover { background: #dc2626; }
