/* WishOwl Wishlist — minimal styles. Inherits theme typography and colors where possible.
 *
 * Customizable values are exposed as CSS custom properties on :root so the admin
 * "Design" tab can override them via a small inline <style> block in wp_head().
 */

:root {
	--wishowl-accent: #e25555;
	--wishowl-bg: transparent;
	--wishowl-text: inherit;
	--wishowl-border: currentColor;
	--wishowl-bg-hover: rgba(0, 0, 0, 0.05);
	--wishowl-icon-color: #999;
	--wishowl-in-list-bg: transparent;
	--wishowl-in-list-text: var(--wishowl-accent);
	--wishowl-in-list-border: var(--wishowl-accent);

	/*
	 * Sizing vars (--wishowl-radius, --wishowl-padding-y/x, --wishowl-font-size)
	 * are deliberately NOT declared here. When undeclared, `var(--wishowl-padding-y)`
	 * with no fallback resolves to "invalid" → the entire declaration is dropped
	 * → the theme's own padding/font/radius wins.
	 *
	 * The admin's inline <style id="wishowl-wishlist-design"> sets these vars only
	 * when needed (in non-theme presets, or when an override toggle is on in the
	 * theme preset). At that point our declaration becomes valid and wins via the
	 * specificity-bumped non-theme rule below.
	 */
}

/*
 * BASE: structural rules only — NO padding, NO font-size, NO border, NO radius.
 *
 * In the default "Match theme button" preset the button gets the WP block-editor
 * `wp-element-button` class so it inherits the theme's button styling. We do NOT
 * add the `.button` class because some themes (Astra) over-style it (uppercase,
 * letter-spacing, oversized padding) which makes the wishlist button visually
 * overpower the cart button.
 *
 * If a theme still paints poorly, switch to Outline / Solid / Custom in the
 * Design tab to take full control.
 */
/* Use the doubled-class pattern (.wishowl-button.wishowl-button) for specificity
 * (0,2,0) so we tie or beat aggressive theme rules like:
 *   `.ast-single-post .entry-content a` — Astra (0,2,1), underlines our Add-to-cart link
 *   `.woocommerce-js a.button`           — WC      (0,2,1), forces display: inline-block
 *
 * For ties at (0,2,1) we lose source-order to inline styles loaded later, so we
 * also include `a.wishowl-button.wishowl-button` to push to (0,2,1) when the
 * element is an anchor. */
.wishowl-button.wishowl-button,
a.wishowl-button.wishowl-button,
button.wishowl-button.wishowl-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	cursor: pointer;
	transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
	/* Sized by content — prevents block themes (TT5 etc.) from stretching the
	 * wishlist button to full width when it sits inside a stacked flex column
	 * (single-product summary area). !important is justified here: this is a
	 * structural "don't break my button" rule, not aesthetic — themes legitimately
	 * style padding/colors but should never force width on our heart button. The
	 * admin can still override via Design tab → non-theme preset if desired. */
	width: max-content !important;
	max-width: 100%;
	align-self: flex-start !important;
	/* Anchors that wear .wishowl-button (like the in-row Add to cart link) must
	 * NOT inherit theme link styling — no underline, no text-shadow halo. */
	text-decoration: none;
	box-shadow: none;
}

.wishowl-button.wishowl-button:hover,
.wishowl-button.wishowl-button:focus,
.wishowl-button.wishowl-button:active {
	text-decoration: none;
}

/*
 * THEME-PRESET COSMETIC RESET.
 *
 * Themes like Astra over-style every <button> on the page with text-transform:
 * uppercase + letter-spacing: 2px — overpowering the cart button. We neutralize
 * those so the wishlist label reads naturally without changing colors/border/
 * padding (which still come from the theme so the wishlist button matches its
 * button family).
 *
 * Sizing overrides (border-radius, padding, font-size) are NOT in this static
 * stylesheet — they're emitted by emit_design_styles() only when the matching
 * "Override theme value" checkbox is on, so the theme's values stay intact by
 * default.
 */
/* Cover BOTH <button> and <a> elements that wear the design system class —
 * the wishlist page renders Add-to-Cart as an <a> for proper rel="nofollow"
 * GET semantics, and we still want it to share the wishlist's button styling. */
