/* Theme-specific fixes for text contrast in dark and light modes */

/* Dark theme text contrast fixes */
[data-bs-theme="dark"] .alert.alert-info {
    color: #000 !important;
    background-color: #d1ecf1 !important;
    border-color: #bee5eb !important;
}

[data-bs-theme="dark"] .alert.alert-warning {
    color: #ffffff !important;
    background-color: #2c2c2c !important;
    background: #2c2c2c !important;
    border-color: #6c757d !important;
    border-width: 1px !important;
}

/* Force override Bootstrap's warning alert colors in dark theme */
[data-bs-theme="dark"] .alert-warning {
    --bs-alert-color: #ffffff !important;
    --bs-alert-bg: #2c2c2c !important;
    --bs-alert-border-color: #6c757d !important;
}

/* Theme-specific warning alert styling for subscription pages - Ultra high specificity */
html[data-bs-theme="dark"] body .container .dark-theme-warning-fix.alert.alert-warning,
html[data-bs-theme="dark"] .dark-theme-warning-fix.alert.alert-warning,
[data-bs-theme="dark"] .dark-theme-warning-fix.alert-warning {
    background: #2c2c2c !important;
    background-color: #2c2c2c !important;
    background-image: none !important;
    border: 1px solid #6c757d !important;
    border-color: #6c757d !important;
    color: #ffffff !important;
    --bs-alert-bg: #2c2c2c !important;
    --bs-alert-color: #ffffff !important;
    --bs-alert-border-color: #6c757d !important;
}

html[data-bs-theme="light"] body .container .dark-theme-warning-fix.alert.alert-warning,
html[data-bs-theme="light"] .dark-theme-warning-fix.alert.alert-warning,
[data-bs-theme="light"] .dark-theme-warning-fix.alert-warning {
    background: #fff3cd !important;
    background-color: #fff3cd !important;
    border: 1px solid #ffecb5 !important;
    border-color: #ffecb5 !important;
    color: #664d03 !important;
    --bs-alert-bg: #fff3cd !important;
    --bs-alert-color: #664d03 !important;
    --bs-alert-border-color: #ffecb5 !important;
}

[data-bs-theme="dark"] .alert.alert-success {
    color: #000 !important;
    background-color: #d4edda !important;
    border-color: #c3e6cb !important;
}

/* Instruction text and muted text fixes */
[data-bs-theme="dark"] .form-text,
[data-bs-theme="dark"] .text-muted,
[data-bs-theme="dark"] .text-secondary {
    color: #adb5bd !important;
}

[data-bs-theme="dark"] small.text-muted,
[data-bs-theme="dark"] small.form-text {
    color: #adb5bd !important;
}

/* Light theme - ensure dark text on alert backgrounds */
[data-bs-theme="light"] .alert.alert-info {
    color: #055160 !important;
}

[data-bs-theme="light"] .alert.alert-warning {
    color: #664d03 !important;
}

[data-bs-theme="light"] .alert.alert-success {
    color: #0f5132 !important;
}

/* Code elements contrast */
[data-bs-theme="dark"] code {
    background-color: #f8f9fa !important;
    color: #212529 !important;
    padding: 2px 4px !important;
    border-radius: 3px !important;
}

[data-bs-theme="light"] code {
    background-color: #f8f9fa;
    color: #212529;
}

/* Form labels and text */
[data-bs-theme="dark"] .form-label {
    color: #fff !important;
}

[data-bs-theme="dark"] .form-check-label {
    color: #fff !important;
}

/* Breadcrumb text */
[data-bs-theme="dark"] .breadcrumb-item + .breadcrumb-item::before {
    color: #6c757d;
}

/* Enhanced styling for warning alerts in dark theme (subscription cancellation/reactivation) */
[data-bs-theme="dark"] .alert.alert-warning .btn-success {
    background-color: #198754 !important;
    border-color: #198754 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .alert.alert-warning .btn-success:hover {
    background-color: #157347 !important;
    border-color: #146c43 !important;
}

/* Warning icon color fix for dark theme */
[data-bs-theme="dark"] .alert.alert-warning .fas.fa-exclamation-triangle {
    color: #ffc107 !important;
}

/* AUTH PAGES TEXT VISIBILITY FIX */
.login-container .form-label,
.login-container label {
    color: #1F2937 !important;
    font-weight: 600 !important;
}

.login-container .form-input,
.login-container input[type="text"],
.login-container input[type="email"],
.login-container input[type="password"] {
    color: #1F2937 !important;
    background-color: #ffffff !important;
}

.login-container .login-title {
    color: #1e3a8a !important;
}

.login-container .login-subtitle {
    color: #4B5563 !important;
}

.login-container input::placeholder {
    color: #6B7280 !important;
}

/* Table text */
[data-bs-theme="dark"] .table td,
[data-bs-theme="dark"] .table th {
    color: #fff;
}

/* Badge text contrast */
[data-bs-theme="dark"] .badge {
    color: #000 !important;
}

/* Help text and instructions */
[data-bs-theme="dark"] .help-text,
[data-bs-theme="dark"] .instruction-text {
    color: #adb5bd !important;
}

