/* ====================================== */
/* COMPREHENSIVE COLOR CONTRAST FIX */
/* Ensures proper text/background contrast for all themes */
/* ====================================== */

/* ====================================== */
/* DARK BACKGROUNDS - WHITE TEXT */
/* ====================================== */

/* All dark backgrounds (700+, 800, 900) should have white or light text */
.bg-gray-700,
.bg-gray-800,
.bg-gray-900,
.bg-slate-700,
.bg-slate-800,
.bg-slate-900,
.bg-zinc-700,
.bg-zinc-800,
.bg-zinc-900,
.bg-neutral-700,
.bg-neutral-800,
.bg-neutral-900,
.bg-stone-700,
.bg-stone-800,
.bg-stone-900,
.bg-blue-700,
.bg-blue-800,
.bg-blue-900,
.bg-indigo-700,
.bg-indigo-800,
.bg-indigo-900,
.bg-purple-700,
.bg-purple-800,
.bg-purple-900,
.bg-pink-700,
.bg-pink-800,
.bg-pink-900,
.bg-red-700,
.bg-red-800,
.bg-red-900,
.bg-orange-700,
.bg-orange-800,
.bg-orange-900,
.bg-amber-700,
.bg-amber-800,
.bg-amber-900,
.bg-yellow-700,
.bg-yellow-800,
.bg-yellow-900,
.bg-lime-700,
.bg-lime-800,
.bg-lime-900,
.bg-green-700,
.bg-green-800,
.bg-green-900,
.bg-emerald-700,
.bg-emerald-800,
.bg-emerald-900,
.bg-teal-700,
.bg-teal-800,
.bg-teal-900,
.bg-cyan-700,
.bg-cyan-800,
.bg-cyan-900,
.bg-sky-700,
.bg-sky-800,
.bg-sky-900,
.bg-dark,
.bg-black {
    color: #ffffff !important;
}

/* Ensure all child text elements also have white text on dark backgrounds */
.bg-gray-700 *,
.bg-gray-800 *,
.bg-gray-900 *,
.bg-slate-700 *,
.bg-slate-800 *,
.bg-slate-900 *,
.bg-zinc-700 *,
.bg-zinc-800 *,
.bg-zinc-900 *,
.bg-neutral-700 *,
.bg-neutral-800 *,
.bg-neutral-900 *,
.bg-stone-700 *,
.bg-stone-800 *,
.bg-stone-900 *,
.bg-blue-700 *,
.bg-blue-800 *,
.bg-blue-900 *,
.bg-indigo-700 *,
.bg-indigo-800 *,
.bg-indigo-900 *,
.bg-purple-700 *,
.bg-purple-800 *,
.bg-purple-900 *,
.bg-pink-700 *,
.bg-pink-800 *,
.bg-pink-900 *,
.bg-red-700 *,
.bg-red-800 *,
.bg-red-900 *,
.bg-orange-700 *,
.bg-orange-800 *,
.bg-orange-900 *,
.bg-amber-700 *,
.bg-amber-800 *,
.bg-amber-900 *,
.bg-yellow-700 *,
.bg-yellow-800 *,
.bg-yellow-900 *,
.bg-lime-700 *,
.bg-lime-800 *,
.bg-lime-900 *,
.bg-green-700 *,
.bg-green-800 *,
.bg-green-900 *,
.bg-emerald-700 *,
.bg-emerald-800 *,
.bg-emerald-900 *,
.bg-teal-700 *,
.bg-teal-800 *,
.bg-teal-900 *,
.bg-cyan-700 *,
.bg-cyan-800 *,
.bg-cyan-900 *,
.bg-sky-700 *,
.bg-sky-800 *,
.bg-sky-900 *,
.bg-dark *,
.bg-black * {
    color: #ffffff !important;
}

/* Dark theme mode */
.dark .dark\:bg-gray-700,
.dark .dark\:bg-gray-800,
.dark .dark\:bg-gray-900,
.dark .dark\:bg-slate-700,
.dark .dark\:bg-slate-800,
.dark .dark\:bg-slate-900 {
    color: #ffffff !important;
}

