/* Library Book Manager — shadcn/zinc theme ported from the reference design. */

.lbm-wrap {
	--lbm-bg: hsl(0 0% 100%);
	--lbm-fg: hsl(240 10% 3.9%);
	--lbm-primary: hsl(240 5.9% 10%);
	--lbm-primary-fg: hsl(0 0% 98%);
	--lbm-muted: hsl(240 4.8% 95.9%);
	--lbm-muted-fg: hsl(240 3.8% 46.1%);
	--lbm-border: hsl(240 5.9% 90%);
	--lbm-ring: hsl(240 5.9% 10%);
	--lbm-destructive: hsl(0 84.2% 60.2%);
	--lbm-radius: 10px;

	max-width: 1600px;
	margin: 0 auto;
	padding: 24px 16px 64px;
	color: var(--lbm-fg);
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

.lbm-header h1 {
	font-size: 26px;
	font-weight: 700;
	margin: 0 0 20px;
	letter-spacing: -0.01em;
}

.lbm-card {
	background: var(--lbm-bg);
	border: 1px solid var(--lbm-border);
	border-radius: var(--lbm-radius);
	padding: 24px;
	margin-bottom: 24px;
	box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}

.lbm-card-title {
	font-size: 18px;
	font-weight: 600;
	margin: 0 0 20px;
}

/* --- Form grid --- */
.lbm-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 16px;
}

.lbm-field { display: flex; flex-direction: column; gap: 6px; position: relative; }

.lbm-field label {
	font-size: 13px;
	font-weight: 500;
	color: var(--lbm-fg);
}
.lbm-field .req { color: var(--lbm-destructive); }

.lbm-field input,
.lbm-field select {
	height: 38px;
	padding: 0 12px;
	border: 1px solid var(--lbm-border);
	border-radius: 8px;
	background: var(--lbm-bg);
	color: var(--lbm-fg);
	font-size: 14px;
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s;
	width: 100%;
	box-sizing: border-box;
}
.lbm-field input:focus,
.lbm-field select:focus {
	border-color: var(--lbm-ring);
	box-shadow: 0 0 0 3px rgb(0 0 0 / 0.08);
}
.lbm-field input:disabled,
.lbm-field select:disabled { background: var(--lbm-muted); cursor: not-allowed; }

/* --- Combobox --- */
.lbm-combo-list {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	z-index: 20;
	margin: 4px 0 0;
	padding: 4px;
	list-style: none;
	background: var(--lbm-bg);
	border: 1px solid var(--lbm-border);
	border-radius: 8px;
	box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
	max-height: 240px;
	overflow-y: auto;
}
.lbm-combo-list li {
	padding: 8px 10px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
}
.lbm-combo-list li:hover,
.lbm-combo-list li.is-active { background: var(--lbm-muted); }
.lbm-combo-list .lbm-combo-add { color: var(--lbm-muted-fg); border-top: 1px solid var(--lbm-border); }
.lbm-combo-list .lbm-combo-add strong { color: var(--lbm-fg); font-style: normal; }

/* "New term will be created" hint on the combobox */
.lbm-combo.is-new input[type="text"] {
	border-color: hsl(142 71% 45%);
	box-shadow: 0 0 0 3px hsl(142 71% 45% / 0.12);
}
.lbm-combo.is-new::after {
	content: "New — will be created on save";
	font-size: 11px;
	color: hsl(142 71% 32%);
	margin-top: 2px;
}

/* --- Toggle switch (Soft Copy) --- */
.lbm-switch {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	height: 38px;
	cursor: pointer;
	user-select: none;
}
.lbm-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.lbm-switch-track {
	position: relative;
	width: 46px;
	height: 26px;
	border-radius: 999px;
	background: var(--lbm-border);
	transition: background 0.18s ease;
	flex-shrink: 0;
}
.lbm-switch-thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
	transition: transform 0.18s ease;
}
.lbm-switch input:checked + .lbm-switch-track { background: var(--lbm-primary); }
.lbm-switch input:checked + .lbm-switch-track .lbm-switch-thumb { transform: translateX(20px); }
.lbm-switch input:focus-visible + .lbm-switch-track { box-shadow: 0 0 0 3px rgb(0 0 0 / 0.12); }
.lbm-switch-label { font-size: 14px; color: var(--lbm-fg); min-width: 26px; }

/* --- Buttons --- */
.lbm-form-actions { display: flex; align-items: center; gap: 12px; margin-top: 24px; }

.lbm-btn {
	height: 40px;
	padding: 0 18px;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	border: 1px solid transparent;
	transition: opacity 0.15s, background 0.15s;
}
.lbm-btn-primary { background: var(--lbm-primary); color: var(--lbm-primary-fg); }
.lbm-btn-primary:hover { opacity: 0.9; }
.lbm-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.lbm-btn-ghost { background: var(--lbm-bg); color: var(--lbm-fg); border-color: var(--lbm-border); }
.lbm-btn-ghost:hover { background: var(--lbm-muted); }

.lbm-form-msg { font-size: 13px; }
.lbm-form-msg.ok { color: hsl(142 71% 35%); }
.lbm-form-msg.err { color: var(--lbm-destructive); }

