/* ============================================================
   pos.css  --  Point of Sale styles
   ============================================================ */

.pos-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 5rem 2rem 2rem;
}

/* --- Layout: 2 columns --- */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1.5rem;
    align-items: start;
}

/* --- Left: Search + Cart --- */
.pos-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- Customer bar --- */
.customer-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.customer-bar .cb-search {
    flex: 1;
    padding: 0.5rem 0.8rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.customer-bar .cb-search:focus {
    outline: none;
    border-color: var(--accent);
}

.customer-bar .cb-selected {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex: 1;
}

.customer-bar .cb-name {
    font-weight: 700;
    font-size: 1rem;
}

.customer-bar .cb-rfc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.customer-bar .cb-balance {
    font-size: 0.85rem;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
}

.cb-balance.positive { background: rgba(255, 68, 68, 0.15); color: var(--danger); }
.cb-balance.zero { background: rgba(34, 197, 94, 0.15); color: var(--success); }

/* --- Customer dropdown --- */
.customer-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.customer-dropdown-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.customer-dropdown-item:hover {
    background: var(--bg-hover);
}

.customer-dropdown-item .cdi-name { font-weight: 600; }
.customer-dropdown-item .cdi-rfc { font-size: 0.8rem; color: var(--text-secondary); }

/* --- Part search --- */
.part-search-wrap {
    position: relative;
}

.part-search {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
}

.part-search:focus {
    outline: none;
    border-color: var(--accent);
}

.part-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0 0 10px 10px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    display: none;
}

.part-result-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.part-result-item:hover,
.part-result-item.part-result-active {
    background: var(--bg-hover);
    border-left: 3px solid var(--accent);
}

.part-result-item .pri-number {
    font-family: monospace;
    font-weight: 600;
    color: var(--accent);
}

.part-result-item .pri-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.part-result-item .pri-type {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.pri-type.oem { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.pri-type.aftermarket { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

/* --- Cart table --- */
.cart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.cart-card h3 {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.cart-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.cart-table th {
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.cart-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid rgba(42, 42, 58, 0.5);
    vertical-align: middle;
}

.cart-table input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 0.3rem 0.4rem;
    font-size: 0.85rem;
    width: 70px;
    text-align: right;
}

.cart-table input:focus {
    outline: none;
    border-color: var(--accent);
}

.cart-table .cart-desc { max-width: 250px; }
.cart-table .cart-qty { width: 45px; text-align: center; }
.cart-table .cart-cost { width: 80px; }
.cart-table .cart-margin { width: 55px; }
.cart-table .cart-price { width: 80px; }

.cart-table .cart-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem;
}

.cart-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* --- Right sidebar: Invoice summary --- */
.pos-sidebar {
    position: sticky;
    top: 5rem;
}

.invoice-summary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
}

.invoice-summary h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.9rem;
}

.summary-row.total {
    border-top: 2px solid var(--accent);
    margin-top: 0.5rem;
    padding-top: 0.8rem;
    font-size: 1.2rem;
    font-weight: 700;
}

.summary-row .sr-label { color: var(--text-secondary); }
.summary-row .sr-value { font-weight: 600; }
.summary-row.total .sr-value { color: var(--accent); }

.btn-facturar {
    width: 100%;
    margin-top: 1.2rem;
    padding: 0.9rem;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--accent), #ff4500);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-facturar:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--accent-glow);
}

.btn-facturar:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.invoice-notes {
    width: 100%;
    margin-top: 0.8rem;
    padding: 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    resize: vertical;
    min-height: 60px;
}

.invoice-notes:focus {
    outline: none;
    border-color: var(--accent);
}

/* --- New customer modal --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    width: 450px;
    max-width: 95vw;
}

.modal-content h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.modal-field {
    margin-bottom: 0.8rem;
}

.modal-field label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.modal-field input {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.modal-field input:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* --- Toast (reuse from captura) --- */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 9999;
    animation: toastIn 0.3s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