button.wishowl-button.wishowl-button--style-theme,
a.wishowl-button.wishowl-button--style-theme,
.wishowl-button.wishowl-button--style-theme {
	text-transform: none;
	/* Letter-spacing defaults to normal so themes' uppercase+spaced styling is
	 * neutralized. If the user explicitly overrides letter-spacing, the inline
	 * <style> from emit_design_styles() declares it directly with higher
	 * source-order priority. */
	letter-spacing: normal;
	font-weight: inherit;
}

/* Zero-specificity fallback padding + radius for theme preset.
 *
 * For block themes (TT5, TT4) whose only button rule is `:where(.wp-element-button)`
 * (zero specificity), we need *some* padding fallback or the button has none.
 * Wrapping ours in `:where()` makes it (0,0,0) too, so:
 *   - Astra, Storefront, etc. → their `.button` rule at (0,1,0) wins. We don't fight.
 *   - TT5-style block themes → our fallback paints, giving a sensible default.
 *   - Admin Design tab "Override padding" → prints (0,2,1) and wins over both.
 *
 * Don't add Astra-specific or theme-specific overrides here — if a user dislikes
 * how their theme paints the button, they should switch to the Outline/Solid/Custom
 * preset in the Design tab. That's what the preset chooser is for. */
:where(.wishowl-button.wishowl-button--style-theme) {
	padding: 0.667em 1.333em;
	border-radius: 0;
}



.wishowl-button[disabled] {
	opacity: 0.6;
	cursor: wait;
}

.wishowl-button .wishowl-button__icon {
	display: inline-flex;
	align-items: center;
	color: var(--wishowl-icon-color, currentColor);
	transition: color 120ms ease, transform 120ms ease;
}

/*
 * NON-THEME PRESETS (outline / solid / custom): high-specificity overrides so we
 * beat aggressive theme rules like `.woocommerce button.button` (specificity 0,2,1).
 *
 * Repeating `.wishowl-button.wishowl-button` is the standard "raise specificity
 * without nesting" trick: same class twice = (0,2,0); + `button` element = (0,2,1).
 * That ties common theme overrides; source-order tiebreak then favors us.
 *
 * The `:not(.wishowl-button--style-theme)` guard means these rules ONLY apply when
 * the admin opted into a non-theme preset. The theme preset stays bare so the
 * button keeps inheriting the theme's native button styles.
 */
button.wishowl-button.wishowl-button:not(.wishowl-button--style-theme),
.wishowl-button.wishowl-button:not(.wishowl-button--style-theme) {
	/* Fallback values so non-theme presets always have sane sizing even if the
	 * admin hasn't set them explicitly. */
	padding: var(--wishowl-padding-y, 0.5em) var(--wishowl-padding-x, 1em);
	font-size: var(--wishowl-font-size, 0.95em);
	border-radius: var(--wishowl-radius, 4px);
	letter-spacing: var(--wishowl-letter-spacing, normal);
	text-transform: none;
	font-weight: inherit;
	border: 1px solid var(--wishowl-border);
	background: var(--wishowl-bg);
	color: var(--wishowl-text);
	line-height: 1.4;
	min-height: 0;
	height: auto;
}

button.wishowl-button.wishowl-button:not(.wishowl-button--style-theme):hover,
.wishowl-button.wishowl-button:not(.wishowl-button--style-theme):hover {
	background: var(--wishowl-bg-hover);
	color: var(--wishowl-text);
	border-color: var(--wishowl-border);
}

/*
 * IN-WISHLIST STATE.
 * For non-theme presets we paint the full state. For the theme preset we only
 * tint the icon (so users still see SOMETHING change), since touching the
 * background/border there would override the theme's hover/active styling.
 */