/* --- Table toolbar --- */
.lbm-table-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 16px;
}
.lbm-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.lbm-filter {
	height: 36px;
	padding: 0 10px;
	border: 1px solid var(--lbm-border);
	border-radius: 8px;
	background: var(--lbm-bg);
	font-size: 13px;
	color: var(--lbm-fg);
}

.lbm-table-scroll { overflow-x: auto; }

/* --- DataTables overrides to match theme --- */
table#lbm-table.dataTable { border-collapse: collapse !important; font-size: 13px; }
table#lbm-table thead th {
	background: var(--lbm-muted);
	color: var(--lbm-fg);
	font-weight: 600;
	white-space: nowrap;
	border-bottom: 1px solid var(--lbm-border);
}
table#lbm-table tbody td {
	border-bottom: 1px solid var(--lbm-border);
	white-space: nowrap;
	padding: 8px 10px;
}
table#lbm-table tbody tr:hover { background: var(--lbm-muted); }

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
	background: var(--lbm-primary) !important;
	color: var(--lbm-primary-fg) !important;
	border-radius: 6px;
	border: none !important;
}
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
	border: 1px solid var(--lbm-border);
	border-radius: 6px;
	padding: 4px 8px;
}

/* --- Row actions --- */
.lbm-col-actions { text-align: center; }
.lbm-actions { display: inline-flex; gap: 6px; }
.lbm-btn-icon {
	width: 30px;
	height: 30px;
	border: 1px solid var(--lbm-border);
	border-radius: 6px;
	background: var(--lbm-bg);
	cursor: pointer;
	font-size: 14px;
	line-height: 1;
}
.lbm-btn-icon:hover { background: var(--lbm-muted); }
.lbm-delete:hover { border-color: var(--lbm-destructive); }

.lbm-login-notice { padding: 40px; text-align: center; color: var(--lbm-muted-fg); }

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

/* ============================================================
   Theme hardening (Astra et al.)
   Scoped under #lbm-app so these win on specificity (id = 1,0,0)
   over theme element/class selectors, without touching the theme
   globally. Neutralizes the theme's button/input skin, then
   re-asserts ours.
   ============================================================ */

#lbm-app,
#lbm-app *,
#lbm-app *::before,
#lbm-app *::after { box-sizing: border-box; }

/* Buttons — strip the theme's button styling, restore ours */
#lbm-app button {
	font-family: inherit;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
	width: auto;
	min-height: 0;
	margin: 0;
}
#lbm-app .lbm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 40px;
	padding: 0 18px;
	border-radius: 8px;
	border: 1px solid transparent;
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transition: opacity 0.15s, background 0.15s;
}
#lbm-app .lbm-btn-primary,
#lbm-app .lbm-btn-primary:hover,
#lbm-app .lbm-btn-primary:focus,
#lbm-app .lbm-btn-primary:active {
	background: var(--lbm-primary);
	color: var(--lbm-primary-fg);
	border-color: var(--lbm-primary);
}
#lbm-app .lbm-btn-primary:hover { opacity: 0.9; }
#lbm-app .lbm-btn-primary:disabled { opacity: 0.5; }
#lbm-app .lbm-btn-ghost,
#lbm-app .lbm-btn-ghost:focus,
#lbm-app .lbm-btn-ghost:active {
	background: var(--lbm-bg);
	color: var(--lbm-fg);
	border-color: var(--lbm-border);
}
#lbm-app .lbm-btn-ghost:hover { background: var(--lbm-muted); color: var(--lbm-fg); }

#lbm-app .lbm-btn-icon {
	width: 30px;
	height: 30px;
	min-height: 0;
	padding: 0;
	border: 1px solid var(--lbm-border);
	border-radius: 6px;
	background: var(--lbm-bg);
	box-shadow: none;
	line-height: 1;
	cursor: pointer;
}
#lbm-app .lbm-btn-icon:hover { background: var(--lbm-muted); }

/* Inputs & selects — strip theme form skin */
#lbm-app input[type="text"],
#lbm-app input[type="number"],
#lbm-app input[type="date"],
#lbm-app select {
	height: 38px;
	width: auto;
	margin: 0;
	padding: 0 12px;
	border: 1px solid var(--lbm-border);
	border-radius: 8px;
	background-color: var(--lbm-bg);
	color: var(--lbm-fg);
	font-size: 14px;
	font-family: inherit;
	line-height: normal;
	box-shadow: none;
	max-width: 100%;
}
/* Full-width only for the form fields; toolbar filters stay auto-width */
#lbm-app .lbm-field input,
#lbm-app .lbm-field select { width: 100%; }
#lbm-app input:focus,
#lbm-app select:focus {
	border-color: var(--lbm-ring);
	box-shadow: 0 0 0 3px rgb(0 0 0 / 0.08);
	outline: none;
}
#lbm-app input:disabled,
#lbm-app select:disabled { background-color: var(--lbm-muted); }

/* Headings shouldn't pick up odd theme margins/colors */
#lbm-app h1,
#lbm-app h2 { color: var(--lbm-fg); margin-top: 0; }

/* The soft-copy toggle uses a hidden checkbox — keep the theme off it */
#lbm-app .lbm-switch input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	margin: 0;
}
