/**
 * Catalyst Networks Theme Overrides
 * Additional styles to integrate with existing application
 */

/* Body and Background */
.catalyst-body {
  font-family: var(--catalyst-font-family);
  background-color: #f9fafb;
  color: var(--catalyst-gray);
  min-height: 100vh;
}

/* Sidebar Container Fix */
.catalyst-sidebar-container {
  position: relative;
  z-index: 40;
}

/* Override the sidebar gradient to be more subtle */
.catalyst-sidebar {
  background: linear-gradient(180deg, #1E293B 0%, #1E293B 100%) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

/* Logo Link Styling */
.catalyst-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: 0.75rem;
}

/* Menu active state - use teal instead of purple */
.catalyst-menu-link.active {
  background-color: rgba(14, 165, 233, 0.1) !important;
  color: var(--catalyst-teal) !important;
  border-left: 3px solid var(--catalyst-teal);
  padding-left: calc(1rem - 3px);
}

/* Menu Subtitle */
.catalyst-menu-subtitle {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
}

/* Main Content Area */
.catalyst-main {
  background-color: #f9fafb;
}

/* Background Animation - make it more subtle */
.catalyst-background {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.catalyst-background::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 20% 80%, rgba(14, 165, 233, 0.02) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(14, 165, 233, 0.02) 0%, transparent 50%),
              radial-gradient(circle at 40% 40%, rgba(14, 165, 233, 0.01) 0%, transparent 50%);
  animation: catalyst-drift 30s ease-in-out infinite;
}

@keyframes catalyst-drift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(-30px, -30px) rotate(120deg); }
  66% { transform: translate(30px, -30px) rotate(240deg); }
}

/* Alert Icon Styling */
.catalyst-alert svg {
  flex-shrink: 0;
}

/* Sidebar Footer */
.catalyst-sidebar-footer {
  padding: 0.75rem;
  background-color: rgba(0, 0, 0, 0.1);
}

/* Mobile Header */
.catalyst-mobile-header {
  background-color: var(--catalyst-blue);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  height: 4rem;
  display: flex;
  align-items: center;
}

/* Mobile Header Visibility */
@media (min-width: 768px) {
  .catalyst-mobile-header {
    display: none;
  }
}

/* Ensure content wrapper takes full width on desktop */
@media (min-width: 768px) {
  .catalyst-content-wrapper {
    margin-left: 280px;
  }
}

/* Footer Styling */
.catalyst-footer {
  position: relative;
  z-index: 10;
}

/* Fix for existing hover-glow class */
.hover-glow {
  transition: all 0.3s ease;
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(14, 165, 233, 0.15);
  transform: translateY(-2px);
}

/* Ensure proper stacking context */
.catalyst-sidebar {
  position: fixed !important;
}

/* Override existing form styles to match Catalyst theme */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: var(--catalyst-radius-md);
  color: var(--catalyst-gray);
  padding: 0.5rem 0.75rem;
  width: 100%;
  transition: all var(--catalyst-transition-base);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--catalyst-teal);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
  background-color: white;
}

/* Dark mode adjustments for forms */
.dark input:not([type="checkbox"]):not([type="radio"]),
.dark select,
.dark textarea {
  background-color: var(--catalyst-blue);
  border-color: var(--catalyst-blue-light);
  color: white;
}

.dark input:not([type="checkbox"]):not([type="radio"]):focus,
.dark select:focus,
.dark textarea:focus {
  background-color: var(--catalyst-blue);
  border-color: var(--catalyst-teal);
}

/* Button overrides - ensure all buttons are readable */
button:not(.catalyst-no-style),
input[type="button"],
input[type="reset"],
input[type="submit"],
.btn,
.btn-primary,
.btn-secondary {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--catalyst-radius-md);
  cursor: pointer;
  transition: all var(--catalyst-transition-base);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

button:not(.catalyst-no-style):hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover,
.btn:hover,
.btn-primary:hover {
  background-color: var(--catalyst-blue) !important;
  color: white !important;
  transform: translateY(-2px);
  box-shadow: var(--catalyst-shadow-md);
}

/* Secondary buttons */
.btn-secondary {
  background-color: transparent !important;
  color: var(--catalyst-teal) !important;
  border: 2px solid var(--catalyst-teal) !important;
}