.wishowl-button.is-in-wishlist .wishowl-button__icon {
	color: var(--wishowl-accent, #e25555);
}

button.wishowl-button.wishowl-button.is-in-wishlist:not(.wishowl-button--style-theme),
.wishowl-button.wishowl-button.is-in-wishlist:not(.wishowl-button--style-theme) {
	background: var(--wishowl-in-list-bg);
	border-color: var(--wishowl-in-list-border);
	color: var(--wishowl-in-list-text);
}

/* Layout: when adjacent to WC's add-to-cart button, sit on the same row.
 *
 * Classic-theme path: form.cart has inline-block children. We just add a
 * left margin and vertical-align so the heart sits beside Add-to-Cart on
 * the same baseline. */
.woocommerce form.cart .wishowl-button,
.woocommerce-page form.cart .wishowl-button {
	margin-left: 0.5em;
	vertical-align: middle;
}

/* Block-theme path (TT5 etc.) + WC Blocks Add-to-Cart Form block:
 *
 * The block renders `form.cart > .wp-block-woocommerce-add-to-cart-form` as a
 * CSS grid with `grid-template-columns: min-content auto`. A WC rule then
 * forces ANY child that isn't `.quantity` to `grid-column: 1 / -1`, which
 * shoves our wishlist button into a full-width second row.
 *
 * Counter that by making the wishlist button stay in the auto column, sized
 * to its content, and aligned to the start. Doubled class is (0,2,0) which
 * beats WC's `.wp-block-woocommerce-add-to-cart-form .variations_button:not(.quantity)`
 * (0,2,1) only with !important on the grid-column. WC's rule was poorly
 * scoped (it shouldn't have applied to third-party buttons), so overriding
 * with !important is justified — we are not breaking a deliberate choice. */
.wp-block-woocommerce-add-to-cart-form .wishowl-button.wishowl-button,
.woocommerce-variation-add-to-cart .wishowl-button.wishowl-button {
	grid-column: auto !important;
	justify-self: start;
	align-self: center;
}

/* Shop-loop button: don't stretch in flex/grid loops (Storefront, Astra, etc).
 * Most loop wrappers use `display: flex; flex-direction: column; align-items: stretch`.
 * align-self:center keeps the compact button inline-sized; max-content prevents
 * the inline-flex container from being forced full width. */
/*
 * Loop button: keep it from stretching full-width inside flex/grid loop wrappers.
 * Sizing (padding/font) only forced for non-theme presets — theme preset inherits
 * the theme's own button size so it visually matches surrounding elements.
 */
.wishowl-button--compact {
	align-self: center;
	width: max-content;
}

/*
 * Icon-only variant — for the ✕ remove button in the wishlist table/grid.
 * Square aspect, same height as a regular button, larger glyph.
 *
 * IMPORTANT: in theme preset the height comes from the theme. We use min-width
 * matching height (via aspect-ratio) and padding-x:0 so it lays out cleanly
 * regardless of theme padding.
 */
.wishowl-button--icon {
	aspect-ratio: 1 / 1;
	min-width: 32px;
	padding-left: 0 !important;
	padding-right: 0 !important;
	font-size: 1.4em;
	line-height: 1;
}

button.wishowl-button.wishowl-button--icon:not(.wishowl-button--style-theme),
.wishowl-button.wishowl-button--icon:not(.wishowl-button--style-theme) {
	padding-left: 0;
	padding-right: 0;
}

button.wishowl-button.wishowl-button--compact:not(.wishowl-button--style-theme),
.wishowl-button.wishowl-button--compact:not(.wishowl-button--style-theme) {
	padding: var(--wishowl-padding-y, 0.35em) var(--wishowl-padding-x, 0.7em);
	font-size: var(--wishowl-font-size, 0.85em);
}

ul.products li.product .wishowl-button--compact,
.products .wishowl-button--compact {
	margin: 0.25em auto 0;
}

/* When the theme renders our button next to a real add_to_cart_button in the loop,
 * keep them on the same line on wider screens. */
ul.products li.product .button + .wishowl-button--compact,
.products li.product .button + .wishowl-button--compact {
	margin-top: 0.5em;
}

.wishowl-button--floating {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 5;
	width: 36px;
	height: 36px;
	padding: 0;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.92);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
	color: #888;
	justify-content: center;
}

.wishowl-button--floating .wishowl-button__label {
	display: none;
}

.wishowl-button--floating.is-in-wishlist {
	color: #e25555;
}

/* Wishlist page table */

.wishowl-page {
	max-width: 1100px;
	margin: 0 auto;
}

.wishowl-page__header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	margin-bottom: 20px;
}

.wishowl-name-edit {
	font-size: 1.4em;
	font-weight: 600;
	border: 1px dashed transparent;
	background: transparent;
	padding: 4px 6px;
	min-width: 220px;
}

