/**
 * Theme Fix - Ensures text is visible in both light and dark modes
 * This file fixes any text visibility issues when switching themes
 */

/* CRITICAL: Prevent flash of white background on load */
html:not(.dark):not(.light) {
    background-color: #020617; /* Default to dark while theme loads */
    color: #f1f5f9;
}

/* Ensure body background changes with theme - FAST */
html {
    transition: background-color 150ms ease, color 150ms ease;
}

/* DARK MODE - Everything Dark */
html.dark {
    background-color: #0f172a !important; /* dark-900 */
    color: #f1f5f9 !important; /* gray-100 */
}

html.dark body {
    background-color: #0f172a !important; /* dark-900 */
    color: #f1f5f9 !important;
}

html.dark main {
    background-color: #0f172a !important; /* dark-900 */
}

/* LIGHT MODE - Everything White */
html:not(.dark) {
    background-color: #ffffff !important; /* white */
    color: #111827 !important; /* gray-900 */
}

html:not(.dark) body {
    background-color: #ffffff !important;
    color: #111827 !important;
}

html:not(.dark) main {
    background-color: #ffffff !important;
}

/* Fix any white text on white background issues */
.text-white {
    color: white !important;
}

html:not(.dark) .dark\:text-white {
    color: #111827 !important; /* Override to gray-900 in light mode */
}