.btn-secondary:hover {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
  border-color: var(--catalyst-teal) !important;
}

/* Fix text color issues on cards */
.catalyst-card {
  background-color: white;
  color: var(--catalyst-gray);
}

.catalyst-card h1,
.catalyst-card h2,
.catalyst-card h3,
.catalyst-card h4,
.catalyst-card h5,
.catalyst-card h6 {
  color: var(--catalyst-blue);
}

/* Fix link colors for better readability */
a:not(.catalyst-menu-link):not(.catalyst-logo-link):not(.btn-catalyst) {
  color: var(--catalyst-teal);
}

a:not(.catalyst-menu-link):not(.catalyst-logo-link):not(.btn-catalyst):hover {
  color: var(--catalyst-teal-light);
}

/* Fix label colors */
label {
  color: var(--catalyst-blue);
  font-weight: 500;
}

/* Fix text colors in forms */
.text-gray-700 {
  color: var(--catalyst-gray) !important;
}

.text-gray-500 {
  color: var(--catalyst-gray-light) !important;
}

/* Fix blue color references to use catalyst-teal */
.text-blue-600 {
  color: var(--catalyst-teal) !important;
}

.text-blue-500 {
  color: var(--catalyst-teal-light) !important;
}

.bg-blue-600 {
  background-color: var(--catalyst-teal) !important;
}

.bg-blue-700 {
  background-color: var(--catalyst-blue) !important;
}

.hover\:bg-blue-700:hover {
  background-color: var(--catalyst-blue) !important;
}

.hover\:text-blue-500:hover {
  color: var(--catalyst-teal-light) !important;
}

.focus\:ring-blue-500:focus {
  --tw-ring-color: var(--catalyst-teal) !important;
}

.focus\:border-blue-500:focus {
  border-color: var(--catalyst-teal) !important;
}

/* Fix error message visibility */
.bg-red-100 {
  background-color: rgba(239, 68, 68, 0.1) !important;
}

.text-red-700 {
  color: var(--catalyst-error) !important;
}

.text-red-600 {
  color: var(--catalyst-error) !important;
}

