/* Theme Compatibility - Ensures all elements are visible in both light and dark modes */

/* Base theme variables for consistency */
:root {
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

.dark {
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --border-color: #374151;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

/* Ensure all text elements have proper contrast */
.theme-text {
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.theme-text-secondary {
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.theme-text-muted {
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.theme-bg {
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease;
}

.theme-bg-secondary {
    background-color: var(--bg-secondary);
    transition: background-color 0.3s ease;
}

/* Fix any invisible elements in dark mode */
.dark .invisible-in-dark {
    opacity: 0.9 !important;
    color: #f9fafb !important;
}

.dark .text-gray-900:not(.force-dark) {
    color: #f9fafb !important;
}

.dark .text-gray-800:not(.force-dark) {
    color: #e5e7eb !important;
}

/* Ensure borders are visible in both themes */
.theme-border {
    border-color: var(--border-color);
    transition: border-color 0.3s ease;
}

/* Fix shadow visibility */
.theme-shadow {
    box-shadow: 0 1px 3px 0 var(--shadow-color);
    transition: box-shadow 0.3s ease;
}

.theme-shadow-lg {
    box-shadow: 0 10px 15px -3px var(--shadow-color);
    transition: box-shadow 0.3s ease;
}

/* Button visibility fixes */
.btn-theme {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.btn-theme:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

/* Input field visibility */
.input-theme {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.input-theme::placeholder {
    color: var(--text-muted);
}

/* Card visibility */
.card-theme {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: 0 1px 3px 0 var(--shadow-color);
    transition: all 0.3s ease;
}

/* Navigation visibility */
.nav-theme {
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.nav-theme:hover {
    color: var(--text-primary);
}

.nav-theme.active {
    color: #3b82f6;
    font-weight: 600;
}

/* Link visibility */
.link-theme {
    color: #3b82f6;
    transition: color 0.3s ease;
}

.dark .link-theme {
    color: #60a5fa;
}

.link-theme:hover {
    color: #1d4ed8;
}

.dark .link-theme:hover {
    color: #93c5fd;
}

/* Modal and overlay visibility */
.overlay-theme {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.dark .overlay-theme {
    background-color: rgba(0, 0, 0, 0.7);
}

/* Table visibility fixes */
.table-theme {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.table-theme th {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.table-theme td {
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.table-theme tr:hover {
    background-color: var(--bg-secondary);
}

/* Code block visibility */
.code-theme {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 1rem;
}

/* Dropdown visibility */
.dropdown-theme {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 15px -3px var(--shadow-color);
    border-radius: 0.5rem;
}

.dropdown-theme .dropdown-item {
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    transition: background-color 0.15s ease;
}

.dropdown-theme .dropdown-item:hover {
    background-color: var(--bg-secondary);
}

/* Toast notification visibility */
.toast-theme {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 15px -3px var(--shadow-color);
}

/* Progress bar visibility */
.progress-theme {
    background-color: var(--bg-secondary);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-theme .progress-fill {
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    height: 100%;
    transition: width 0.3s ease;
}

/* Badge visibility */
.badge-theme {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Icon visibility fixes */
.icon-theme {
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.icon-theme:hover {
    color: var(--text-primary);
}

/* Separator visibility */
.separator-theme {
    border-color: var(--border-color);
    transition: border-color 0.3s ease;
}

/* Focus ring visibility */
.focus-theme:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.dark .focus-theme:focus {
    outline-color: #60a5fa;
}

/* Ensure all Tailwind dark mode classes work properly */
.dark .dark\:bg-gray-800 {
    background-color: #1f2937 !important;
}

.dark .dark\:bg-gray-700 {
    background-color: #374151 !important;
}

.dark .dark\:bg-gray-600 {
    background-color: #4b5563 !important;
}

.dark .dark\:text-white {
    color: #ffffff !important;
}

.dark .dark\:text-gray-300 {
    color: #d1d5db !important;
}

.dark .dark\:text-gray-400 {
    color: #9ca3af !important;
}

.dark .dark\:border-gray-700 {
    border-color: #374151 !important;
}

.dark .dark\:border-gray-600 {
    border-color: #4b5563 !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --text-primary: #000000;
        --text-secondary: #333333;
        --bg-primary: #ffffff;
        --border-color: #000000;
    }
    
    .dark {
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
        --bg-primary: #000000;
        --border-color: #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .theme-text,
    .theme-bg,
    .theme-border,
    .theme-shadow,
    .btn-theme,
    .input-theme,
    .card-theme,
    .nav-theme,
    .link-theme {
        transition: none !important;
    }
}