/**
 * COA & Batch Documents — frontend styles
 * Deliberately neutral: inherits the theme's font, uses grayscale rules
 * so it blends into any store (WoodMart, Storefront, block themes, etc).
 */

.coa-docs {
	--coa-border: rgba(0, 0, 0, 0.12);
	--coa-muted: rgba(0, 0, 0, 0.55);
	--coa-bg-soft: rgba(0, 0, 0, 0.03);
	font-size: 0.95em;
}

.coa-docs__intro {
	color: var(--coa-muted);
	margin-bottom: 1.25em;
	max-width: 60ch;
}

.coa-docs__empty {
	color: var(--coa-muted);
	border: 1px dashed var(--coa-border);
	padding: 1.5em;
	text-align: center;
	border-radius: 4px;
}

/* Filter bar (library shortcode): full-width searchable combobox */
.coa-library__filter {
	display: block;
	margin-bottom: 1.5em;
}

.coa-combo {
	position: relative;
	width: 100%;
}

.coa-combo__input {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid var(--coa-border);
	border-radius: 6px;
	padding: 0.75em 2.75em 0.75em 1em;
	background: #fff;
	font-size: 1em;
	line-height: 1.4;
}

.coa-combo__input:focus {
	outline: none;
	border-color: rgba(0, 0, 0, 0.35);
}

/* Chevron */
.coa-combo__icon {
	position: absolute;
	top: 50%;
	right: 1em;
	width: 8px;
	height: 8px;
	border-right: 1.5px solid var(--coa-muted);
	border-bottom: 1.5px solid var(--coa-muted);
	transform: translateY(-70%) rotate(45deg);
	pointer-events: none;
}

.coa-combo__list {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	z-index: 50;
	margin: 0;
	padding: 4px;
	list-style: none;
	background: #fff;
	border: 1px solid var(--coa-border);
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
	max-height: 280px;
	overflow-y: auto;
}

.coa-combo__option {
	padding: 0.6em 0.9em;
	border-radius: 4px;
	cursor: pointer;
	font-size: 0.95em;
	margin: 0;
	list-style: none;
}

.coa-combo__option:hover {
	background: var(--coa-bg-soft);
}

.coa-combo__option[data-id=""] {
	color: var(--coa-muted);
	border-bottom: 1px solid var(--coa-border);
	border-radius: 0;
	margin-bottom: 4px;
}

/* -------------------------------------------------------------------------
 * Card grid (default layout)
 * 4 per row on desktop. Simple: document image, batch/lot chip in
 * the top-right corner, title bar at the bottom.
 * ---------------------------------------------------------------------- */

.coa-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 24px;
}

@media (max-width: 1024px) {
	.coa-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 768px) {
	.coa-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 16px;
	}
}

@media (max-width: 420px) {
	.coa-grid {
		grid-template-columns: 1fr;
	}
}

.coa-card {
	border: 1px solid var(--coa-border);
	border-radius: 6px;
	overflow: hidden;
	background: #fff;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.coa-card:hover {
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
	transform: translateY(-2px);
}

/* Portrait media area, sized for document pages */
.coa-card__media {
	position: relative;
	display: flex;
	flex-direction: column;
	aspect-ratio: 3 / 4;
	background: #fff;
	overflow: hidden;
	text-decoration: none;
}

.coa-card__media img,
.coa-card__img {
	width: 100%;
	flex: 1;
	min-height: 0;
	object-fit: cover;
	object-position: top;
	display: block;
}

/* Placeholder when no thumbnail exists (e.g. PDF without Imagick) */
.coa-card__placeholder {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--coa-bg-soft);
}

.coa-card__ext {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 1.1em;
	font-weight: 700;
	letter-spacing: 0.15em;
	color: rgba(0, 0, 0, 0.35);
	border: 2px solid rgba(0, 0, 0, 0.15);
	border-radius: 6px;
	padding: 0.5em 0.9em;
}

/* Batch/lot chip, top-right corner */
.coa-card__lot {
	position: absolute;
	top: 10px;
	right: 10px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.72em;
	font-weight: 600;
	letter-spacing: 0.03em;
	color: #fff;
	background: rgba(20, 20, 20, 0.78);
	backdrop-filter: blur(4px);
	border-radius: 4px;
	padding: 0.35em 0.65em;
	max-width: 70%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Title bar at the bottom of the card */
.coa-card__title {
	display: block;
	background: #141414;
	color: #fff;
	font-size: 0.95em;
	font-weight: 600;
	line-height: 1.3;
	text-align: center;
	padding: 0.85em 0.75em;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Table (alternate layout via [coa_library layout="table"]) */
table.coa-table {
	width: 100%;
	border-collapse: collapse;
	border: 1px solid var(--coa-border);
	margin: 0;
}

.coa-table thead th {
	font-size: 0.75em;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	font-weight: 600;
	color: var(--coa-muted);
	text-align: left;
	padding: 0.9em 1em;
	background: var(--coa-bg-soft);
	border-bottom: 1px solid var(--coa-border);
}

.coa-table tbody td {
	padding: 0.9em 1em;
	border-bottom: 1px solid var(--coa-border);
	vertical-align: middle;
}

.coa-table tbody tr:last-child td {
	border-bottom: none;
}

.coa-table tbody tr:hover td {
	background: var(--coa-bg-soft);
}

/* Lot number: monospace, reads like a lab record */
.coa-lot {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9em;
	background: var(--coa-bg-soft);
	border: 1px solid var(--coa-border);
	border-radius: 3px;
	padding: 0.15em 0.5em;
	white-space: nowrap;
}

/* Document type badges: outlined, quiet */
.coa-badge {
	display: inline-block;
	font-size: 0.7em;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	border: 1px solid var(--coa-border);
	border-radius: 3px;
	padding: 0.25em 0.6em;
	color: var(--coa-muted);
	white-space: nowrap;
}

.coa-badge--coa {
	border-color: rgba(16, 92, 60, 0.35);
	color: rgb(16, 92, 60);
}

.coa-badge--sds {
	border-color: rgba(140, 90, 20, 0.35);
	color: rgb(140, 90, 20);
}

/* View link */
a.coa-download {
	font-size: 0.85em;
	font-weight: 600;
	text-decoration: none;
	border: 1px solid var(--coa-border);
	border-radius: 4px;
	padding: 0.4em 0.9em;
	white-space: nowrap;
	transition: background 0.15s ease;
}

a.coa-download:hover {
	background: var(--coa-bg-soft);
}

.coa-table__action {
	text-align: right;
	width: 1%;
}

/* Mobile: stack rows into cards */
@media (max-width: 640px) {
	.coa-table thead {
		display: none;
	}
	.coa-table,
	.coa-table tbody,
	.coa-table tr,
	.coa-table td {
		display: block;
		width: 100%;
	}
	.coa-table tr {
		border-bottom: 1px solid var(--coa-border);
		padding: 0.5em 0;
	}
	.coa-table tbody td {
		border: none;
		padding: 0.35em 1em;
	}
	.coa-table tbody td[data-label]::before {
		content: attr(data-label);
		display: block;
		font-size: 0.7em;
		text-transform: uppercase;
		letter-spacing: 0.08em;
		color: var(--coa-muted);
		margin-bottom: 0.15em;
	}
	.coa-table__action {
		text-align: left;
	}
}