/* Dashboard specific fixes */
.bg-dark-900 {
  background-color: white !important;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

/* User avatar colors - use teal consistently */
.bg-primary-700 {
  background-color: var(--catalyst-teal) !important;
}

.text-primary-400 {
  color: var(--catalyst-teal) !important;
}

.hover\:bg-primary-700:hover {
  background-color: rgba(14, 165, 233, 0.1) !important;
}

.hover\:text-primary-400:hover {
  color: var(--catalyst-teal) !important;
}

/* Fix mobile menu styling */
.text-light-300 {
  color: rgba(255, 255, 255, 0.9) !important;
}

.hover\:bg-primary-700:hover {
  background-color: rgba(14, 165, 233, 0.1) !important;
}

/* Remove purple tints from UI */
.bg-opacity-20 {
  background-color: rgba(14, 165, 233, 0.1) !important;
}

/* Ensure checkbox styling is consistent */
input[type="checkbox"] {
  accent-color: var(--catalyst-teal);
}

/* Fix border colors for better harmony */
.border-gray-300 {
  border-color: #e5e7eb !important;
}

.border-gray-700 {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Dashboard specific fixes */
.bg-dark-800 {
  background-color: #f9fafb !important;
}

.text-light-100 {
  color: var(--catalyst-blue) !important;
}

.text-light-200 {
  color: var(--catalyst-gray) !important;
}

.text-light-300 {
  color: var(--catalyst-gray-light) !important;
}

/* Fix organization cards */
.bg-primary-700.bg-opacity-10 {
  background-color: rgba(14, 165, 233, 0.05) !important;
}

.bg-primary-700.bg-opacity-20 {
  background-color: rgba(14, 165, 233, 0.1) !important;
}

/* Fix info/notice boxes */
.bg-primary-700.bg-opacity-10.border-l-4 {
  background-color: #f0f9ff !important;
  border-left-color: var(--catalyst-teal) !important;
}

/* Fix border colors */
.border-gray-700 {
  border-color: #e5e7eb !important;
}

/* Stats cards icons */
.text-primary-400 {
  color: var(--catalyst-teal) !important;
}

/* Fix buttons */
.bg-primary-500 {
  background-color: var(--catalyst-teal) !important;
}

.bg-primary-600 {
  background-color: var(--catalyst-blue) !important;
}

.hover\:bg-primary-600:hover {
  background-color: var(--catalyst-blue) !important;
}

/* Fix loading spinners */
.border-primary-400 {
  border-color: var(--catalyst-teal) !important;
}

/* Fix role badges */
.bg-gray-700 {
  background-color: var(--catalyst-gray-light) !important;
}

.text-gray-300 {
  color: white !important;
}

/* Fix hover states */
.hover-glow {
  transition: all 0.3s ease;
  background-color: white;
}

.hover-glow:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

/* Make sure all text is readable */
p, span, div {
  color: inherit;
}

/* Fix gray text */
.text-gray-500 {
  color: var(--catalyst-gray) !important;
}

/* Animation fixes */
.animate-spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Ensure card text is readable */
.bg-dark-900 h1,
.bg-dark-900 h2,
.bg-dark-900 h3,
.bg-dark-900 h4,
.bg-dark-900 h5,
.bg-dark-900 h6 {
  color: var(--catalyst-blue) !important;
}

.bg-dark-900 p,
.bg-dark-900 span {
  color: var(--catalyst-gray);
}

/* Fix organization card stat boxes */
.bg-primary-700.bg-opacity-10.rounded {
  background-color: #f0f9ff !important;
  border: 1px solid rgba(14, 165, 233, 0.2);
}

/* Ensure links in cards are visible */
.bg-dark-900 a:not(.btn-catalyst):not(.catalyst-menu-link) {
  color: var(--catalyst-teal) !important;
}

.bg-dark-900 a:not(.btn-catalyst):not(.catalyst-menu-link):hover {
  color: var(--catalyst-teal-light) !important;
  text-decoration: underline;
}

/* Fix button inside cards */
.bg-dark-900 .bg-primary-500 {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
}

/* Override any remaining background issues */
div[class*="bg-dark"] {
  background-color: white !important;
}

/* Fix nested cards */
.bg-dark-900 .bg-dark-800 {
  background-color: #f9fafb !important;
  border: 1px solid #e5e7eb !important;
}

/* Fix icon containers */
.p-3.rounded-full.bg-primary-700.bg-opacity-20 {
  background-color: #e0f2fe !important;
}

/* Ensure certificate warning and activity sections are readable */
#certificate-warnings,
#recent-activity {
  color: var(--catalyst-gray);
}

/* Fix any remaining contrast issues */
.bg-dark-900 .text-sm {
  color: var(--catalyst-gray) !important;
}

/* Organization card specific fixes */
.bg-dark-800.border.border-gray-700.rounded-lg {
  background-color: #f9fafb !important;
  border-color: #e5e7eb !important;
}

.bg-dark-900.border-b.border-gray-700 {
  background-color: white !important;
  border-bottom-color: #e5e7eb !important;
}

/* Mobile dropdown menu - keep it dark */
.bg-catalyst-blue {
  background-color: var(--catalyst-blue) !important;
}

.border-catalyst-blue-light {
  border-color: var(--catalyst-blue-light) !important;
}

/* Fix mobile dropdown menu items */
.bg-catalyst-blue a {
  color: rgba(255, 255, 255, 0.9) !important;
}

.bg-catalyst-blue a:hover {
  background-color: rgba(14, 165, 233, 0.1) !important;
  color: white !important;
}

.bg-catalyst-blue .border-t {
  border-top-color: rgba(255, 255, 255, 0.1) !important;
}

.bg-catalyst-blue .text-xs {
  color: var(--catalyst-teal) !important;
  opacity: 0.8;
}

/* Fix form elements to ensure they work in both light and dark contexts */
.catalyst-input {
  background-color: white !important;
  color: var(--catalyst-gray) !important;
  border-color: #e5e7eb !important;
}

.catalyst-input:focus {
  background-color: white !important;
  border-color: var(--catalyst-teal) !important;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1) !important;
}

/* Ensure dashboard title is visible */
.space-y-6 > div:first-child h1 {
  color: var(--catalyst-blue) !important;
}

/* Fix create organization button */
.space-y-6 a[href*="organizations/create"] {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
}