.dark .dark\:bg-gray-700 *,
.dark .dark\:bg-gray-800 *,
.dark .dark\:bg-gray-900 *,
.dark .dark\:bg-slate-700 *,
.dark .dark\:bg-slate-800 *,
.dark .dark\:bg-slate-900 * {
    color: #ffffff !important;
}

/* Override dark text on dark backgrounds */
.bg-gray-700.text-gray-700,
.bg-gray-800.text-gray-800,
.bg-gray-900.text-gray-900,
.bg-gray-700.text-gray-800,
.bg-gray-800.text-gray-900,
.bg-dark.text-gray-700,
.bg-dark.text-gray-800,
.bg-dark.text-gray-900,
.bg-black.text-black,
.dark .dark\:bg-gray-700.dark\:text-gray-700,
.dark .dark\:bg-gray-800.dark\:text-gray-800,
.dark .dark\:bg-gray-900.dark\:text-gray-900 {
    color: #ffffff !important;
}

/* ====================================== */
/* LIGHT BACKGROUNDS - DARK TEXT */
/* ====================================== */

/* All light backgrounds (white, 50, 100, 200) should have dark text */
.bg-white,
.bg-gray-50,
.bg-gray-100,
.bg-gray-200,
.bg-slate-50,
.bg-slate-100,
.bg-slate-200,
.bg-zinc-50,
.bg-zinc-100,
.bg-zinc-200,
.bg-neutral-50,
.bg-neutral-100,
.bg-neutral-200,
.bg-stone-50,
.bg-stone-100,
.bg-stone-200,
.bg-blue-50,
.bg-blue-100,
.bg-blue-200,
.bg-indigo-50,
.bg-indigo-100,
.bg-indigo-200,
.bg-purple-50,
.bg-purple-100,
.bg-purple-200,
.bg-pink-50,
.bg-pink-100,
.bg-pink-200,
.bg-red-50,
.bg-red-100,
.bg-red-200,
.bg-orange-50,
.bg-orange-100,
.bg-orange-200,
.bg-amber-50,
.bg-amber-100,
.bg-amber-200,
.bg-yellow-50,
.bg-yellow-100,
.bg-yellow-200,
.bg-lime-50,
.bg-lime-100,
.bg-lime-200,
.bg-green-50,
.bg-green-100,
.bg-green-200,
.bg-emerald-50,
.bg-emerald-100,
.bg-emerald-200,
.bg-teal-50,
.bg-teal-100,
.bg-teal-200,
.bg-cyan-50,
.bg-cyan-100,
.bg-cyan-200,
.bg-sky-50,
.bg-sky-100,
.bg-sky-200 {
    color: #1f2937 !important;
}

/* Ensure all child text elements also have dark text on light backgrounds */
.bg-white *,
.bg-gray-50 *,
.bg-gray-100 *,
.bg-gray-200 *,
.bg-slate-50 *,
.bg-slate-100 *,
.bg-slate-200 *,
.bg-zinc-50 *,
.bg-zinc-100 *,
.bg-zinc-200 *,
.bg-neutral-50 *,
.bg-neutral-100 *,
.bg-neutral-200 *,
.bg-stone-50 *,
.bg-stone-100 *,
.bg-stone-200 *,
.bg-blue-50 *,
.bg-blue-100 *,
.bg-blue-200 *,
.bg-indigo-50 *,
.bg-indigo-100 *,
.bg-indigo-200 *,
.bg-purple-50 *,
.bg-purple-100 *,
.bg-purple-200 *,
.bg-pink-50 *,
.bg-pink-100 *,
.bg-pink-200 *,
.bg-red-50 *,
.bg-red-100 *,
.bg-red-200 *,
.bg-orange-50 *,
.bg-orange-100 *,
.bg-orange-200 *,
.bg-amber-50 *,
.bg-amber-100 *,
.bg-amber-200 *,
.bg-yellow-50 *,
.bg-yellow-100 *,
.bg-yellow-200 *,
.bg-lime-50 *,
.bg-lime-100 *,
.bg-lime-200 *,
.bg-green-50 *,
.bg-green-100 *,
.bg-green-200 *,
.bg-emerald-50 *,
.bg-emerald-100 *,
.bg-emerald-200 *,
.bg-teal-50 *,
.bg-teal-100 *,
.bg-teal-200 *,
.bg-cyan-50 *,
.bg-cyan-100 *,
.bg-cyan-200 *,
.bg-sky-50 *,
.bg-sky-100 *,
.bg-sky-200 * {
    color: #1f2937 !important;
}

