/*
 * Sumon Enterprise V2 — Light Theme Contrast Repair V9
 * Explicit high-contrast light palette. Loaded after all legacy theme styles.
 * Does not change application routes, business logic, or dark-mode colors.
 */

body.mf-classic-v4:not(.dark-mode) {
  color-scheme: light !important;
  --bg-body: #f4f6f8 !important;
  --bg-card: #ffffff !important;
  --surface: #ffffff !important;
  --surface-alt: #f5f7fa !important;
  --bg-surface-alt: #f5f7fa !important;
  --surface-hover: #edf2f7 !important;
  --bg-hover: #edf2f7 !important;
  --text-primary: #172033 !important;
  --text-secondary: #475569 !important;
  --text-muted: #64748b !important;
  --border: #d8e0e8 !important;
  --border-light: #e8edf2 !important;
  --bs-body-color: #172033 !important;
  --bs-secondary-color: #475569 !important;
  --bs-tertiary-color: #64748b !important;
  --bs-emphasis-color: #111827 !important;
  --bs-border-color: #d8e0e8 !important;
  background-color: #f4f6f8 !important;
  color: #172033 !important;
}

/* Ensure the normal page canvas and primary cards remain genuinely light. */
body.mf-classic-v4:not(.dark-mode) .main-area,
body.mf-classic-v4:not(.dark-mode) .content-area,
body.mf-classic-v4:not(.dark-mode) .main-content {
  color: #172033 !important;
}
body.mf-classic-v4:not(.dark-mode) .card,
body.mf-classic-v4:not(.dark-mode) .card-modern,
body.mf-classic-v4:not(.dark-mode) .stat-card,
body.mf-classic-v4:not(.dark-mode) .form-card,
body.mf-classic-v4:not(.dark-mode) .search-filter-bar,
body.mf-classic-v4:not(.dark-mode) .admin-card,
body.mf-classic-v4:not(.dark-mode) .table-card,
body.mf-classic-v4:not(.dark-mode) .report-card,
body.mf-classic-v4:not(.dark-mode) .product-card,
body.mf-classic-v4:not(.dark-mode) .pos-products-panel,
body.mf-classic-v4:not(.dark-mode) .pos-cart-panel {
  background-color: #ffffff !important;
  color: #172033 !important;
  border-color: #d8e0e8 !important;
}

/* Dark, readable headings and secondary copy in Light Mode. */
body.mf-classic-v4:not(.dark-mode) .content-area h1,
body.mf-classic-v4:not(.dark-mode) .content-area h2,
body.mf-classic-v4:not(.dark-mode) .content-area h3,
body.mf-classic-v4:not(.dark-mode) .content-area h4,
body.mf-classic-v4:not(.dark-mode) .content-area h5,
body.mf-classic-v4:not(.dark-mode) .content-area h6,
body.mf-classic-v4:not(.dark-mode) .card-title,
body.mf-classic-v4:not(.dark-mode) .card-header h5,
body.mf-classic-v4:not(.dark-mode) .product-name,
body.mf-classic-v4:not(.dark-mode) .stat-info h3 {
  color: #172033 !important;
}
body.mf-classic-v4:not(.dark-mode) .content-area .text-muted,
body.mf-classic-v4:not(.dark-mode) .content-area .text-secondary,
body.mf-classic-v4:not(.dark-mode) .content-area .form-text,
body.mf-classic-v4:not(.dark-mode) .content-area .form-label,
body.mf-classic-v4:not(.dark-mode) .content-area label,
body.mf-classic-v4:not(.dark-mode) .content-area .page-description,
body.mf-classic-v4:not(.dark-mode) .content-area .product-meta,
body.mf-classic-v4:not(.dark-mode) .content-area .stat-info p,
body.mf-classic-v4:not(.dark-mode) .content-area .card-header p {
  color: #475569 !important;
}

/* Inputs, selects, search fields and their placeholders. */
body.mf-classic-v4:not(.dark-mode) .content-area input:not([type=checkbox]):not([type=radio]):not([type=range]),
body.mf-classic-v4:not(.dark-mode) .content-area textarea,
body.mf-classic-v4:not(.dark-mode) .content-area select,
body.mf-classic-v4:not(.dark-mode) .content-area .form-control,
body.mf-classic-v4:not(.dark-mode) .content-area .form-select {
  background-color: #ffffff !important;
  color: #172033 !important;
  border-color: #cbd5e1 !important;
}
body.mf-classic-v4:not(.dark-mode) .content-area input::placeholder,
body.mf-classic-v4:not(.dark-mode) .content-area textarea::placeholder {
  color: #64748b !important;
  opacity: 1 !important;
}

