/* Dark mode readability tweaks scoped to dark theme */
[data-bs-theme="dark"] .text-secondary { color: rgba(229,231,235,0.86) !important; }
[data-bs-theme="dark"] .text-muted { color: rgba(229,231,235,0.66) !important; }
/* Badges and subtle backgrounds */
[data-bs-theme="dark"] .badge.bg-secondary-lt { background-color: rgba(229,231,235,0.12) !important; color: rgba(229,231,235,0.9) !important; }
[data-bs-theme="dark"] .card .card-header .text-secondary { color: rgba(229,231,235,0.8) !important; }
/* Tables */
[data-bs-theme="dark"] table .text-secondary { color: rgba(229,231,235,0.8) !important; }

/* Inputs: placeholder + disabled text */
[data-bs-theme="dark"] .form-control::placeholder,
[data-bs-theme="dark"] .form-select::placeholder,
[data-bs-theme="dark"] textarea::placeholder { color: rgba(229,231,235,0.55) !important; }
[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-select:disabled,
[data-bs-theme="dark"] fieldset:disabled .form-control,
[data-bs-theme="dark"] fieldset:disabled .form-select { color: rgba(229,231,235,0.6) !important; }

/* Outline secondary buttons: ensure sufficient contrast */
[data-bs-theme="dark"] .btn-outline-secondary { color: rgba(229,231,235,0.9); border-color: rgba(229,231,235,0.35); }
[data-bs-theme="dark"] .btn-outline-secondary:hover,
[data-bs-theme="dark"] .btn-outline-secondary:focus { color: rgba(229,231,235,0.98); border-color: rgba(229,231,235,0.55); background-color: rgba(229,231,235,0.08); }

/* Secondary links */
[data-bs-theme="dark"] .link-secondary,
[data-bs-theme="dark"] a.text-secondary { color: rgba(229,231,235,0.82) !important; }
[data-bs-theme="dark"] .link-secondary:hover,
[data-bs-theme="dark"] a.text-secondary:hover { color: rgba(229,231,235,0.95) !important; }

/* Ensure text remains readable on colored backgrounds in all themes */
.alert .text-secondary { color: inherit !important; }
.badge .text-secondary { color: inherit !important; }
/* Also inherit for links and muted text inside alerts/badges */
.alert .text-muted, .alert a, .alert .badge { color: inherit !important; }
/* Light theme alerts may have low-contrast muted text; normalize */
.alert .text-muted { opacity: .92; }
/* For dark theme, also ensure better contrast inside alerts */
[data-bs-theme="dark"] .alert .text-muted { color: inherit !important; opacity: .92; }

/* Solid color badges: force readable text color */
.badge.bg-red, .badge.bg-danger,
.badge.bg-orange, .badge.bg-warning,
.badge.bg-yellow,
.badge.bg-primary, .badge.bg-blue, .badge.bg-azure,
.badge.bg-green,
.badge.bg-indigo, .badge.bg-purple,
.badge.bg-success
{ color: #fff !important; }

/* Secondary solid badge: keep text readable */
.badge.bg-secondary { color: #fff !important; }

/* Light-tone background badges (bg-*-lt): align text color with semantic hue for contrast */
.badge.bg-blue-lt { color: var(--tblr-blue) !important; }
.badge.bg-azure-lt { color: var(--tblr-azure) !important; }
.badge.bg-primary-lt { color: var(--tblr-primary) !important; }
.badge.bg-green-lt { color: var(--tblr-green) !important; }
.badge.bg-yellow-lt { color: var(--tblr-yellow) !important; }
.badge.bg-orange-lt { color: var(--tblr-orange) !important; }
.badge.bg-red-lt { color: var(--tblr-red) !important; }
.badge.bg-indigo-lt { color: var(--tblr-indigo) !important; }
.badge.bg-purple-lt { color: var(--tblr-purple) !important; }
.badge.bg-muted-lt { color: var(--tblr-secondary) !important; }

/* Support Bootstrap-style success aliases used in some views */
.badge.bg-success-lt { color: var(--tblr-success, var(--tblr-green)) !important; }

/* Improve readability of disabled outline secondary buttons (both themes) */
.btn-outline-secondary:disabled,
.btn-outline-secondary.disabled,
fieldset:disabled .btn-outline-secondary {
	color: #495057 !important; /* darker text */
	border-color: #adb5bd !important; /* stronger border */
	background-color: rgba(0,0,0,0.02) !important; /* subtle fill for contrast */
	opacity: 1 !important; /* avoid extra fading */
}

/* Dark theme variant for disabled outline secondary */
[data-bs-theme="dark"] .btn-outline-secondary:disabled,
[data-bs-theme="dark"] .btn-outline-secondary.disabled,
[data-bs-theme="dark"] fieldset:disabled .btn-outline-secondary {
	color: rgba(229,231,235,0.9) !important;
	border-color: rgba(229,231,235,0.45) !important;
	background-color: rgba(229,231,235,0.08) !important;
	opacity: 1 !important;
}

/* Embedded text-* on *-lt backgrounds: prefer the matching hue for readability */
.bg-blue-lt .text-secondary, .bg-blue-lt .text-muted { color: var(--tblr-blue) !important; }
.bg-green-lt .text-secondary, .bg-green-lt .text-muted { color: var(--tblr-green) !important; }
.bg-yellow-lt .text-secondary, .bg-yellow-lt .text-muted { color: var(--tblr-yellow) !important; }
.bg-orange-lt .text-secondary, .bg-orange-lt .text-muted { color: var(--tblr-orange) !important; }
.bg-red-lt .text-secondary, .bg-red-lt .text-muted { color: var(--tblr-red) !important; }
.bg-indigo-lt .text-secondary, .bg-indigo-lt .text-muted { color: var(--tblr-indigo) !important; }
.bg-purple-lt .text-secondary, .bg-purple-lt .text-muted { color: var(--tblr-purple) !important; }
.bg-primary-lt .text-secondary, .bg-primary-lt .text-muted { color: var(--tblr-primary) !important; }
.bg-azure-lt .text-secondary, .bg-azure-lt .text-muted { color: var(--tblr-azure) !important; }
.bg-muted-lt .text-secondary, .bg-muted-lt .text-muted { color: var(--tblr-secondary) !important; }

/* Notification bell badge alignment and color */
.navbar .badge.bg-red { color: #fff !important; min-width: 0.5rem; min-height: 0.5rem; }

/* Code blocks: ensure readable text on light backgrounds (fix white-on-white) */
pre.bg-light,
pre.bg-light code,
pre.bg-light kbd,
pre.bg-light samp,
.bg-light pre,
.bg-light pre code,
.bg-light pre kbd,
.bg-light pre samp {
	color: #1f2937 !important; /* slate-800-ish for strong contrast on light bg */
}

/* Featured Products (product-card) fixes for dark theme */
[data-bs-theme="dark"] .product-card {
	color: rgba(243,244,246,0.95); /* near-white body text on dark */
}
[data-bs-theme="dark"] .product-card .product-title {
	color: rgba(255,255,255,0.96); /* strong contrast for titles */
	/* Title chip to ensure readability even if image above is white */
	background: rgba(0,0,0,0.28);
	padding: .125rem .25rem;
	border-radius: .25rem;
}
[data-bs-theme="dark"] .product-card .text-secondary,
[data-bs-theme="dark"] .product-card .text-muted {
	color: rgba(229,231,235,0.78) !important; /* readable subtitle/brand */
}
[data-bs-theme="dark"] .product-card .ratio {
	background-color: #0b1220; /* deep slate to avoid white halo behind images */
}
[data-bs-theme="dark"] .product-card .ratio img {
	background-color: transparent; /* preserve image transparency */
}

/* Guard against accidental overlap: ensure spacing between image and body */
[data-bs-theme="dark"] .product-card .ratio + .card-body { margin-top: .125rem; }

/* Brand logos in dark theme: reduce glare slightly */
[data-bs-theme="dark"] .product-card .brand-logo {
	opacity: .92;
}

/* Light theme base for modern placeholder tile (kept here so it's globally available) */
.ph-tile { 
	position: relative; 
	border-radius: .5rem; 
	background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
	display: flex; align-items: center; justify-content: center; 
	color: #94a3b8; 
}
.ph-tile svg { width: 56px; height: 56px; opacity: .8; }

/* Portal/catalog card images: avoid bright white tiles in dark */
[data-bs-theme="dark"] .card .card-img-top {
	background-color: #0b1220 !important; /* deep slate */
}

/* Dark theme variant for modern placeholder tile */
[data-bs-theme="dark"] .ph-tile {
	background: linear-gradient(135deg, #0b1220 0%, #0f172a 100%);
	color: #64748b; /* slate-500 */
}
[data-bs-theme="dark"] .ph-tile svg { opacity: .85; }
