/**
 * Text Color Standardization for Dark Theme
 * 
 * This file overrides Bootstrap's text color classes to ensure readability
 * in both light and dark themes.
 * 
 * Problem: Classes like 'text-dark' and 'text-muted' are unreadable on dark backgrounds
 * Solution: Override these classes to use theme-aware colors
 */

/* Main Text Colors - Override Bootstrap defaults */
.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

.text-muted {
    color: var(--text-muted, #94a3b8) !important;
    opacity: 1;
}

.text-black {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Form Labels */
.form-label {
    color: var(--text-primary, #f1f5f9);
}

.form-label.fw-semibold,
.form-label.fw-bold {
    color: var(--text-primary, #f1f5f9);
}

/* Headings - h1 to h6 */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--text-primary, #f1f5f9);
}

h1.text-dark, h2.text-dark, h3.text-dark, h4.text-dark, h5.text-dark, h6.text-dark,
h1.fw-bold, h2.fw-bold, h3.fw-bold, h4.fw-bold, h5.fw-bold, h6.fw-bold {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Small Text & Descriptions */
small {
    color: var(--text-secondary, #cbd5e1);
}

small.text-muted {
    color: var(--text-muted, #94a3b8) !important;
    opacity: 1;
}

/* Paragraph Text */
p.text-muted {
    color: var(--text-muted, #94a3b8) !important;
    opacity: 1;
}

/* Stat/Counter Numbers */
.fw-bold.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Stats Card Text */
.card-body .text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

.card-body .text-muted {
    color: var(--text-muted, #94a3b8) !important;
}

/* Filter Section Text */
.form-label.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Title/Name Text in Cards */
.fw-semibold.text-dark,
.fw-bold.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Badge with text-dark (community score, etc) */
.badge.text-dark {
    color: #0f172a !important; /* Keep dark for badges as they have light backgrounds */
}

.badge.bg-warning.text-dark {
    color: #0f172a !important; /* Keep dark for warning badges */
}

.badge.bg-info.text-dark {
    color: #0f172a !important; /* Keep dark for info badges */
}

.badge.bg-light.text-dark {
    color: #0f172a !important; /* Keep dark for light badges */
}

/* Span text in stats/progress */
span.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

span.fw-bold.text-dark,
span.fw-semibold.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Empty State Text */
.text-center .text-dark,
.text-center .text-muted {
    color: var(--text-primary, #f1f5f9) !important;
}

.text-center .text-muted {
    color: var(--text-muted, #94a3b8) !important;
}

/* Icon muted color */
.fa.text-muted,
.fas.text-muted,
.far.text-muted,
.fab.text-muted {
    color: var(--text-muted, #94a3b8) !important;
    opacity: 0.8;
}

/* Ensure links don't inherit text-dark */
a.text-dark:hover,
a.text-dark:focus {
    color: var(--text-link, #818cf8) !important;
}

/* List items */
ul.text-muted li,
ul.text-muted {
    color: var(--text-muted, #94a3b8) !important;
}

/* Divider text */
.fw-semibold.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Friend/User Names */
.fw-semibold.text-dark,
div.fw-semibold.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Specific fixes for profile list pages */
.card .fw-bold.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

.card .text-muted {
    color: var(--text-muted, #94a3b8) !important;
}

/* Progress/Stats Numbers */
.card-body span.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Filter labels */
label.fw-semibold.text-dark,
label.fw-bold.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Section Headers */
h5.fw-bold.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Author/Creator text */
span.text-dark[style*="font-size"] {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Synopsis/Description text */
p.text-muted[style*="cursor: help"],
p.text-muted[title] {
    color: var(--text-muted, #94a3b8) !important;
}

/* Item titles in lists */
h5.fw-bold.text-dark[title],
h6.fw-bold.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

/* Stats counters */
.text-center .fw-bold.text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

.text-center small.text-muted {
    color: var(--text-muted, #94a3b8) !important;
}

/* Privacy Policy & Static Pages */
.privacy-policy .text-dark,
.terms-service .text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

.privacy-policy .text-muted,
.terms-service .text-muted {
    color: var(--text-muted, #94a3b8) !important;
}

/* Account Settings */
.account-settings .text-muted {
    color: var(--text-muted, #94a3b8) !important;
}

/* Maintenance Page */
.maintenance .text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

.maintenance .text-muted {
    color: var(--text-muted, #94a3b8) !important;
}

/* Game/Anime/Manga List Items */
.list-item h6.text-dark,
.list-item .text-dark {
    color: var(--text-primary, #f1f5f9) !important;
}

.list-item .text-muted {
    color: var(--text-muted, #94a3b8) !important;
}

/* Stats Grid in Manga/Anime/Game Cards - Volume/Chapter/Episode badges */
.d-flex.gap-3 .d-flex.align-items-center[style*="background: linear-gradient"] .text-dark,
.d-flex.gap-3 .d-flex.align-items-center[style*="background: linear-gradient"] span.text-dark,
.d-flex.gap-3 .d-flex.align-items-center[style*="background: linear-gradient"] .fw-bold.text-dark {
    color: #1e293b !important; /* Dark color for light gradient backgrounds */
}

.d-flex.gap-3 .d-flex.align-items-center[style*="background: linear-gradient"] .text-muted,
.d-flex.gap-3 .d-flex.align-items-center[style*="background: linear-gradient"] small.text-muted {
    color: #475569 !important; /* Medium dark for light gradient backgrounds */
    opacity: 1;
}

/* Responsive: Ensure consistency on mobile */
@media (max-width: 768px) {
    .text-dark,
    .fw-bold.text-dark,
    .fw-semibold.text-dark {
        color: var(--text-primary, #f1f5f9) !important;
    }
    
    .text-muted,
    small.text-muted {
        color: var(--text-muted, #94a3b8) !important;
    }
    
    /* Stats Grid badges on mobile - keep dark text on light backgrounds */
    .d-flex.gap-3 .d-flex.align-items-center[style*="background: linear-gradient"] .text-dark,
    .d-flex.gap-3 .d-flex.align-items-center[style*="background: linear-gradient"] span.text-dark,
    .d-flex.gap-3 .d-flex.align-items-center[style*="background: linear-gradient"] .fw-bold.text-dark {
        color: #1e293b !important;
    }
    
    .d-flex.gap-3 .d-flex.align-items-center[style*="background: linear-gradient"] .text-muted,
    .d-flex.gap-3 .d-flex.align-items-center[style*="background: linear-gradient"] small.text-muted {
        color: #475569 !important;
    }
}

/* ================== AUTOFILL FIX - GENERIC FOR ALL INPUTS ================== */

/**
 * Browser Autofill Fix
 * 
 * Problem: When browser autofills or user pastes values, Chrome/Edge/Safari apply
 * a forced white/yellow background that breaks dark theme styling
 * 
 * Solution: Override autofill styles for both light and dark themes
 */

/* Dark Theme Autofill Fix */
.theme-indigo-dark input:-webkit-autofill,
.theme-indigo-dark input:-webkit-autofill:hover,
.theme-indigo-dark input:-webkit-autofill:focus,
.theme-indigo-dark input:-webkit-autofill:active,
.theme-indigo-dark textarea:-webkit-autofill,
.theme-indigo-dark textarea:-webkit-autofill:hover,
.theme-indigo-dark textarea:-webkit-autofill:focus,
.theme-indigo-dark textarea:-webkit-autofill:active,
.theme-indigo-dark select:-webkit-autofill,
.theme-indigo-dark select:-webkit-autofill:hover,
.theme-indigo-dark select:-webkit-autofill:focus,
.theme-indigo-dark select:-webkit-autofill:active {
    -webkit-text-fill-color: #f1f5f9 !important;
    -webkit-box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.8) inset !important;
    box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.8) inset !important;
    background-color: rgba(15, 23, 42, 0.8) !important;
    border-color: rgba(51, 65, 85, 0.8) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Dark Theme Autofill on Focus */
.theme-indigo-dark input:-webkit-autofill:focus,
.theme-indigo-dark textarea:-webkit-autofill:focus,
.theme-indigo-dark select:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.95) inset, 0 0 0 4px rgba(99, 102, 241, 0.2) !important;
    box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.95) inset, 0 0 0 4px rgba(99, 102, 241, 0.2) !important;
    border-color: #6366f1 !important;
}

/* Light Theme Autofill Fix */
.theme-indigo-light input:-webkit-autofill,
.theme-indigo-light input:-webkit-autofill:hover,
.theme-indigo-light input:-webkit-autofill:focus,
.theme-indigo-light input:-webkit-autofill:active,
.theme-indigo-light textarea:-webkit-autofill,
.theme-indigo-light textarea:-webkit-autofill:hover,
.theme-indigo-light textarea:-webkit-autofill:focus,
.theme-indigo-light textarea:-webkit-autofill:active,
.theme-indigo-light select:-webkit-autofill,
.theme-indigo-light select:-webkit-autofill:hover,
.theme-indigo-light select:-webkit-autofill:focus,
.theme-indigo-light select:-webkit-autofill:active {
    -webkit-text-fill-color: #1e293b !important;
    -webkit-box-shadow: 0 0 0 1000px #f8fafc inset !important;
    box-shadow: 0 0 0 1000px #f8fafc inset !important;
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Light Theme Autofill on Focus */
.theme-indigo-light input:-webkit-autofill:focus,
.theme-indigo-light textarea:-webkit-autofill:focus,
.theme-indigo-light select:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px white inset, 0 0 0 4px rgba(102, 126, 234, 0.15) !important;
    box-shadow: 0 0 0 1000px white inset, 0 0 0 4px rgba(102, 126, 234, 0.15) !important;
    border-color: #667eea !important;
}

/* Generic fix for pages without theme class (fallback to dark) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
textarea:-webkit-autofill:active,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus,
select:-webkit-autofill:active {
    -webkit-text-fill-color: #f1f5f9 !important;
    -webkit-box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.8) inset !important;
    box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.8) inset !important;
    background-color: rgba(15, 23, 42, 0.8) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Firefox Autofill Fix */
.theme-indigo-dark input:-moz-autofill,
.theme-indigo-dark textarea:-moz-autofill,
.theme-indigo-dark select:-moz-autofill {
    background-color: rgba(15, 23, 42, 0.8) !important;
    color: #f1f5f9 !important;
}

.theme-indigo-light input:-moz-autofill,
.theme-indigo-light textarea:-moz-autofill,
.theme-indigo-light select:-moz-autofill {
    background-color: #f8fafc !important;
    color: #1e293b !important;
}
