/**
 * TEXT VISIBILITY FIX
 * Fixes white text on white background issues across the application
 * Created: October 4, 2025
 */

/* ==========================
   GLOBAL TEXT COLOR FIXES
   ========================== */

/* Ensure body has dark text by default */
body {
  color: #1f2937 !important;
}

/* Override any white text that doesn't have a dark background */
.text-white:not(.bg-primary):not(.bg-success):not(.bg-info):not(.bg-warning):not(.bg-danger):not(.bg-dark):not(.bg-secondary):not([class*="bg-gradient"]):not([style*="background"]) {
  color: #1f2937 !important;
}

/* ==========================
   SPECIFIC ELEMENT FIXES
   ========================== */

/* Fix white links on white backgrounds */
a.text-white {
  color: #172a74 !important;
  text-decoration: underline;
}

a.text-white:hover {
  color: #21a9af !important;
}

/* Fix paragraph and heading text */
p, h1, h2, h3, h4, h5, h6,
span, div, td, th, li, label {
  color: inherit;
}

/* Ensure dark text on light backgrounds */
.bg-white p,
.bg-white h1, .bg-white h2, .bg-white h3,
.bg-white h4, .bg-white h5, .bg-white h6,
.bg-white span, .bg-white div,
.bg-white td, .bg-white th, .bg-white li,
.bg-white label, .bg-white a {
  color: #1f2937 !important;
}

.bg-light p,
.bg-light h1, .bg-light h2, .bg-light h3,
.bg-light h4, .bg-light h5, .bg-light h6,
.bg-light span, .bg-light div,
.bg-light td, .bg-light th, .bg-light li,
.bg-light label {
  color: #1f2937 !important;
}

/* ==========================
   CARD FIXES
   ========================== */

/* Cards without colored backgrounds should have dark text */
.card:not(.bg-primary):not(.bg-success):not(.bg-info):not(.bg-warning):not(.bg-danger):not(.bg-dark) {
  color: #1f2937 !important;
}

.card:not(.bg-primary):not(.bg-success):not(.bg-info):not(.bg-warning):not(.bg-danger):not(.bg-dark) .card-title,
.card:not(.bg-primary):not(.bg-success):not(.bg-info):not(.bg-warning):not(.bg-danger):not(.bg-dark) .card-text,
.card:not(.bg-primary):not(.bg-success):not(.bg-info):not(.bg-warning):not(.bg-danger):not(.bg-dark) p,
.card:not(.bg-primary):not(.bg-success):not(.bg-info):not(.bg-warning):not(.bg-danger):not(.bg-dark) span {
  color: #1f2937 !important;
}

/* Card headers with colored backgrounds keep white text */
.card-header.bg-primary,
.card-header.bg-success,
.card-header.bg-info,
.card-header.bg-warning,
.card-header.bg-danger,
.card-header.bg-dark,
.card-header.bg-secondary {
  color: white !important;
}

.card-header.bg-primary *,
.card-header.bg-success *,
.card-header.bg-info *,
.card-header.bg-danger *,
.card-header.bg-dark *,
.card-header.bg-secondary * {
  color: white !important;
}

/* Warning backgrounds need dark text */
.card-header.bg-warning,
.card-header.bg-warning * {
  color: #1f2937 !important;
}

/* ==========================
   FORM ELEMENT FIXES
   ========================== */

/* Form inputs and labels */
input, textarea, select {
  color: #1f2937 !important;
}

input::placeholder,
textarea::placeholder {
  color: #6b7280 !important;
}

label {
  color: #1f2937 !important;
}

.form-control {
  color: #1f2937 !important;
  background-color: #ffffff !important;
}

.form-control:focus {
  color: #1f2937 !important;
}

/* ==========================
   TABLE FIXES
   ========================== */

table {
  color: #1f2937 !important;
}

thead th {
  color: #1f2937 !important;
}

tbody td {
  color: #1f2937 !important;
}

/* Dark table variants keep white text */
.table-dark,
.table-dark th,
.table-dark td {
  color: white !important;
}

/* ==========================
   BUTTON FIXES
   ========================== */

/* Buttons with dark backgrounds keep white text */
.btn-primary,
.btn-success,
.btn-info,
.btn-danger,
.btn-dark,
.btn-secondary {
  color: white !important;
}

/* Warning button needs dark text for contrast */
.btn-warning {
  color: #1f2937 !important;
}

