/* Central contrast fixes and color tokens */
:root{
  --app-text:#0f172a; /* dark text */
  --app-muted:#475569; /* secondary text */
  --app-muted-2:#6b7280; /* lighter secondary */
  --app-accent:#2563eb;
  --app-bg:#ffffff;
  --app-bg-alt:#f8fafc;
}

/* Ensure pages default to light background and dark text */
html, body { background-color: var(--app-bg) !important; color: var(--app-text) !important; }

/* Neutralize any dark-theme body classes */
body.bg-gray-900, body.dark, body[data-theme="dark"]{ background:var(--app-bg) !important; color:var(--app-text) !important; }

/* Muted text */
.muted, .text-muted, .small-muted{ color:var(--app-muted) !important; }

/* Inputs/placeholders */
input::placeholder, textarea::placeholder{ color:var(--app-muted-2) !important; }

/* Sidebar defaults to light */
.sidebar{ background:var(--app-bg-alt) !important; color:var(--app-text) !important; }
.sidebar .sidebar-text, .sidebar .user-info p{ color:var(--app-muted) !important; }

/* Ensure buttons and primary text remain readable */
.btn, button, label, .form-group label{ color:inherit; }

/* Avoid very light gray on white backgrounds */
[style*="#cbd5e0"], [style*="#a0aec0"], [style*="#9ca3af"]{ color:var(--app-muted) !important; }

/* Table header and previews */
.preview-table th, .preview-table td{ color:var(--app-text); }

/* Utility: high contrast utility class */
.text-high-contrast{ color:var(--app-text) !important; }

/* Override common dark Tailwind classes to light equivalents */
[class*="bg-gray-900"], [class*="bg-gray-800"], [class*="bg-gray-700"], [class*="bg-gray-600"]{
  background-color: var(--app-bg-alt) !important;
}
[class*="bg-gray-900/"], [class*="bg-gray-800/"], [class*="bg-gray-700/"], [class*="bg-gray-600/"]{
  background-color: var(--app-bg-alt) !important;
}
[class*="text-gray-100"], [class*="text-gray-200"], [class*="text-gray-300"]{
  color: var(--app-text) !important;
}
[class*="border-gray-700"], [class*="border-gray-800"], [class*="border-gray-600"]{
  border-color: #e5e7eb !important;
}

/* Scrollbar for light theme */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Buttons and gold accent */
.btn-gold { background: linear-gradient(135deg, #facc15, #ca8a04); transition: all 0.3s; color:#1f2937 !important; }
.btn-gold:hover { box-shadow: 0 0 25px rgba(234,179,8,0.25); }

/* Small helper to ensure readable text on previously dark elements */
.bg-dark-fallback { background: var(--app-bg-alt) !important; color: var(--app-text) !important; }

/* Sidebar / menu link styling */
.sidebar a.sidebar-link { color: var(--app-muted) !important; display: flex; align-items: center; }
.sidebar a.sidebar-link .sidebar-text { color: var(--app-muted) !important; transition: color .15s ease; }
.sidebar a.sidebar-link i { color: var(--app-muted) !important; transition: color .15s ease; }

.sidebar a.sidebar-link:hover,
.sidebar a.sidebar-link.active {
  color: var(--app-text) !important;
  background: linear-gradient(135deg, rgba(250,204,21,0.08), rgba(202,138,4,0.04));
  box-shadow: inset 4px 0 0 var(--app-accent);
}
.sidebar a.sidebar-link:hover .sidebar-text,
.sidebar a.sidebar-link.active .sidebar-text { color: var(--app-text) !important; }
.sidebar a.sidebar-link:hover i,
.sidebar a.sidebar-link.active i { color: var(--app-accent) !important; }

/* Smaller visual tweak for collapsed sidebar: keep icons readable */
.sidebar .sidebar-logo-text, .sidebar .user-info { color: var(--app-muted) !important; }
