/* LA110 PO — frontend */

.la110-po-list-wrap {
	overflow-x: auto;
	margin-bottom: 1.5rem;
}

.la110-po-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.95rem;
}

.la110-po-table th,
.la110-po-table td {
	border: 1px solid #c3c4c7;
	padding: 0.5rem 0.65rem;
	text-align: left;
	vertical-align: top;
}

.la110-po-table thead th {
	background: #f6f7f7;
	font-weight: 600;
}

.la110-po-modal-root {
	margin: 1rem 0;
}

.la110-po-modal[hidden] {
	display: none !important;
}

body.la110-po-modal-open {
	overflow: hidden;
}

.la110-po-modal {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: max(
			1rem,
			var(--la110-po-modal-offset, 0px),
			calc(var(--wp-admin--admin-bar--height, 0px) + 1rem)
		)
		1rem 1rem;
	box-sizing: border-box;
	isolation: isolate;
}

.la110-po-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
}

.la110-po-modal__panel {
	position: relative;
	z-index: 1;
	background: #fff;
	max-width: 980px;
	width: 100%;
	max-height: calc(100dvh - var(--la110-po-modal-offset, 0px) - 2rem);
	overflow: auto;
	-webkit-overflow-scrolling: touch;
	padding: 1.25rem 1.5rem;
	border-radius: 4px;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.la110-po-modal__panel h2 {
	margin: 0 2.25rem 1rem 0;
	padding: 0;
	font-size: 1.35rem;
	line-height: 1.3;
}

.la110-po-modal__close {
	position: absolute;
	top: 0.5rem;
	right: 0.65rem;
	border: 0;
	background: transparent;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
	color: #50575e;
}

.la110-po-modal__close:hover {
	color: #1d2327;
}

.la110-po-modal__message {
	padding: 0.5rem 0.75rem;
	border-radius: 3px;
	margin-bottom: 0.75rem;
}

.la110-po-modal__message.is-error {
	background: #fcf0f1;
	color: #8a2424;
}

.la110-po-modal__message.is-ok {
	background: #edfaef;
	color: #1e4620;
}

.la110-po-form label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.25rem;
}

.la110-po-form select,
.la110-po-form input[type="date"],
.la110-po-form input[type="text"],
.la110-po-form input[type="number"],
.la110-po-form textarea {
	max-width: 100%;
	width: 100%;
	box-sizing: border-box;
}

.la110-po-lines {
	width: 100%;
	border-collapse: collapse;
	margin: 0.5rem 0 1rem;
	font-size: 0.9rem;
}

.la110-po-lines th,
.la110-po-lines td {
	border: 1px solid #dcdcde;
	padding: 0.35rem 0.4rem;
}

.la110-po-lines th:last-child,
.la110-po-lines td:last-child {
	width: 1%;
	white-space: nowrap;
}

.la110-po-lines thead th {
	background: #f6f7f7;
}

.la110-po-lines td button.la110-po-remove-line {
	appearance: none !important;
	-webkit-appearance: none !important;
	display: inline-block !important;
	border: 1px solid #c05555 !important;
	border-radius: 3px !important;
	background: #d46464 !important;
	background-color: #d46464 !important;
	background-image: none !important;
	color: #ffffff !important;
	font-size: 0.85rem !important;
	line-height: 1.4 !important;
	padding: 0.2rem 0.5rem !important;
	margin: 0 !important;
	cursor: pointer !important;
	vertical-align: middle !important;
	white-space: nowrap !important;
	min-width: 6.5rem !important;
	text-decoration: none !important;
	box-shadow: none !important;
}

.la110-po-lines td button.la110-po-remove-line:hover {
	background: #c05555 !important;
	background-color: #c05555 !important;
	background-image: none !important;
	border-color: #af4949 !important;
}

.la110-po-lines td button.la110-po-remove-line:focus-visible {
	outline: 2px solid #2271b1 !important;
	outline-offset: 1px !important;
}

.la110-po-lines-fieldset {
	border: 1px solid #dcdcde;
	padding: 0.75rem 1rem 1rem;
	margin: 1rem 0;
}

.la110-po-open-modal {
	margin-bottom: 0.5rem;
}

.la110-po-table td.la110-po-actions button.la110-po-edit,
.la110-po-table td.la110-po-actions button.la110-po-delete,
.la110-po-table td.la110-po-actions button.la110-po-approve {
	appearance: none !important;
	-webkit-appearance: none !important;
	display: inline-block !important;
	border: 1px solid #8c8f94 !important;
	border-radius: 3px !important;
	background: #f6f7f7 !important;
	color: #2c3338 !important;
	font-size: 0.85rem !important;
	line-height: 1.4 !important;
	padding: 0.2rem 0.5rem !important;
	margin: 0 !important;
	cursor: pointer !important;
	vertical-align: middle !important;
	text-decoration: none !important;
	box-shadow: none !important;
}