/* Override light text on light backgrounds */
.bg-white.text-white,
.bg-white.text-gray-100,
.bg-white.text-gray-200,
.bg-white.text-gray-300,
.bg-white.text-gray-400,
.bg-gray-50.text-white,
.bg-gray-50.text-gray-100,
.bg-gray-50.text-gray-200,
.bg-gray-50.text-gray-300,
.bg-gray-50.text-gray-400,
.bg-gray-100.text-white,
.bg-gray-100.text-gray-100,
.bg-gray-100.text-gray-200,
.bg-gray-100.text-gray-300,
.bg-gray-100.text-gray-400,
.bg-gray-200.text-white,
.bg-gray-200.text-gray-200,
.bg-gray-200.text-gray-300,
.bg-blue-50.text-white,
.bg-indigo-50.text-white,
.bg-green-50.text-white,
.bg-red-50.text-white {
    color: #1f2937 !important;
}

/* ====================================== */
/* BUTTONS - PRESERVE ORIGINAL COLORS INSIDE */
/* ====================================== */

/* Preserve button colors - buttons handle their own contrast */
button,
.btn,
[class*="btn-"],
a[class*="bg-"] {
    /* Remove global color override for buttons */
}

/* But ensure button text is appropriate */
.bg-blue-500,
.bg-blue-600,
.bg-blue-700,
.bg-indigo-500,
.bg-indigo-600,
.bg-indigo-700,
.bg-purple-500,
.bg-purple-600,
.bg-purple-700,
.bg-pink-500,
.bg-pink-600,
.bg-pink-700,
.bg-red-500,
.bg-red-600,
.bg-red-700,
.bg-orange-500,
.bg-orange-600,
.bg-orange-700,
.bg-amber-500,
.bg-amber-600,
.bg-amber-700,
.bg-yellow-500,
.bg-yellow-600,
.bg-yellow-700,
.bg-lime-500,
.bg-lime-600,
.bg-lime-700,
.bg-green-500,
.bg-green-600,
.bg-green-700,
.bg-emerald-500,
.bg-emerald-600,
.bg-emerald-700,
.bg-teal-500,
.bg-teal-600,
.bg-teal-700,
.bg-cyan-500,
.bg-cyan-600,
.bg-cyan-700,
.bg-sky-500,
.bg-sky-600,
.bg-sky-700,
.bg-gray-500,
.bg-gray-600 {
    color: #ffffff !important;
}

/* Ensure button children also have white text */
.bg-blue-500 *,
.bg-blue-600 *,
.bg-blue-700 *,
.bg-indigo-500 *,
.bg-indigo-600 *,
.bg-indigo-700 *,
.bg-purple-500 *,
.bg-purple-600 *,
.bg-purple-700 *,
.bg-pink-500 *,
.bg-pink-600 *,
.bg-pink-700 *,
.bg-red-500 *,
.bg-red-600 *,
.bg-red-700 *,
.bg-orange-500 *,
.bg-orange-600 *,
.bg-orange-700 *,
.bg-amber-500 *,
.bg-amber-600 *,
.bg-amber-700 *,
.bg-yellow-500 *,
.bg-yellow-600 *,
.bg-yellow-700 *,
.bg-lime-500 *,
.bg-lime-600 *,
.bg-lime-700 *,
.bg-green-500 *,
.bg-green-600 *,
.bg-green-700 *,
.bg-emerald-500 *,
.bg-emerald-600 *,
.bg-emerald-700 *,
.bg-teal-500 *,
.bg-teal-600 *,
.bg-teal-700 *,
.bg-cyan-500 *,
.bg-cyan-600 *,
.bg-cyan-700 *,
.bg-sky-500 *,
.bg-sky-600 *,
.bg-sky-700 *,
.bg-gray-500 *,
.bg-gray-600 * {
    color: #ffffff !important;
}