/* Light buttons need dark text */
.btn-light,
.btn-outline-primary,
.btn-outline-secondary {
  color: #1f2937 !important;
}

/* ==========================
   LIST FIXES
   ========================== */

ul, ol {
  color: #1f2937 !important;
}

li {
  color: inherit;
}

/* ==========================
   MODAL FIXES
   ========================== */

.modal-body {
  color: #1f2937 !important;
}

.modal-body p,
.modal-body span,
.modal-body div:not(.bg-primary):not(.bg-success):not(.bg-info):not(.bg-danger) {
  color: #1f2937 !important;
}

/* Glassmorphism modals with dark backgrounds keep white text */
.glassmorphism-modal,
.glassmorphism-modal * {
  color: white !important;
}

/* Modal headers with colored backgrounds */
.modal-header.bg-primary,
.modal-header.bg-success,
.modal-header.bg-info,
.modal-header.bg-danger,
.modal-header.bg-dark {
  color: white !important;
}

.modal-header.bg-primary *,
.modal-header.bg-success *,
.modal-header.bg-info *,
.modal-header.bg-danger *,
.modal-header.bg-dark * {
  color: white !important;
}

/* ==========================
   ALERT FIXES
   ========================== */

.alert {
  color: #1f2937 !important;
}

.alert-primary {
  color: #172a74 !important;
  background-color: #e0e7ff !important;
}

.alert-success {
  color: #065f46 !important;
  background-color: #d1fae5 !important;
}

.alert-info {
  color: #075985 !important;
  background-color: #e0f2fe !important;
}

.alert-warning {
  color: #92400e !important;
  background-color: #fef3c7 !important;
}

.alert-danger {
  color: #991b1b !important;
  background-color: #fee2e2 !important;
}

/* ==========================
   BADGE FIXES
   ========================== */

/* Badges with dark backgrounds keep white text */
.badge-primary,
.badge-success,
.badge-info,
.badge-danger,
.badge-dark,
.badge-secondary {
  color: white !important;
}

.badge-warning,
.badge-light {
  color: #1f2937 !important;
}

/* ==========================
   NAVBAR FIXES (Exceptions)
   ========================== */

/* Header navigation keeps white text */
.header-blue,
.header-blue * {
  color: white !important;
}

.header-blue .navbar-brand,
.header-blue .nav-link,
.header-blue .navbar-text {
  color: white !important;
}

/* Language dropdown button needs dark text (on light background) */
#languageDropdown,
.lang-dropdown-btn {
  color: #1f2937 !important;
  background: rgba(255, 255, 255, 0.95) !important;
}

#languageDropdown:hover,
.lang-dropdown-btn:hover {
  color: #172a74 !important;
  background: #ffffff !important;
}

/* Navbar icon buttons in header keep white icons */
.header-blue .btn-light,
.header-blue .btn-light i,
.header-blue .btn-light .fa,
.header-blue .btn-light .fas,
.header-blue .btn-outline-light,
.header-blue .btn-outline-light i,
.header-blue .btn-outline-light .fa,
.header-blue .btn-outline-light .fas {
  color: white !important;
}

/* But dropdowns in header should have dark text */
.header-blue .dropdown-menu,
.header-blue .dropdown-item {
  color: #1f2937 !important;
}

