/**
 * LancerBill Tools - invoice / quote / receipt builders and printable documents.
 */

/* ---- line item editor ---- */
.lb-items-head,
.lb-item-row {
	display: grid;
	grid-template-columns: 1fr 90px 120px 110px 40px;
	gap: 0.5rem;
	align-items: end;
}

.lb-items-head {
	font-weight: 700;
	font-size: 0.85rem;
	color: #475569;
	padding-bottom: 0.35rem;
}

.lb-item-row {
	margin-bottom: 0.5rem;
}

.lb-item-remove {
	padding: 0.8rem 0;
	background: transparent;
	border: 0;
	color: #dc2626;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
	border-radius: 0.4rem;
	min-width: 2.75rem;
}

.lb-item-remove:hover {
	background: #fef2f2;
}

.lb-item-remove:focus-visible {
	outline: 2px solid #2563eb;
	outline-offset: 2px;
}

.lb-add-item {
	margin-top: 0.25rem;
}

@media (max-width: 600px) {
	.lb-items-head {
		display: none;
	}
	.lb-item-row {
		grid-template-columns: 1fr 1fr;
		grid-template-areas:
			"desc desc"
			"qty rate"
			"amount remove";
		border: 1px solid #e2e8f0;
		border-radius: 0.6rem;
		padding: 0.75rem;
		background: #f8fafc;
	}
	.lb-item-desc { grid-area: desc; }
	.lb-item-qty { grid-area: qty; }
	.lb-item-rate { grid-area: rate; }
	.lb-item-amount { grid-area: amount; align-self: center; font-weight: 700; }
	.lb-item-remove { grid-area: remove; justify-self: end; }
}

/* ---- document preview ---- */
.lb-doc-preview {
	margin-top: 1.5rem;
	border: 1px solid #cbd5e1;
	border-radius: 0.5rem;
	background: #fff;
	color: #111;
	padding: 2rem;
	font-size: 0.95rem;
	overflow-x: auto; /* wide tables scroll inside the preview, never the page */
}

.lb-doc-preview h2 {
	margin: 0 0 0.25rem;
	font-size: 1.6rem;
	letter-spacing: 0.04em;
}

.lb-doc-top {
	display: flex;
	justify-content: space-between;
	gap: 1.5rem;
	flex-wrap: wrap;
	margin-bottom: 1.5rem;
}

.lb-doc-meta {
	text-align: right;
}

.lb-doc-meta table {
	margin-left: auto;
	border-collapse: collapse;
}

.lb-doc-meta td {
	padding: 0.15rem 0 0.15rem 1rem;
	vertical-align: top;
}

.lb-doc-meta td:first-child {
	color: #475569;
}

.lb-doc-parties {
	display: flex;
	justify-content: space-between;
	gap: 1.5rem;
	flex-wrap: wrap;
	margin-bottom: 1.5rem;
}

.lb-doc-party {
	min-width: 0;
	flex: 1 1 220px;
}

.lb-doc-party h4 {
	margin: 0 0 0.35rem;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #475569;
}

.lb-doc-party p {
	margin: 0;
	white-space: pre-line;
}

.lb-doc-table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 1.25rem;
}

.lb-doc-table th,
.lb-doc-table td {
	text-align: left;
	padding: 0.55rem 0.6rem;
	border-bottom: 1px solid #e2e8f0;
	vertical-align: top;
	overflow-wrap: anywhere; /* long unbroken strings (URLs) can't push the table wide */
}

.lb-doc-table th {
	background: #f1f5f9;
	font-size: 0.82rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.lb-doc-table td.num,
.lb-doc-table th.num {
	text-align: right;
	white-space: nowrap;
}

.lb-doc-totals {
	margin-left: auto;
	width: 100%;
	max-width: 320px;
	border-collapse: collapse;
}

.lb-doc-totals td {
	padding: 0.35rem 0.2rem;
}

.lb-doc-totals td:last-child {
	text-align: right;
	white-space: nowrap;
	font-weight: 600;
}

.lb-doc-totals tr.grand td {
	font-size: 1.2rem;
	border-top: 2px solid #111;
	color: #15803d;
}

.lb-doc-notes {
	margin-top: 1.25rem;
	font-size: 0.9rem;
}

.lb-doc-notes h4 {
	margin: 0 0 0.3rem;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #475569;
}

.lb-doc-notes p {
	margin: 0;
	white-space: pre-line;
}

.lb-doc-footer {
	margin-top: 2rem;
	padding-top: 0.75rem;
	border-top: 1px solid #e2e8f0;
	font-size: 0.8rem;
	color: #64748b;
	text-align: center;
}

@media (max-width: 480px) {
	.lb-doc-preview {
		padding: 1.1rem;
	}
	.lb-doc-meta {
		text-align: left;
	}
	.lb-doc-meta table {
		margin-left: 0;
	}
}

/* ---- print: only the document prints ---- */
.lb-print-root {
	display: none;
}

@media print {
	body.lb-printing > *:not(.lb-print-root) {
		display: none !important;
	}
	body.lb-printing > .lb-print-root {
		display: block !important;
	}
	.lb-print-root .lb-doc-preview {
		border: 0;
		margin: 0;
		padding: 0;
	}
}