/* ====================================== */
/* INPUT AND SELECT ELEMENTS */
/* ====================================== */

/* Light background inputs should have dark text */
input.bg-white,
input.bg-gray-50,
input.bg-gray-100,
select.bg-white,
select.bg-gray-50,
select.bg-gray-100,
textarea.bg-white,
textarea.bg-gray-50,
textarea.bg-gray-100,
.dark input.dark\:bg-gray-700,
.dark select.dark\:bg-gray-700,
.dark textarea.dark\:bg-gray-700 {
    color: #1f2937 !important;
}

/* Dark background inputs should have white text */
.dark input.dark\:bg-gray-700,
.dark select.dark\:bg-gray-700,
.dark textarea.dark\:bg-gray-700 {
    color: #ffffff !important;
}

/* ====================================== */
/* TABLE ELEMENTS */
/* ====================================== */

/* Table headers with dark backgrounds */
thead.bg-gray-700,
thead.bg-gray-800,
thead.bg-gray-900,
th.bg-gray-700,
th.bg-gray-800,
th.bg-gray-900,
.dark thead.dark\:bg-gray-700,
.dark thead.dark\:bg-gray-800,
.dark th.dark\:bg-gray-700 {
    color: #ffffff !important;
}

thead.bg-gray-700 *,
thead.bg-gray-800 *,
thead.bg-gray-900 *,
th.bg-gray-700 *,
th.bg-gray-800 *,
th.bg-gray-900 *,
.dark thead.dark\:bg-gray-700 *,
.dark thead.dark\:bg-gray-800 *,
.dark th.dark\:bg-gray-700 * {
    color: #ffffff !important;
}

/* Table headers with light backgrounds */
thead.bg-gray-50,
thead.bg-gray-100,
th.bg-gray-50,
th.bg-gray-100 {
    color: #1f2937 !important;
}

thead.bg-gray-50 *,
thead.bg-gray-100 *,
th.bg-gray-50 *,
th.bg-gray-100 * {
    color: #1f2937 !important;
}

/* ====================================== */
/* CARD AND PANEL ELEMENTS */
/* ====================================== */

/* Cards with dark backgrounds */
.card.bg-dark,
.card.bg-gray-800,
.card.bg-gray-900,
.panel.bg-dark,
.panel.bg-gray-800,
.panel.bg-gray-900 {
    color: #ffffff !important;
}

/* Cards with light backgrounds */
.card.bg-white,
.card.bg-gray-50,
.card.bg-gray-100,
.panel.bg-white,
.panel.bg-gray-50,
.panel.bg-gray-100 {
    color: #1f2937 !important;
}

/* ====================================== */
/* SPECIAL CASES */
/* ====================================== */

/* Legal pages with bg-dark headers */
.bg-dark.text-white {
    color: #ffffff !important;
}

/* Info boxes */
.bg-info.text-white {
    color: #ffffff !important;
}

/* Primary boxes */
.bg-primary.text-white {
    color: #ffffff !important;
}

/* Sidebar - always white text */
.admin-sidebar,
.admin-sidebar * {
    color: #ffffff !important;
}

/* ====================================== */
/* DARK MODE GLOBAL RULES */
/* ====================================== */

.dark body,
.dark .dark\:text-gray-200,
.dark .dark\:text-gray-300,
.dark .dark\:text-white {
    color: #e5e7eb !important;
}