.space-y-6 a[href*="organizations/create"]:hover {
  background-color: var(--catalyst-blue) !important;
}

/* Final dashboard readability fixes */
.space-y-6 {
  color: var(--catalyst-gray);
}

/* Ensure all headings in the dashboard are the right color */
h1, h2, h3, h4, h5, h6 {
  color: var(--catalyst-blue) !important;
}

/* Fix stat card numbers */
.ml-4 p {
  color: var(--catalyst-blue) !important;
  font-weight: 600;
}

/* Organization role badges */
.px-2.py-1.text-xs.rounded-full {
  font-weight: 500;
}

/* Fix the "View all organizations" link */
a[href*="organizations/list"] {
  color: var(--catalyst-teal) !important;
}

/* Fix notice box text */
.bg-primary-700.bg-opacity-10.border-l-4 p {
  color: var(--catalyst-gray) !important;
}

/* Ensure created date text is visible */
.text-sm.text-gray-500.mt-1 {
  color: var(--catalyst-gray) !important;
}

/* Fix the manage organization button styling */
.px-4.py-2.bg-primary-500,
.bg-primary-500.text-white.px-4.py-2 {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
  font-weight: 500;
  transition: all var(--catalyst-transition-base);
}

.px-4.py-2.bg-primary-500:hover,
.bg-primary-500.text-white.px-4.py-2:hover {
  background-color: var(--catalyst-teal-light) !important;
  color: white !important;
  transform: translateY(-2px);
  box-shadow: var(--catalyst-shadow-md);
}

/* More specific rules for the manage organization button */
a[href*="organizations/detail"].px-4.py-2.bg-primary-500.text-white {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
  font-weight: 500;
  transition: all var(--catalyst-transition-base);
}

a[href*="organizations/detail"].px-4.py-2.bg-primary-500.text-white:hover {
  background-color: var(--catalyst-teal-light) !important;
  color: white !important;
  transform: translateY(-2px);
  box-shadow: var(--catalyst-shadow-md);
}

/* Ensure all primary buttons have proper contrast */
a.bg-primary-500.text-white,
button.bg-primary-500.text-white {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
}

a.bg-primary-500.text-white:hover,
button.bg-primary-500.text-white:hover {
  background-color: var(--catalyst-teal-light) !important;
  color: white !important;
}

/* Ensure no blue on blue text */
.text-primary-400:not(.material-icons):not(.fa) {
  color: var(--catalyst-teal) !important;
}

/* Fix organization stats text */
.bg-primary-700.bg-opacity-10.rounded span {
  color: var(--catalyst-gray) !important;
}

.bg-primary-700.bg-opacity-10.rounded span.text-primary-400 {
  color: var(--catalyst-blue) !important;
  font-weight: 600;
}

/* Fix "No organizations" message */
.text-center.py-4 p {
  color: var(--catalyst-gray) !important;
}

/* Ensure all SVG icons use the right color */
svg.text-primary-400 {
  color: var(--catalyst-teal) !important;
}

/* Tab buttons */
.tab-btn {
  background-color: var(--catalyst-gray-light) !important;
  color: white !important;
  padding: 0.375rem 0.75rem;
  border-radius: var(--catalyst-radius-sm);
  cursor: pointer;
  transition: all var(--catalyst-transition-base);
  border: none;
  font-size: 0.875rem;
}

.tab-btn:hover {
  background-color: var(--catalyst-gray) !important;
  color: white !important;
}

/* Active tab button */
.tab-btn.bg-primary-700,
.tab-btn[onclick*="showTab"]:first-child {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
}

/* Fix any buttons with bg-primary classes */
.bg-primary-700.text-white {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
}

.bg-dark-700 {
  background-color: var(--catalyst-gray-light) !important;
}