/* Tables need dark body text on white rows and a distinct header. */
body.mf-classic-v4:not(.dark-mode) .content-area .table,
body.mf-classic-v4:not(.dark-mode) .content-area .admin-table {
  --bs-table-bg: #ffffff;
  --bs-table-color: #172033;
  --bs-table-border-color: #d8e0e8;
  color: #172033 !important;
  background: #ffffff !important;
}
body.mf-classic-v4:not(.dark-mode) .content-area .table thead th,
body.mf-classic-v4:not(.dark-mode) .content-area .table-light th,
body.mf-classic-v4:not(.dark-mode) .content-area .admin-table th {
  background: #eef2f6 !important;
  color: #263548 !important;
  border-color: #d8e0e8 !important;
}
body.mf-classic-v4:not(.dark-mode) .content-area .table tbody td,
body.mf-classic-v4:not(.dark-mode) .content-area .admin-table td {
  background: #ffffff !important;
  color: #263548 !important;
  border-color: #e2e8f0 !important;
}

/* Product details modal — never let the dark backdrop become the dialog surface. */
body.mf-classic-v4:not(.dark-mode) .product-modal-overlay {
  background: rgba(15, 23, 42, .58) !important;
}
body.mf-classic-v4:not(.dark-mode) .product-modal-dialog {
  background: #ffffff !important;
  color: #172033 !important;
  border: 1px solid #d5dee8 !important;
}
body.mf-classic-v4:not(.dark-mode) .product-modal-header,
body.mf-classic-v4:not(.dark-mode) .product-modal-body {
  background: #ffffff !important;
  color: #172033 !important;
  border-color: #e2e8f0 !important;
}
body.mf-classic-v4:not(.dark-mode) .product-modal-header h3,
body.mf-classic-v4:not(.dark-mode) .product-modal-details .detail-row strong {
  color: #172033 !important;
}
body.mf-classic-v4:not(.dark-mode) .product-modal-details .detail-row span {
  color: #475569 !important;
}
body.mf-classic-v4:not(.dark-mode) .product-modal-details .detail-row {
  border-color: #e2e8f0 !important;
}
body.mf-classic-v4:not(.dark-mode) .product-modal-footer {
  background: #f5f7fa !important;
  border-color: #d8e0e8 !important;
}
body.mf-classic-v4:not(.dark-mode) .product-modal-close {
  background: #eef2f6 !important;
  color: #334155 !important;
  border-color: #cbd5e1 !important;
}
body.mf-classic-v4:not(.dark-mode) .product-modal-image-wrap,
body.mf-classic-v4:not(.dark-mode) .product-modal-image,
body.mf-classic-v4:not(.dark-mode) .product-modal-no-image {
  background: #f5f7fa !important;
  border-color: #d8e0e8 !important;
}
body.mf-classic-v4:not(.dark-mode) .product-modal-footer .btn-secondary {
  background: #e9eef4 !important;
  color: #263548 !important;
  border: 1px solid #cbd5e1 !important;
}

/* Keep Dark Mode explicitly dark; this also protects against Light Mode overrides. */
body.mf-classic-v4.dark-mode {
  color-scheme: dark !important;
}
body.mf-classic-v4.dark-mode .product-modal-dialog {
  background: #182433 !important;
  color: #e8eff7 !important;
  border-color: #40536a !important;
}
body.mf-classic-v4.dark-mode .product-modal-header,
body.mf-classic-v4.dark-mode .product-modal-body {
  background: #182433 !important;
  color: #e8eff7 !important;
  border-color: #40536a !important;
}
body.mf-classic-v4.dark-mode .product-modal-header h3,
body.mf-classic-v4.dark-mode .product-modal-details .detail-row strong {
  color: #edf3fa !important;
}
body.mf-classic-v4.dark-mode .product-modal-details .detail-row span {
  color: #bdcad8 !important;
}
body.mf-classic-v4.dark-mode .product-modal-footer {
  background: #202f40 !important;
  border-color: #40536a !important;
}
body.mf-classic-v4.dark-mode .product-modal-close {
  background: #26384c !important;
  color: #e2ebf4 !important;
  border-color: #40536a !important;
}
body.mf-classic-v4.dark-mode .product-modal-image-wrap,
body.mf-classic-v4.dark-mode .product-modal-image,
body.mf-classic-v4.dark-mode .product-modal-no-image {
  background: #202f40 !important;
  border-color: #40536a !important;
}
body.mf-classic-v4.dark-mode .product-modal-footer .btn-secondary {
  background: #293b50 !important;
  color: #e2ebf4 !important;
  border-color: #40536a !important;
}

@media (prefers-reduced-motion: reduce) {
  body.mf-classic-v4 .product-modal-overlay,
  body.mf-classic-v4 .product-modal-dialog {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