.dark .dark\:bg-gray-900 {
    background-color: #111827 !important;
    color: #ffffff !important;
}

.dark .dark\:bg-gray-800 {
    background-color: #1f2937 !important;
    color: #ffffff !important;
}

.dark .dark\:bg-gray-700 {
    background-color: #374151 !important;
    color: #ffffff !important;
}

/* ====================================== */
/* HOVER STATES */
/* ====================================== */

/* Ensure hover states maintain proper contrast */
.hover\:text-white:hover,
.dark .dark\:hover\:text-white:hover {
    color: #ffffff !important;
}

.hover\:text-gray-900:hover,
.dark .dark\:hover\:text-white:hover.bg-gray-50,
.dark .dark\:hover\:text-white:hover.bg-white {
    color: #1f2937 !important;
}

/* ====================================== */
/* BADGE AND TAG ELEMENTS */
/* ====================================== */

/* Badges with light backgrounds */
.bg-gray-100.text-gray-800,
.bg-gray-100.text-gray-700,
.bg-gray-200.text-gray-800,
.bg-blue-100.text-blue-800,
.bg-green-100.text-green-800 {
    color: #1f2937 !important;
}

/* Badges with dark backgrounds in dark mode */
.dark .dark\:bg-gray-700.dark\:text-gray-200,
.dark .dark\:bg-gray-700.dark\:text-gray-300,
.dark .dark\:bg-gray-800.dark\:text-gray-200 {
    color: #ffffff !important;
}

/* ====================================== */
/* FILE INPUT ELEMENTS */
/* ====================================== */

/* File inputs with light backgrounds */
input[type="file"].bg-white,
input[type="file"].bg-gray-50,
input[type="file"].bg-indigo-50,
input[type="file"].bg-indigo-100 {
    color: #1f2937 !important;
}

/* File inputs with dark backgrounds in dark mode */
.dark input[type="file"].dark\:bg-gray-700,
.dark input[type="file"].dark\:bg-gray-800 {
    color: #ffffff !important;
}

/* ====================================== */
/* PLACEHOLDER FIX */
/* ====================================== */

/* Ensure placeholders are visible on both themes */
::placeholder {
    color: #9ca3af !important;
    opacity: 1 !important;
}

.dark ::placeholder {
    color: #6b7280 !important;
    opacity: 1 !important;
}

/* ====================================== */
/* OVERRIDE ANY CONFLICTING TEXT COLORS */
/* ====================================== */

/* Fix common problematic combinations found in scan */
.bg-gray-50.text-white,
.bg-gray-100.text-white,
.bg-gray-200.text-gray-200,
.bg-gray-200.text-gray-300,
.bg-gray-200.text-gray-400 {
    color: #1f2937 !important;
}

.bg-gray-700.text-gray-700,
.bg-gray-700.text-gray-800,
.bg-gray-700.text-gray-900,
.bg-gray-800.text-gray-800,
.bg-gray-800.text-gray-900,
.bg-gray-900.text-gray-800,
.bg-gray-900.text-gray-900 {
    color: #ffffff !important;
}

/* Fix departmental inventory specific issues */
.bg-emerald-700.text-black {
    color: #ffffff !important;
}

.bg-red-700.text-black,
.bg-red-800.text-black,
.bg-red-900.text-black,
.bg-red-900.text-gray-700 {
    color: #ffffff !important;
}

/* ====================================== */
/* ENSURE ICON VISIBILITY */
/* ====================================== */

/* Icons should inherit parent text color */
.bg-gray-700 i,
.bg-gray-800 i,
.bg-gray-900 i,
.bg-dark i,
.bg-black i {
    color: inherit;
}

.bg-white i,
.bg-gray-50 i,
.bg-gray-100 i,
.bg-gray-200 i {
    color: inherit;
}

/* ====================================== */
/* FORCE IMPORTANT ON ALL FIXES */
/* ====================================== */

/* This ensures our contrast rules override any inline styles or other CSS */