/* Ensure all link buttons are readable */
a.btn,
a.btn-primary,
a.btn-secondary,
a[class*="bg-primary"] {
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Fix any remaining button text visibility issues */
button,
.btn,
[class*="btn-"],
input[type="submit"],
input[type="button"],
input[type="reset"] {
  min-height: 2.5rem;
  font-weight: 500 !important;
}

/* Ensure button text is never transparent or too light */
button:not(:disabled),
.btn:not(:disabled),
[class*="btn-"]:not(:disabled) {
  opacity: 1 !important;
}

/* Disabled button state */
button:disabled,
.btn:disabled,
[class*="btn-"]:disabled {
  background-color: var(--catalyst-gray-light) !important;
  color: white !important;
  opacity: 0.6;
  cursor: not-allowed;
}

/* FINAL BUTTON READABILITY GUARANTEE */
/* This section ensures NO button can have unreadable text */

/* Override any button that might have been missed */
button:not(.catalyst-no-style):not(:disabled) {
  color: white !important;
  background-color: var(--catalyst-teal) !important;
}

/* Fix any inline styles or dynamically added classes */
[style*="background-color: white"] button,
[style*="background-color: #fff"] button,
[style*="background-color: rgb(255"] button {
  color: var(--catalyst-blue) !important;
}

/* Ensure gradient buttons always have white text */
.btn-catalyst-gradient {
  color: white !important;
}

/* Fix any buttons with light backgrounds */
button[class*="bg-white"],
button[class*="bg-light"],
.btn[class*="bg-white"],
.btn[class*="bg-light"] {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
}

/* Ensure hover states don't break readability */
button:hover,
.btn:hover,
[class*="btn-"]:hover {
  color: white !important;
}

/* Fix specific problem buttons */
.text-white.bg-white {
  background-color: var(--catalyst-teal) !important;
}

.text-light-100,
.text-light-200,
.text-light-300 {
  color: var(--catalyst-gray) !important;
}

/* When used on buttons, ensure contrast */
button .text-light-100,
button .text-light-200,
button .text-light-300,
.btn .text-light-100,
.btn .text-light-200,
.btn .text-light-300 {
  color: white !important;
}

/* ===== SPECIFIC FIXES FOR MANAGE ORGANIZATION BUTTON ===== */
/* Target the exact button in the dashboard */
.bg-dark-900 .bg-dark-800 .bg-dark-800 .mt-4 .flex .justify-center a[href*="organizations/detail"] {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
  font-weight: 500;
  transition: all var(--catalyst-transition-base);
  border-radius: var(--catalyst-radius-md);
  padding: 0.5rem 1rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bg-dark-900 .bg-dark-800 .bg-dark-800 .mt-4 .flex .justify-center a[href*="organizations/detail"]:hover {
  background-color: var(--catalyst-teal-light) !important;
  color: white !important;
  transform: translateY(-2px);
  box-shadow: var(--catalyst-shadow-md);
}

/* Alternative selector for the manage organization button */
div[class*="bg-dark"] a[href*="organizations/detail"].px-4.py-2.bg-primary-500.text-white {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
  font-weight: 500;
  transition: all var(--catalyst-transition-base);
}

div[class*="bg-dark"] a[href*="organizations/detail"].px-4.py-2.bg-primary-500.text-white:hover {
  background-color: var(--catalyst-teal-light) !important;
  color: white !important;
  transform: translateY(-2px);
  box-shadow: var(--catalyst-shadow-md);
}

/* Ensure no blue text on any button */
a.bg-primary-500,
button.bg-primary-500,
.btn.bg-primary-500 {
  color: white !important;
}

a.bg-primary-500:hover,
button.bg-primary-500:hover,
.btn.bg-primary-500:hover {
  color: white !important;
}

/* Override any potential conflicting styles */
.text-white {
  color: white !important;
}

/* Final override for any remaining issues */
*[class*="bg-primary-500"][class*="text-white"] {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
}

*[class*="bg-primary-500"][class*="text-white"]:hover {
  background-color: var(--catalyst-teal-light) !important;
  color: white !important;
}

/* Also fix bg-primary-600 buttons */
*[class*="bg-primary-600"][class*="text-white"] {
  background-color: var(--catalyst-teal) !important;
  color: white !important;
}

*[class*="bg-primary-600"][class*="text-white"]:hover {
  background-color: var(--catalyst-teal-light) !important;
  color: white !important;
}

/* Ensure hover states for primary-600 work correctly */
.hover\:bg-primary-600:hover {
  background-color: var(--catalyst-teal-light) !important;
}

.hover\:bg-primary-700:hover {
  background-color: var(--catalyst-teal-light) !important;
} 