.header-blue .dropdown-item:hover {
  color: white !important;
  background: linear-gradient(135deg, #172a74, #21a9af) !important;
}

/* ==========================
   DASHBOARD SIDEBAR FIXES
   ========================== */

/* Sidebars with gradient backgrounds keep white text */
.sidebar,
.booking-sidebar,
.dashboard-page .sidebar,
.admin-sidebar {
  color: white !important;
}

.sidebar *,
.booking-sidebar *,
.dashboard-page .sidebar *,
.admin-sidebar * {
  color: white !important;
}

/* Admin sidebar links */
.admin-sidebar .list-group-item,
.admin-sidebar .list-group-item i,
.admin-sidebar .list-group-item:hover,
.admin-sidebar .list-group-item.active {
  color: white !important;
}

/* ==========================
   COURIER DASHBOARD FIXES
   ========================== */

/* Courier navbar with gradient background keeps white text */
.navbar {
  color: white !important;
}

.navbar *,
.navbar .navbar-brand,
.navbar .nav-link,
.navbar .nav-link i {
  color: white !important;
}

/* Courier company info section with gradient background keeps white text */
.company-info,
.company-info * {
  color: white !important;
}

/* Dashboard cards with white backgrounds have dark text */
.dashboard-card {
  color: #1f2937 !important;
  background: white !important;
}

.dashboard-card h5,
.dashboard-card p,
.dashboard-card .card-icon,
.dashboard-card .text-muted {
  color: inherit !important;
}

/* Welcome section with white background has dark text */
.welcome-section {
  color: #1f2937 !important;
}

.welcome-section h4,
.welcome-section p,
.welcome-section * {
  color: #1f2937 !important;
}

/* Request cards with white background have dark text */
.request-card {
  color: #1f2937 !important;
}

.request-card h6,
.request-card p,
.request-card strong {
  color: #333 !important;
}

/* Preserve colored stat values */
.stat-value {
  color: inherit !important;
}

.text-primary {
  color: #172a74 !important;
}

.text-success {
  color: #28a745 !important;
}

.text-warning {
  color: #d97706 !important;
}

.text-info {
  color: #21a9af !important;
}

/* Buttons keep their white text */
.btn-dashboard,
.btn-success,
.btn-danger {
  color: white !important;
}

.btn-dashboard *,
.btn-success *,
.btn-danger * {
  color: white !important;
}

/* ==========================
   FOOTER FIXES
   ========================== */

.footer,
.footer * {
  color: rgba(255, 255, 255, 0.8) !important;
}

.footer h3,
.footer h4,
.footer h5 {
  color: white !important;
}

/* ==========================
   STATUS BADGE FIXES
   ========================== */

.status-pill {
  color: inherit;
}

.status-pending {
  color: #92400e !important;
}

.status-accepted,
.status-on_the_way {
  color: #172a74 !important;
}

.status-in_progress,
.status-completed {
  color: #065f46 !important;
}

.status-cancelled {
  color: #991b1b !important;
}

/* ==========================
   OVERRIDE INLINE STYLES
   ========================== */

/* Force visible text on common containers */
.container,
.container-fluid,
.row,
.col,
[class*="col-"] {
  color: inherit;
}

/* Ensure divs without background have dark text */
div:not([class*="bg-"]):not([class*="gradient"]):not(.header-blue):not(.sidebar):not(.footer) {
  color: #1f2937;
}

/* ==========================
   ADDITIONAL UTILITY CLASSES
   ========================== */

.text-dark-important {
  color: #1f2937 !important;
}

.text-visible {
  color: #1f2937 !important;
}

.text-readable {
  color: #1f2937 !important;
  font-weight: 500;
}

/* ==========================
   HIGH SPECIFICITY OVERRIDES
   ========================== */

/* Nuclear option for stubborn white text */
body *:not(.header-blue *):not(.sidebar *):not(.footer *):not(.bg-primary *):not(.bg-success *):not(.bg-info *):not(.bg-danger *):not(.bg-dark *):not(.bg-secondary *):not(.badge-primary):not(.badge-success):not(.badge-info):not(.badge-danger):not(.btn-primary):not(.btn-success):not(.btn-info):not(.btn-danger):not(.btn-dark):not(.glassmorphism-modal *) {
  color: #1f2937;
}

/* Whitelist: These elements should keep white text */
.bg-primary,
.bg-primary *,
.bg-success,
.bg-success *,
.bg-info,
.bg-info *,
.bg-danger,
.bg-danger *,
.bg-dark,
.bg-dark *,
.bg-secondary,
.bg-secondary *,
.btn-primary,
.btn-success,
.btn-info,
.btn-danger,
.btn-dark,
.btn-secondary,
[class*="bg-gradient-"] {
  color: white !important;
}

/* Exception for warning backgrounds - they need dark text */
.bg-warning,
.bg-warning *,
.btn-warning {
  color: #1f2937 !important;
}

/* ==========================
   RESPONSIVE FIXES
   ========================== */

@media (max-width: 768px) {
  /* Ensure mobile text is also visible */
  body {
    color: #1f2937 !important;
  }
  
  p, span, div:not([class*="bg-"]):not(.header-blue):not(.sidebar):not(.footer) {
    color: #1f2937 !important;
  }
}

/* ==========================
   PRINT STYLES
   ========================== */

@media print {
  * {
    color: black !important;
    background: white !important;
  }
}