/* List items in instruction contexts */
[data-bs-theme="dark"] ul li,
[data-bs-theme="dark"] ol li {
    color: inherit;
}

/* Modal text */
[data-bs-theme="dark"] .modal-body {
    color: #fff;
}

/* Alert link colors */
[data-bs-theme="dark"] .alert-link {
    color: #0d6efd !important;
}

[data-bs-theme="light"] .alert-link {
    color: #0d6efd !important;
}

/* Professional alert styling for login and authentication errors */
.alert {
    border-radius: 8px !important;
    border: none !important;
    font-weight: 500 !important;
    margin-bottom: 1.5rem !important;
    padding: 1rem 1.5rem !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c2c7 100%) !important;
    color: #721c24 !important;
    border-left: 4px solid #dc3545 !important;
}

.alert-success {
    background: linear-gradient(135deg, #d1e7dd 0%, #badbcc 100%) !important;
    color: #0f5132 !important;
    border-left: 4px solid #198754 !important;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffecb5 100%) !important;
    color: #664d03 !important;
    border-left: 4px solid #ffc107 !important;
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #b8daff 100%) !important;
    color: #055160 !important;
    border-left: 4px solid #0dcaf0 !important;
}

/* Dark theme alert adjustments */
[data-bs-theme="dark"] .alert-danger {
    background: linear-gradient(135deg, #3d1a1b 0%, #4a1e20 100%) !important;
    color: #f8d7da !important;
    border-left: 4px solid #dc3545 !important;
}

[data-bs-theme="dark"] .alert-success {
    background: linear-gradient(135deg, #1a3d2e 0%, #1e4a35 100%) !important;
    color: #d1e7dd !important;
    border-left: 4px solid #198754 !important;
}

[data-bs-theme="dark"] .alert-warning {
    background: linear-gradient(135deg, #3d3a1a 0%, #4a441e 100%) !important;
    color: #fff3cd !important;
    border-left: 4px solid #ffc107 !important;
    opacity: 1 !important;
}

[data-bs-theme="dark"] .alert-info {
    background: linear-gradient(135deg, #1a3d42 0%, #1e4a50 100%) !important;
    color: #d1ecf1 !important;
    border-left: 4px solid #0dcaf0 !important;
}

/* Payment reminder and alert text fixes */
[data-bs-theme="dark"] .alert p,
[data-bs-theme="dark"] .alert div {
    color: inherit !important;
}

[data-bs-theme="light"] .alert p,
[data-bs-theme="light"] .alert div {
    color: inherit !important;
}

/* Specific fix for payment reminder text */
[data-bs-theme="dark"] .alert.alert-info p {
    color: #000 !important;
}

[data-bs-theme="light"] .alert.alert-info p {
    color: #055160 !important;
}

/* Payment reminder card fix */
[data-bs-theme="dark"] .card.bg-light .card-title,
[data-bs-theme="dark"] .card.bg-light .card-text,
[data-bs-theme="dark"] .card.bg-light small {
    color: #000 !important;
}

[data-bs-theme="light"] .card.bg-light .card-title,
[data-bs-theme="light"] .card.bg-light .card-text,
[data-bs-theme="light"] .card.bg-light small {
    color: #000 !important;
}

/* Ensure strong text remains visible */
[data-bs-theme="dark"] strong {
    color: inherit;
}

/* Card text */
[data-bs-theme="dark"] .card-text {
    color: #fff;
}

[data-bs-theme="dark"] .card-body p {
    color: #fff;
}

/* Navigation breadcrumbs */
[data-bs-theme="dark"] .breadcrumb-item a {
    color: #0d6efd;
}

[data-bs-theme="dark"] .breadcrumb-item.active {
    color: #6c757d;
}

/* Force banner visibility for dark theme with very specific selectors */
[data-bs-theme="dark"] .alert.alert-warning {
    background: #856404 !important;
    background-color: #856404 !important;
    color: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    border-radius: 8px !important;
    opacity: 1 !important;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3) !important;
}

[data-bs-theme="dark"] .alert.alert-warning * {
    color: #fff3cd !important;
}

[data-bs-theme="dark"] .alert.alert-warning strong {
    color: #fff !important;
    font-weight: 600 !important;
}

[data-bs-theme="dark"] .alert.alert-warning small {
    color: #fff3cd !important;
}

[data-bs-theme="dark"] .alert.alert-warning .alert-link,
[data-bs-theme="dark"] .alert.alert-warning a {
    color: #87ceeb !important;
    text-decoration: underline !important;
    font-weight: 500 !important;
}

[data-bs-theme="dark"] .alert.alert-warning .alert-link:hover,
[data-bs-theme="dark"] .alert.alert-warning a:hover {
    color: #add8e6 !important;
}

[data-bs-theme="dark"] .alert.alert-warning i,
[data-bs-theme="dark"] .alert.alert-warning .fas,
[data-bs-theme="dark"] .alert.alert-warning .fa-exclamation-triangle,
[data-bs-theme="dark"] .alert.alert-warning i.fas,
[data-bs-theme="dark"] .alert.alert-warning i.fa-exclamation-triangle {
    color: #fff !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: inline !important;
}

/* Very specific override for the warning icon in dashboard */
html[data-bs-theme="dark"] .alert.alert-warning .fas.fa-exclamation-triangle.me-2,
html[data-bs-theme="dark"] .alert.alert-warning i.fas.fa-exclamation-triangle.me-2 {
    color: #ffc107 !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: inline !important;
}

/* Border-left warning styling for consistent banner appearance */
.border-left-warning {
    border-left: 4px solid #ffc107 !important;
}

[data-bs-theme="dark"] .border-left-warning {
    border-left: 4px solid #ffc107 !important;
}

/* Info alert improvements */
[data-bs-theme="dark"] .alert.alert-info {
    background: #0c5460 !important;
    background-color: #0c5460 !important;
    color: #b3d4fc !important;
    border: 2px solid #0dcaf0 !important;
    border-radius: 8px !important;
    opacity: 1 !important;
    box-shadow: 0 4px 12px rgba(13, 202, 240, 0.3) !important;
}

[data-bs-theme="dark"] .alert.alert-info * {
    color: #b3d4fc !important;
}

[data-bs-theme="dark"] .alert.alert-info strong {
    color: #fff !important;
    font-weight: 600 !important;
}

/* Settlement strategies report dark theme fixes - Fix white backgrounds */
[data-bs-theme="dark"] .bg-light {
    background-color: #2c2c2c !important;
    background: #2c2c2c !important;
    color: #ffffff !important;
    border-color: #6c757d !important;
}

[data-bs-theme="dark"] .bg-light .text-muted {
    color: #adb5bd !important;
}

[data-bs-theme="dark"] .bg-light small.text-muted {
    color: #adb5bd !important;
}

/* Fix bg-light-subtle for dark theme - mobile creditor cards */
[data-bs-theme="dark"] .bg-light-subtle {
    background-color: #2c2c2c !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .bg-light-subtle .fw-bold {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .bg-light-subtle small {
    color: #adb5bd !important;
}

/* Fix Bootstrap CSS variables for bg-subtle classes in dark theme */
[data-bs-theme="dark"] {
    --bs-light-bg-subtle: #2c2c2c !important;
    --bs-danger-bg-subtle: #2c1618 !important;
    --bs-warning-bg-subtle: #332701 !important;
}

/* Ensure text remains visible on subtle backgrounds */
[data-bs-theme="dark"] .fw-semibold {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #adb5bd !important;
}

/* Fix table row warning styling in dark theme */
[data-bs-theme="dark"] .table-warning {
    background-color: #404040 !important;
    color: #ffffff !important;
    border-color: #ffc107 !important;
}

[data-bs-theme="dark"] .table-warning td {
    background-color: #404040 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .table-warning th {
    background-color: #404040 !important;
    color: #ffffff !important;
}

/* Ensure text in warning table rows remains visible */
[data-bs-theme="dark"] .table-warning strong {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .table-warning .text-muted {
    color: #adb5bd !important;
}

/* Ultra-specific override for table hover - prevent any color change on warning rows */
html[data-bs-theme="dark"] .table.table-hover tbody tr.table-warning:hover,
html[data-bs-theme="dark"] .table-hover tbody tr.table-warning:hover,
[data-bs-theme="dark"] .table.table-hover tbody .table-warning:hover,
[data-bs-theme="dark"] .table-hover tbody .table-warning:hover {
    background-color: #404040 !important;
}

html[data-bs-theme="dark"] .table.table-hover tbody tr.table-warning:hover td,
html[data-bs-theme="dark"] .table-hover tbody tr.table-warning:hover td,
[data-bs-theme="dark"] .table.table-hover tbody .table-warning:hover td,
[data-bs-theme="dark"] .table-hover tbody .table-warning:hover td {
    background-color: #404040 !important;
}

/* Disable default table hover on warning rows completely */
[data-bs-theme="dark"] .table-hover tbody tr.table-warning:hover {
    background-color: #404040 !important;
    --bs-table-hover-bg: #404040 !important;
}

/* Fix mobile card warning styling in dark theme */
[data-bs-theme="dark"] .mobile-card.border-warning {
    background-color: #404040 !important;
    border-color: #ffc107 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .mobile-card.border-warning .card-title {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .mobile-card.border-warning .text-muted {
    color: #adb5bd !important;
}

/* Payment reminder card styling for theme compatibility */
.payment-reminder-card {
    background-color: rgba(13, 110, 253, 0.1) !important;
    border: 1px solid rgba(13, 110, 253, 0.3) !important;
}

.payment-reminder-title {
    color: #0d6efd !important;
    font-weight: 600 !important;
}

.payment-reminder-text {
    color: #6c757d !important;
}

/* Dark theme overrides for payment reminder */
[data-bs-theme="dark"] .payment-reminder-card {
    background-color: rgba(13, 110, 253, 0.2) !important;
    border: 1px solid rgba(13, 110, 253, 0.5) !important;
}

[data-bs-theme="dark"] .payment-reminder-title {
    color: #6ea8fe !important;
}

[data-bs-theme="dark"] .payment-reminder-text {
    color: #adb5bd !important;
}