.la110-po-table td.la110-po-actions button.la110-po-edit:hover,
.la110-po-table td.la110-po-actions button.la110-po-delete:hover,
.la110-po-table td.la110-po-actions button.la110-po-approve:hover {
	background: #f0f0f1 !important;
	border-color: #787c82 !important;
}

.la110-po-table td.la110-po-actions button.la110-po-edit:focus-visible,
.la110-po-table td.la110-po-actions button.la110-po-delete:focus-visible,
.la110-po-table td.la110-po-actions button.la110-po-approve:focus-visible {
	outline: 2px solid #2271b1 !important;
	outline-offset: 1px !important;
}

.la110-po-table td.la110-po-actions button.la110-po-delete {
	background: #d46464 !important;
	background-color: #d46464 !important;
	background-image: none !important;
	border-color: #c05555 !important;
	color: #ffffff !important;
}

.la110-po-table td.la110-po-actions button.la110-po-delete:hover {
	background: #c05555 !important;
	background-color: #c05555 !important;
	background-image: none !important;
	border-color: #af4949 !important;
}

.la110-po-table td.la110-po-actions button.la110-po-approve {
	background: #719456 !important;
	background-color: #719456 !important;
	background-image: none !important;
	border-color: #5f7f48 !important;
	color: #ffffff !important;
}

.la110-po-table td.la110-po-actions button.la110-po-approve:hover {
	background: #5f7f48 !important;
	background-color: #5f7f48 !important;
	background-image: none !important;
	border-color: #4f6b3b !important;
}

/* Klickbart PO-nummer / utkast → detaljpopup */
.la110-po-table td.la110-po-num-cell {
	position: relative;
	z-index: 1;
}

a.la110-po-show-lines {
	display: inline-block;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	font-weight: inherit;
	color: #2271b1;
	text-decoration: underline;
	text-align: left;
	cursor: pointer;
	pointer-events: auto;
	max-width: 100%;
	word-break: break-word;
}

a.la110-po-show-lines:hover,
a.la110-po-show-lines:focus {
	color: #135e96;
	outline: none;
}

a.la110-po-show-lines:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* Läs-popup: orderrader */
.la110-po-detail-modal[hidden]:not(.is-open) {
	display: none !important;
}

.la110-po-detail-modal {
	position: fixed;
	inset: 0;
	z-index: 100001;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	box-sizing: border-box;
}

.la110-po-detail-modal.is-open {
	display: flex !important;
}

.la110-po-detail-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
}

.la110-po-detail-modal__panel {
	position: relative;
	z-index: 1;
	background: #fff;
	max-width: 640px;
	width: 100%;
	max-height: 90vh;
	overflow: auto;
	padding: 1.25rem 1.5rem;
	border-radius: 4px;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.la110-po-detail-modal__title {
	margin: 0 2rem 0.75rem 0;
	padding: 0;
	font-size: 1.25rem;
}

.la110-po-detail-modal__close {
	position: absolute;
	top: 0.5rem;
	right: 0.65rem;
	border: 0;
	background: transparent;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
	color: #50575e;
}

.la110-po-detail-modal__close:hover {
	color: #1d2327;
}

.la110-po-detail-supplier {
	margin: 0 0 1rem;
	color: #50575e;
}

.la110-po-detail-supplier:empty {
	display: none;
}

.la110-po-detail-loading {
	margin: 0 0 0.5rem;
}

.la110-po-detail-error {
	margin: 0 0 0.5rem;
	color: #8a2424;
}

.la110-po-detail-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9rem;
}

.la110-po-detail-table th,
.la110-po-detail-table td {
	border: 1px solid #dcdcde;
	padding: 0.4rem 0.5rem;
	text-align: left;
	vertical-align: top;
}

.la110-po-detail-table thead th {
	background: #f6f7f7;
	font-weight: 600;
}

.la110-po-detail-th-article {
	min-width: 40%;
}

.la110-po-detail-total-row {
	margin: 1rem 0 0;
}

