/*
 * Buchhandlung Stock — catalog front-end styles
 *
 * Consumes the sibling buchhandlung-books plugin's brand tokens (--bh-*)
 * with safe fallbacks so the catalog is usable on any theme.
 */

.bhs-catalog {
	--bhs-bg:           var(--bh-cream, #faf7f2);
	--bhs-bg-card:      var(--bh-warm-white, #fffdf9);
	--bhs-text:         var(--bh-ink, #1a1a2e);
	--bhs-text-muted:   var(--bh-ink-light, #3d3d5c);
	--bhs-brand:        var(--bh-primary, #202684);
	--bhs-accent:       var(--bh-secondary, #f78da7);
	--bhs-rule:         var(--bh-rule, rgba(32,38,132,0.15));
	--bhs-shadow:       0 4px 12px rgba(0,0,0,0.14);
	--bhs-radius:       6px;

	font-family: var(--bh-font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);
	color: var(--bhs-text);
	background: var(--bhs-bg);
	padding: 1.5rem;
	border-radius: var(--bhs-radius);
	max-width: 980px;
	margin: 0 auto;
	position: relative;
}

.bhs-catalog *,
.bhs-catalog *::before,
.bhs-catalog *::after { box-sizing: border-box; }

/* ── Toolbar ─────────────────────────────────────────────────────────────── */

.bhs-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1rem;
}

.bhs-shipping-note {
	margin: 0;
	font-size: 0.9rem;
	color: var(--bhs-text-muted);
}

.bhs-toolbar-actions {
	display: flex;
	gap: 0.5rem;
	margin-left: auto;
}

.bhs-catalog .bhs-basket-toggle {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	background: var(--bhs-bg-card);
	color: var(--bhs-text);
	border: 1px solid var(--bhs-rule);
	border-radius: var(--bhs-radius);
	padding: 0.45rem 0.7rem;
	cursor: pointer;
	font: inherit;
}

.bhs-catalog .bhs-basket-toggle:hover { border-color: var(--bhs-brand); }
.bhs-catalog .bhs-basket-toggle .bhs-icon { width: 20px; height: 20px; }

.bhs-basket-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.4em;
	height: 1.4em;
	padding: 0 0.4em;
	background: var(--bhs-brand);
	color: #fff;
	border-radius: 999px;
	font-size: 0.78rem;
	font-weight: 600;
}

/* ── Search ──────────────────────────────────────────────────────────────── */

.bhs-catalog .bhs-search {
	position: relative;
	margin-bottom: 1rem;
}

.bhs-catalog .bhs-search-icon {
	position: absolute;
	left: 14px;
	top: 50%;
	width: 18px;
	height: 18px;
	transform: translateY(-50%);
	color: var(--bhs-text-muted);
	pointer-events: none;
	display: flex;
	align-items: center;
	justify-content: center;
}

.bhs-catalog .bhs-search-icon svg {
	width: 18px;
	height: 18px;
	display: block;
}

.bhs-catalog .bhs-search-input {
	width: 100%;
	padding: 0.6rem 0.9rem 0.6rem 44px;
	background: var(--bhs-bg-card);
	color: var(--bhs-text);
	border: 1px solid var(--bhs-rule);
	border-radius: var(--bhs-radius);
	font: inherit;
}

.bhs-catalog .bhs-search-input:focus {
	outline: none;
	border-color: var(--bhs-brand);
	box-shadow: 0 0 0 3px rgba(32,38,132,0.18);
}

/* ── Navigation dropdown ─────────────────────────────────────────────────── */

.bhs-catalog .bhs-nav {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin-bottom: 0.75rem;
}

.bhs-catalog .bhs-nav-label {
	font-size: 0.85rem;
	color: var(--bhs-text-muted);
	font-weight: 500;
	flex-shrink: 0;
}

.bhs-catalog .bhs-nav-select {
	flex: 1;
	max-width: 320px;
	padding: 0.5rem 2rem 0.5rem 0.9rem;
	background: var(--bhs-bg-card);
	color: var(--bhs-text);
	border: 1px solid var(--bhs-rule);
	border-radius: var(--bhs-radius);
	font: inherit;
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233d3d5c'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.4rem center;
	background-size: 18px 18px;
	cursor: pointer;
}

.bhs-catalog .bhs-nav-select:focus {
	outline: none;
	border-color: var(--bhs-brand);
	box-shadow: 0 0 0 3px rgba(32,38,132,0.18);
}

/* ── Status + load-more ──────────────────────────────────────────────────── */

.bhs-status,
.bhs-load-more {
	margin: 0.5rem 0 1rem;
	color: var(--bhs-text-muted);
	font-size: 0.9rem;
	text-align: center;
}

.bhs-status[data-state="loading"] { font-style: italic; }
.bhs-status[data-state="error"]   { color: #b32d2e; }
.bhs-status[data-state="stale"]   { color: #b85c00; }

/* ── Results list ────────────────────────────────────────────────────────── */

.bhs-results {
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.75rem;
}

.bhs-item {
	margin: 0;
	padding: 1rem 1.1rem;
	background: var(--bhs-bg-card);
	border: 1px solid var(--bhs-rule);
	border-radius: var(--bhs-radius);
	cursor: pointer;
	transition: border-color 0.15s ease, transform 0.15s ease;
	position: relative;
}

.bhs-item:hover { border-color: var(--bhs-brand); }
.bhs-item:focus-visible {
	outline: 2px solid var(--bhs-brand);
	outline-offset: 2px;
}

.bhs-item[data-in-basket="true"] {
	border-color: var(--bhs-brand);
	background: linear-gradient(0deg, rgba(32,38,132,0.04), rgba(32,38,132,0.04)), var(--bhs-bg-card);
}

.bhs-item-title {
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	color: var(--bhs-text);
	display: flex;
	gap: 0.5rem;
	align-items: flex-start;
}

.bhs-item-cover {
	float: right;
	width: auto;
	max-width: 72px;
	max-height: 108px;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: var(--bhs-shadow);
	margin: -0.5rem 0 0.25rem 0.75rem;
}

.bhs-item-favorite {
	display: inline-block;
	width: 1em;
	height: 1em;
	margin-right: 0.25rem;
	color: var(--bhs-accent);
	flex-shrink: 0;
}

.bhs-item-basket-flag {
	color: var(--bhs-brand);
	flex-shrink: 0;
	margin-right: 0.25rem;
}

.bhs-item-author {
	font-weight: 400;
	color: var(--bhs-text-muted);
}

.bhs-item-meta {
	margin: 0.4rem 0 0;
	font-size: 0.88rem;
	color: var(--bhs-text-muted);
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
}

.bhs-item-meta .bhs-label {
	color: var(--bhs-brand);
	font-weight: 600;
	margin-right: 0.25rem;
}

.bhs-item-isbn { font-size: 0.92em; }

/* ── Modal ───────────────────────────────────────────────────────────────── */

.bhs-modal {
	position: fixed;
	inset: 0;
	z-index: 1010;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.bhs-modal[hidden] { display: none; }

.bhs-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,0.45);
}

.bhs-modal-panel {
	position: relative;
	background: var(--bhs-bg-card);
	color: var(--bhs-text);
	border-radius: var(--bhs-radius);
	box-shadow: var(--bhs-shadow);
	width: 100%;
	max-width: 560px;
	max-height: calc(100vh - 2rem);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.bhs-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.9rem 1.1rem;
	border-bottom: 1px solid var(--bhs-rule);
}

.bhs-modal-title { margin: 0; font-size: 1.05rem; font-weight: 600; }

.bhs-modal-close {
	background: transparent;
	border: 0;
	color: inherit;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	padding: 0 0.25rem;
}

.bhs-modal-body {
	padding: 1rem 1.1rem;
	overflow-y: auto;
}

.bhs-modal-body .bhs-empty {
	text-align: center;
	color: var(--bhs-text-muted);
	padding: 1rem 0;
}

.bhs-modal-body ul {
	list-style: none;
	padding: 0;
	margin: 0 0 1rem;
}

.bhs-modal-body li {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.45rem 0;
	border-bottom: 1px solid var(--bhs-rule);
}

.bhs-modal-body li:last-child { border-bottom: 0; }

.bhs-modal-body .bhs-line-meta {
	color: var(--bhs-text-muted);
	font-size: 0.85rem;
}

.bhs-modal-body .bhs-remove-line {
	background: transparent;
	border: 0;
	color: #b32d2e;
	cursor: pointer;
	padding: 0 0.25rem;
	font-size: 1.1rem;
}

.bhs-modal-fieldset {
	border: 0;
	padding: 0;
	margin: 1rem 0;
}

.bhs-modal-fieldset legend {
	font-weight: 600;
	margin-bottom: 0.35rem;
}

.bhs-modal-fieldset label {
	display: flex;
	gap: 0.4rem;
	align-items: center;
	margin: 0.2rem 0;
}

.bhs-modal-fieldset textarea {
	width: 100%;
	min-height: 60px;
	padding: 0.5rem;
	background: var(--bhs-bg);
	color: var(--bhs-text);
	border: 1px solid var(--bhs-rule);
	border-radius: var(--bhs-radius);
	font: inherit;
	margin-top: 0.4rem;
}

.bhs-modal-total {
	display: flex;
	justify-content: space-between;
	font-weight: 600;
	margin: 0.5rem 0 1rem;
}

.bhs-modal-actions {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	justify-content: flex-end;
}

.bhs-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	background: var(--bhs-brand);
	color: #fff;
	border: 0;
	border-radius: var(--bhs-radius);
	padding: 0.5rem 0.9rem;
	cursor: pointer;
	font: inherit;
}

.bhs-btn:hover { filter: brightness(1.05); }

.bhs-btn-secondary {
	background: transparent;
	color: var(--bhs-text);
	border: 1px solid var(--bhs-rule);
}

.bhs-btn-danger {
	background: transparent;
	color: #b32d2e;
	border: 1px solid #d63638;
}

.bhs-btn-primary { background: var(--bhs-brand); color: #fff; }
.bhs-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	filter: none;
}

/* ── Customer form ─────────────────────────────────────────────────────── */

.bhs-customer-fields .bhs-field {
	display: block;
	margin: 0.5rem 0 0.75rem;
}

.bhs-customer-fields .bhs-field label {
	display: block;
	font-weight: 600;
	font-size: 0.9rem;
	margin-bottom: 0.25rem;
}

.bhs-customer-fields .bhs-field input,
.bhs-customer-fields .bhs-field textarea {
	width: 100%;
	padding: 0.5rem 0.65rem;
	background: var(--bhs-bg);
	color: var(--bhs-text);
	border: 1px solid var(--bhs-rule);
	border-radius: var(--bhs-radius);
	font: inherit;
}

.bhs-customer-fields .bhs-field textarea {
	min-height: 64px;
	resize: vertical;
}

.bhs-customer-fields .bhs-field input:focus,
.bhs-customer-fields .bhs-field textarea:focus {
	outline: none;
	border-color: var(--bhs-brand);
	box-shadow: 0 0 0 3px rgba(32,38,132,0.18);
}

.bhs-customer-fields [aria-invalid="true"] {
	border-color: #d63638;
}

.bhs-consent-label {
	display: flex !important;
	gap: 0.5rem;
	align-items: flex-start;
	font-size: 0.9rem;
	line-height: 1.4;
	margin-top: 0.5rem;
}

.bhs-consent-label input[type="checkbox"] {
	margin-top: 0.25rem;
	flex-shrink: 0;
}

.bhs-form-error {
	margin: 0.25rem 0 0;
	color: #b32d2e;
	font-size: 0.85rem;
}

.bhs-form-error--global {
	background: rgba(214, 54, 56, 0.08);
	border: 1px solid rgba(214, 54, 56, 0.35);
	border-radius: var(--bhs-radius);
	padding: 0.55rem 0.75rem;
	margin: 0.75rem 0;
}

/* ── Success screen ────────────────────────────────────────────────────── */

.bhs-success {
	text-align: center;
	padding: 1.5rem 0.5rem 0.5rem;
}

.bhs-success-icon {
	color: var(--bhs-brand);
	margin-bottom: 0.5rem;
}

.bhs-success h3 {
	margin: 0 0 0.5rem;
	font-size: 1.15rem;
}

.bhs-success p {
	margin: 0.35rem 0;
	color: var(--bhs-text);
}

.bhs-success .bhs-line-meta {
	color: var(--bhs-text-muted);
}

.bhs-success .bhs-modal-actions {
	justify-content: center;
	margin-top: 1.25rem;
}

.bhs-toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	background: rgba(0,0,0,0.85);
	color: #fff;
	padding: 0.55rem 1rem;
	border-radius: var(--bhs-radius);
	z-index: 1100;
	font-size: 0.92rem;
	pointer-events: none;
	opacity: 1;
	transition: opacity 0.3s ease;
}

.bhs-toast[data-state="hide"] { opacity: 0; }