.wishowl-name-edit:focus {
	border-color: #ccc;
	outline: none;
}

.wishowl-page__actions {
	margin-left: auto;
	display: flex;
	gap: 8px;
	align-items: center;
}

/* Layout toggle (table/grid) — segmented control */
.wishowl-view-toggle {
	display: inline-flex;
	border: 1px solid #d0d4dc;
	border-radius: 6px;
	overflow: hidden;
}

.wishowl-view-toggle .wishowl-view-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 30px;
	padding: 0;
	border: 0;
	background: #fff;
	color: #777;
	cursor: pointer;
	transition: background 120ms ease, color 120ms ease;
}

.wishowl-view-toggle .wishowl-view-btn + .wishowl-view-btn {
	border-left: 1px solid #d0d4dc;
}

.wishowl-view-toggle .wishowl-view-btn:hover {
	background: #f3f4f6;
	color: #222;
}

.wishowl-view-toggle .wishowl-view-btn.is-active {
	background: var(--wishowl-accent, #e25555);
	color: #fff;
}

.wishowl-view-toggle .wishowl-view-btn.is-active:hover {
	background: var(--wishowl-accent, #e25555);
	color: #fff;
	opacity: 0.92;
}

.wishowl-view-toggle .wishowl-view-btn svg {
	display: block;
}

.wishowl-table {
	width: 100%;
	border-collapse: collapse;
}

.wishowl-table th, .wishowl-table td {
	padding: 12px 8px;
	text-align: left;
	vertical-align: middle;
	border-bottom: 1px solid #eee;
}

.wishowl-table img.wishowl-thumb {
	width: 64px;
	height: 64px;
	object-fit: cover;
	display: block;
}

.wishowl-price-drop {
	display: inline-block;
	margin-left: 6px;
	padding: 1px 6px;
	font-size: 0.75em;
	background: #e8f7ee;
	color: #0a7c33;
	border-radius: 999px;
}

.wishowl-price-old {
	text-decoration: line-through;
	color: #888;
	margin-right: 6px;
}

.wishowl-empty {
	text-align: center;
	padding: 60px 20px;
	color: #777;
}

.wishowl-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 16px;
}

.wishowl-grid__item {
	border: 1px solid #eee;
	padding: 12px;
	border-radius: 6px;
	text-align: center;
}

.wishowl-grid__item img {
	width: 100%;
	height: 160px;
	object-fit: cover;
}

.wishowl-share-row {
	display: flex;
	gap: 8px;
	align-items: center;
	margin-top: 8px;
}

.wishowl-share-url {
	flex: 1;
	padding: 6px 8px;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-family: monospace;
	font-size: 0.85em;
}

/* Sidebar widget */

.wishowl-widget {
	font-size: 0.95em;
}

.wishowl-widget__row {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 8px;
}

.wishowl-widget__count {
	font-weight: 600;
}

.wishowl-widget__items {
	display: flex;
	gap: 6px;
	margin: 8px 0;
}

.wishowl-widget__items img {
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: 4px;
}

.wishowl-widget__link {
	font-weight: 500;
}

/* Footer brand mention */

.wishowl-powered {
	margin-top: 24px;
	font-size: 0.8em;
	color: #888;
	text-align: center;
}

.wishowl-powered a {
	color: inherit;
	text-decoration: underline;
}

/* Soft cross-promo card on wishlist page */

.wishowl-cta {
	margin-top: 30px;
	padding: 16px 20px;
	border: 1px dashed #d0d4dc;
	border-radius: 8px;
	background: #fafbfd;
	color: #555;
	font-size: 0.95em;
}

.wishowl-cta strong { color: #222; }
.wishowl-cta a { font-weight: 600; }

/* Nav menu count badge — appears next to a wishlist menu item */

.wishowl-count-badge {
	display: inline-block;
	min-width: 1.4em;
	padding: 0 0.45em;
	margin-left: 0.4em;
	font-size: 0.75em;
	font-weight: 600;
	line-height: 1.5;
	text-align: center;
	color: #fff;
	background: #e25555;
	border-radius: 999px;
	vertical-align: middle;
}

.wishowl-count-badge:empty,
.wishowl-count-badge[data-empty="1"] {
	display: none;
}