/* Mobil: popup för ny/redigera PO — full höjd under toppraden */
@media (max-width: 782px) {
	.la110-po-modal {
		padding: 0;
		align-items: stretch;
	}

	.la110-po-modal__panel {
		max-width: none;
		width: 100%;
		min-height: 100dvh;
		max-height: none;
		margin: 0;
		border-radius: 0;
		box-shadow: none;
		padding:
			calc(var(--la110-po-modal-offset, 0px) + max(0.75rem, env(safe-area-inset-top, 0px)))
			max(1rem, env(safe-area-inset-right, 0px))
			max(1.25rem, env(safe-area-inset-bottom, 0px))
			max(1rem, env(safe-area-inset-left, 0px));
	}

	.la110-po-modal__close {
		top: max(0.35rem, env(safe-area-inset-top, 0px));
		right: max(0.65rem, env(safe-area-inset-right, 0px));
		width: 2.75rem;
		height: 2.75rem;
		font-size: 2rem;
		line-height: 2.75rem;
		text-align: center;
		z-index: 2;
	}

	.la110-po-form select,
	.la110-po-form input[type="date"],
	.la110-po-form input[type="text"],
	.la110-po-form input[type="number"],
	.la110-po-form textarea {
		font-size: 16px;
	}

	.la110-po-lines-fieldset {
		padding: 0.75rem 0.85rem 1rem;
	}

	.la110-po-lines--cards-mobile {
		border: 0;
	}

	.la110-po-lines--cards-mobile thead {
		display: none;
	}

	.la110-po-lines--cards-mobile tbody tr.la110-po-line {
		display: block;
		margin-bottom: 0.85rem;
		border: 1px solid #dcdcde;
		border-radius: 6px;
		padding: 0.65rem 0.75rem;
		background: #fafafa;
	}

	.la110-po-lines--cards-mobile tbody tr.la110-po-line:last-child {
		margin-bottom: 0;
	}

	.la110-po-lines--cards-mobile tbody td {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 0.65rem;
		border: 0;
		padding: 0.35rem 0;
	}

	.la110-po-lines--cards-mobile tbody td::before {
		content: attr(data-label);
		font-weight: 600;
		color: #50575e;
		flex: 0 0 38%;
		font-size: 0.85rem;
	}

	.la110-po-lines--cards-mobile tbody td input {
		flex: 1 1 auto;
		min-width: 0;
	}

	.la110-po-lines--cards-mobile tbody td.la110-line-total {
		font-weight: 600;
	}

	.la110-po-lines--cards-mobile tbody td:last-child {
		padding-top: 0.5rem;
		margin-top: 0.25rem;
		border-top: 1px solid #dcdcde;
	}

	.la110-po-lines--cards-mobile tbody td:last-child::before {
		display: none;
	}

	.la110-po-lines--cards-mobile tbody td:last-child button {
		width: 100%;
		min-height: 2.5rem;
	}
}

/* Mobil: visa listan som kort i stället för horisontell tabell */
@media (max-width: 782px) {
	.la110-po-list-wrap {
		overflow-x: visible;
	}

	.la110-po-table--cards-mobile {
		border: 0;
	}

	.la110-po-table--cards-mobile thead {
		display: none;
	}

	.la110-po-table--cards-mobile tbody tr {
		display: block;
		margin-bottom: 1rem;
		border: 1px solid #c3c4c7;
		border-radius: 6px;
		padding: 0.85rem 1rem;
		background: #fff;
		box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
	}

	.la110-po-table--cards-mobile tbody tr:last-child {
		margin-bottom: 0;
	}

	.la110-po-table--cards-mobile tbody td {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		gap: 0.75rem;
		border: 0;
		padding: 0.4rem 0;
		text-align: right;
	}

	.la110-po-table--cards-mobile tbody td::before {
		content: attr(data-label);
		font-weight: 600;
		color: #50575e;
		text-align: left;
		flex: 0 0 42%;
	}

	.la110-po-table--cards-mobile tbody td.la110-po-table__empty {
		display: block;
		text-align: center;
		padding: 0.5rem 0;
	}

	.la110-po-table--cards-mobile tbody td.la110-po-table__empty::before {
		display: none;
	}

	.la110-po-table--cards-mobile tbody td.la110-po-num-cell {
		display: block;
		padding: 0 0 0.6rem;
		margin-bottom: 0.35rem;
		border-bottom: 1px solid #dcdcde;
		text-align: left;
		font-size: 1.05rem;
	}

	.la110-po-table--cards-mobile tbody td.la110-po-num-cell::before {
		display: none;
	}

	.la110-po-table--cards-mobile tbody td.la110-po-actions {
		flex-wrap: wrap;
		justify-content: flex-start;
		padding-top: 0.65rem;
		margin-top: 0.35rem;
		border-top: 1px solid #dcdcde;
		text-align: left;
	}

	.la110-po-table--cards-mobile tbody td.la110-po-actions::before {
		flex: 0 0 100%;
		margin-bottom: 0.15rem;
	}

	.la110-po-table--cards-mobile tbody td.la110-po-actions button {
		flex: 1 1 auto;
		min-width: 5.5rem;
	}
}