/* Ensure proper text contrast in light mode */
html:not(.dark) {
    /* Gray text variations */
    .text-gray-100 { color: #f3f4f6; }
    .text-gray-200 { color: #e5e7eb; }
    .text-gray-300 { color: #d1d5db; }
    .text-gray-400 { color: #9ca3af; }
    .text-gray-500 { color: #6b7280; }
    .text-gray-600 { color: #4b5563; }
    .text-gray-700 { color: #374151; }
    .text-gray-800 { color: #1f2937; }
    .text-gray-900 { color: #111827; }
}

/* Fix search input text visibility */
html:not(.dark) input[type="text"],
html:not(.dark) input[type="search"],
html:not(.dark) textarea {
    color: #111827; /* gray-900 */
    background-color: #f3f4f6; /* gray-100 */
}

html:not(.dark) input::placeholder,
html:not(.dark) textarea::placeholder {
    color: #9ca3af; /* gray-400 */
}

/* Fix dropdown menu text in light mode */
html:not(.dark) .dropdown-menu,
html:not(.dark) [role="menu"] {
    background-color: white;
    color: #111827;
}

/* Fix table in light mode */
html:not(.dark) .crypto-table {
    background-color: white;
    color: #111827;
}

html:not(.dark) .crypto-table thead {
    background-color: #f9fafb; /* gray-50 */
    border-color: #e5e7eb; /* gray-200 */
}

html:not(.dark) .crypto-table th {
    color: #4b5563; /* gray-600 */
}

html:not(.dark) .crypto-table td {
    color: #111827; /* gray-900 */
}

html:not(.dark) .crypto-table tbody tr {
    border-color: #f3f4f6; /* gray-100 */
}

html:not(.dark) .crypto-table tbody tr:hover {
    background-color: #f9fafb; /* gray-50 */
}

/* Fix card text in light mode */
html:not(.dark) .crypto-card {
    background-color: white;
    color: #111827;
}

/* Fix badge text visibility */
html:not(.dark) .badge-success {
    background-color: #dcfce7; /* green-100 */
    color: #166534; /* green-800 */
}

html:not(.dark) .badge-danger {
    background-color: #fee2e2; /* red-100 */
    color: #991b1b; /* red-800 */
}

/* Fix price indicators */
html:not(.dark) .price-up,
html:not(.dark) .price-positive {
    color: #16a34a !important; /* green-600 */
}

html:not(.dark) .price-down,
html:not(.dark) .price-negative {
    color: #dc2626 !important; /* red-600 */
}

/* Fix navbar in light mode */
html:not(.dark) nav {
    background-color: white;
    border-color: #e5e7eb; /* gray-200 */
}

html:not(.dark) nav a,
html:not(.dark) nav button {
    color: #374151; /* gray-700 */
}

html:not(.dark) nav a:hover,
html:not(.dark) nav button:hover {
    color: #059669; /* crypto-600 */
    background-color: #f3f4f6; /* gray-100 */
}

/* Fix footer in light mode */
html:not(.dark) footer {
    background-color: #f9fafb; /* gray-50 */
    color: #4b5563; /* gray-600 */
}

/* Fix live indicator in light mode */
html:not(.dark) .live-indicator {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #059669; /* green-600 */
}

html:not(.dark) .live-indicator-dot {
    background-color: #10b981; /* green-500 */
}

/* Fix modal/popup backgrounds */
html:not(.dark) .modal,
html:not(.dark) .popup {
    background-color: white;
    color: #111827;
}

/* Fix any remaining contrast issues */
html:not(.dark) h1,
html:not(.dark) h2,
html:not(.dark) h3,
html:not(.dark) h4,
html:not(.dark) h5,
html:not(.dark) h6 {
    color: #111827; /* gray-900 */
}

html:not(.dark) p {
    color: #4b5563; /* gray-600 */
}

html:not(.dark) a {
    color: #059669; /* crypto-600 */
}

html:not(.dark) a:hover {
    color: #047857; /* crypto-700 */
}

/* Fix skeleton loaders */
html:not(.dark) .skeleton {
    background-color: #e5e7eb; /* gray-200 */
}

/* Fix scrollbar in light mode */
html:not(.dark) ::-webkit-scrollbar-track {
    background-color: #f3f4f6; /* gray-100 */
}

html:not(.dark) ::-webkit-scrollbar-thumb {
    background-color: #d1d5db; /* gray-300 */
}

html:not(.dark) ::-webkit-scrollbar-thumb:hover {
    background-color: #9ca3af; /* gray-400 */
}

/* Smooth theme transitions - OPTIMIZED FOR SPEED */
*,
*::before,
*::after {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: ease-in-out;
    transition-duration: 120ms; /* Faster! */
}

/* CRITICAL: Disable ALL transitions during theme switch for instant change */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
    transition: none !important;
    animation: none !important;
}

/* Don't animate these properties - instant feel */
input,
textarea,
select,
button {
    transition-property: background-color, border-color, box-shadow;
    transition-duration: 100ms; /* Even faster for inputs */
}

/* No transitions on these - instant switch */
svg,
img,
.w-8,
.h-8,
.skeleton,
.animate-spin {
    transition: none !important;
}

/* Theme toggle animation */
[x-cloak] {
    display: none !important;
}

.theme-transition {
    transition: all 120ms ease-in-out;
}

/* Fix TradingView chart theme */
html:not(.dark) #tradingview_widget,
html:not(.dark) .tradingview-widget-container {
    background-color: white !important;
}

/* Fix ApexCharts theme */
html:not(.dark) .apexcharts-canvas {
    background: white !important;
}

html:not(.dark) .apexcharts-text {
    fill: #111827 !important;
}

/* Ensure buttons have proper contrast */
html:not(.dark) .btn-primary {
    background-color: #059669;
    color: white;
}

html:not(.dark) .btn-primary:hover {
    background-color: #047857;
}

html:not(.dark) .btn-secondary {
    background-color: #e5e7eb; /* gray-200 */
    color: #111827;
}

html:not(.dark) .btn-secondary:hover {
    background-color: #d1d5db; /* gray-300 */
}

/* Fix form inputs */
html:not(.dark) .input-modern {
    background-color: #f9fafb; /* gray-50 */
    border-color: #e5e7eb; /* gray-200 */
    color: #111827;
}

html:not(.dark) .input-modern:focus {
    border-color: #10b981;
    background-color: white;
}

/* Fix any stats/metrics displays */
html:not(.dark) .stat-item {
    background-color: #f9fafb; /* gray-50 */
    color: #111827;
}

html:not(.dark) .stat-value {
    color: #111827;
}

html:not(.dark) .stat-label {
    color: #6b7280; /* gray-500 */
}

/* ===== FAQ SECTION DARK MODE FIX ===== */
/* Ensure FAQ content text is visible in dark mode */
html.dark .faq-content,
html.dark .faq-content div,
html.dark .faq-content p,
html.dark .faq-content span,
html.dark .faq-content li,
html.dark .faq-content ul,
html.dark .faq-content ol {
    color: #e2e8f0 !important; /* slate-200 - visible white */
}

html.dark .faq-content strong,
html.dark .faq-content b,
html.dark .faq-content h1,
html.dark .faq-content h2,
html.dark .faq-content h3,
html.dark .faq-content h4,
html.dark .faq-content h5,
html.dark .faq-content h6 {
    color: #ffffff !important; /* pure white for emphasis */
}

html.dark .faq-content a {
    color: #4ade80 !important; /* green-400 for links */
}

/* Dark mode prose override for FAQ */
html.dark .prose,
html.dark .prose-sm,
html.dark .dark\:prose-invert {
    color: #e2e8f0 !important;
}

html.dark .prose p,
html.dark .prose-sm p {
    color: #e2e8f0 !important;
}

html.dark .prose strong,
html.dark .prose-sm strong {
    color: #ffffff !important;
}

html.dark .prose li,
html.dark .prose-sm li {
    color: #e2e8f0 !important;
}

/* Ensure text-gray classes show white in dark mode */
html.dark .text-gray-700,
html.dark .text-gray-600,
html.dark .text-gray-500 {
    color: #cbd5e1 !important; /* slate-300 */
}

html.dark .text-gray-300,
html.dark .text-gray-400 {
    color: #e2e8f0 !important; /* slate-200 */
}
