/**
 * ModernTable.js - Themes & Accessibility CSS
 * Focused ONLY on Modern Table components
 * 
 * SCOPE: All styles are limited to .modern-table-wrapper
 * PURPOSE: Light & Dark mode theming for Modern Table
 */

/* ========================================
   DARK THEME
   ======================================== */

/* Base wrapper */
:is([data-bs-theme="dark"], .theme-dark) .modern-table-wrapper {
  background-color: #212529 !important;
  color: #dee2e6 !important;
  border-color: #495057;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

:is([data-bs-theme="dark"], .theme-dark) .modern-table-wrapper:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

/* Table elements */
:is([data-bs-theme="dark"], .theme-dark) .modern-table {
  background-color: #212529 !important;
  color: #dee2e6 !important;
  border-color: #495057 !important;
}

:is([data-bs-theme="dark"], .theme-dark) .modern-table th {
  background-color: #343a40 !important;
  border-color: #495057 !important;
  color: #dee2e6 !important;
}

:is([data-bs-theme="dark"], .theme-dark) .modern-table td {
  border-color: #495057 !important;
  color: #dee2e6 !important;
  background-color: #212529 !important;
}

/* Table states */
:is([data-bs-theme="dark"], .theme-dark) .modern-table tbody tr:hover {
  background-color: #343a40;
}

:is([data-bs-theme="dark"], .theme-dark) .modern-table tbody tr.selected {
  background-color: #0d47a1;
}

/* Dark mode striped table */
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table
  tbody
  tr:nth-of-type(odd),
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table.table-striped
  tbody
  tr:nth-of-type(odd) {
  background-color: #212529 !important;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table
  tbody
  tr:nth-of-type(even),
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table.table-striped
  tbody
  tr:nth-of-type(even) {
  background-color: #2c3034 !important;
}

/* Dark mode checkbox */
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table
  :is(th, td)
  .form-check-input {
  appearance: none;
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  border: 1px solid #6c757d;
  border-radius: 3px;
  background-color: #343a40;
  cursor: pointer;
  vertical-align: middle;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table
  :is(th, td)
  .form-check-input:hover {
  background-color: #495057;
  border-color: #adb5bd;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table
  :is(th, td)
  .form-check-input:checked {
  background-color: #0d6efd;
  border-color: #0d6efd;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M3 8l3 3 7-7'/%3e%3c/svg%3e");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 70% 70%;
}

/* ========================================
   DARK THEME - TOOLBAR & PAGINATION
   ======================================== */

/* Toolbar & pagination base */
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .modern-table-toolbar,
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .modern-table-pagination {
  background-color: #212529;
  color: #dee2e6;
  border-top-color: #495057;
}

:is([data-bs-theme="dark"], .theme-dark) .modern-table-wrapper .toolbar-left,
:is([data-bs-theme="dark"], .theme-dark) .modern-table-wrapper .toolbar-center,
:is([data-bs-theme="dark"], .theme-dark) .modern-table-wrapper .toolbar-right {
  background-color: #212529;
  color: #dee2e6;
}

/* Toolbar Left - Dark Mode Colors Only */
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-toolbar
  .toolbar-left
  .text-muted {
  color: #dee2e6;
}

/* :is([data-bs-theme="dark"], .theme-dark)
  .modern-table-toolbar
  .toolbar-left
  select.form-select {
  background: #495057;
  border: 1px solid #6c757d;
  color: #dee2e6;
} */

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-toolbar
  .toolbar-left
  select.form-select:hover {
  background: #5a6268;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-toolbar
  .toolbar-left
  select.form-select:focus {
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
  outline: none;
}

/* Toolbar Center Buttons */
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .modern-table-toolbar
  .toolbar-center
  .btn,
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .modern-table-toolbar
  .toolbar-center
  button {
  background: #495057 !important;
  border: 1px solid #6c757d !important;
  color: #dee2e6 !important;
  padding: 0.4rem 0.9rem !important;
  border-radius: 6px !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .modern-table-toolbar
  .toolbar-center
  .btn:hover,
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .modern-table-toolbar
  .toolbar-center
  button:hover {
  background: #5a6268 !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35) !important;
  border-color: #adb5bd !important;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .modern-table-toolbar
  .toolbar-center
  .btn:focus-visible,
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .modern-table-toolbar
  .toolbar-center
  button:focus-visible {
  outline: 2px solid #6c63ff !important;
  outline-offset: 2px;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .modern-table-toolbar
  .toolbar-center
  .btn:active,
:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .modern-table-toolbar
  .toolbar-center
  button:active {
  transform: scale(0.97) !important;
}

/* Toolbar Right (Search) - Dark Mode Colors Only */
:is([data-bs-theme="dark"], .theme-dark) .modern-table-toolbar .toolbar-right {
  background-color: #343a40;
  border: 1px solid #495057;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-toolbar
  .toolbar-right
  .modern-table-search
  .form-control {
  background-color: #495057;
  color: #dee2e6;
  border: 1px solid #6c757d;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-toolbar
  .toolbar-right
  .modern-table-search
  .form-control::placeholder {
  color: #adb5bd;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-toolbar
  .toolbar-right
  .modern-table-search
  .form-control:hover {
  background-color: #5a6268;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-toolbar
  .toolbar-right
  .modern-table-search
  .form-control:focus {
  background-color: #5a6268;
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
  outline: none;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-toolbar
  .toolbar-right
  .modern-table-search
  button {
  color: #adb5bd;
  background: none;
  border: none;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-toolbar
  .toolbar-right
  .modern-table-search
  button:hover {
  color: #fff;
}

/* ========================================
   FILRTER PANEL
   ======================================== */

/* Dark mode overrides */
.modern-table-wrapper.no-bootstrap.theme-dark .modern-table-filters {
  background: #343a40;
  border: 1px solid #495057;
  color: #dee2e6;
}

.modern-table-wrapper.no-bootstrap.theme-dark .modern-table-filters label {
  color: #dee2e6;
}

.modern-table-wrapper.no-bootstrap.theme-dark .modern-table-filters input,
.modern-table-wrapper.no-bootstrap.theme-dark .modern-table-filters select {
  background-color: #495057;
  color: #dee2e6;
  border: 1px solid #6c757d;
}

.modern-table-wrapper.no-bootstrap.theme-dark .modern-table-filters input:focus,
.modern-table-wrapper.no-bootstrap.theme-dark
  .modern-table-filters
  select:focus {
  background-color: #5a6268;
  border-color: #0d6efd;
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
  outline: none;
}

.modern-table-wrapper.no-bootstrap.theme-dark .modern-table-filters .d-flex {
  background-color: transparent;
}

/* Date picker dark mode */
.modern-table-wrapper.no-bootstrap.theme-dark
  .modern-table-filters
  input[type="date"] {
  color-scheme: dark;
  background-color: #495057;
  color: #dee2e6;
  border: 1px solid #6c757d;
}

.modern-table-wrapper.no-bootstrap.theme-dark
  .modern-table-filters
  input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
  opacity: 0.8;
}

.modern-table-wrapper.no-bootstrap.theme-dark
  .modern-table-filters
  input[type="date"]::-moz-calendar-picker-indicator {
  filter: invert(1);
}

/* Force dark theme for date picker popup */
:is([data-bs-theme="dark"], .theme-dark) input[type="date"] {
  color-scheme: dark;
}

.modern-table-wrapper.no-bootstrap.theme-dark .modern-table-filters button {
  background: #495057;
  border: 1px solid #6c757d;
  color: #dee2e6;
}

.modern-table-wrapper.no-bootstrap.theme-dark
  .modern-table-filters
  button:hover {
  background: #5a6268;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  border-color: #adb5bd;
  color: #dee2e6;
}

.modern-table-wrapper.no-bootstrap.theme-dark
  .modern-table-filters
  button:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

.modern-table-wrapper.no-bootstrap.theme-dark
  .modern-table-filters
  button:active {
  transform: scale(0.97);
}

/* =====================================
   COLUMN SEARCH ROW
   ===================================== */
.modern-table-wrapper.no-bootstrap.theme-dark
  .modern-table
  .column-search-row
  .column-search-input {
  color: #dee2e6;
  background-color: #495057;
  border: 1px solid #6c757d;
}

.modern-table-wrapper.no-bootstrap.theme-dark
  .modern-table
  .column-search-row
  .column-search-input:focus {
  background-color: #5a6268;
  border-color: #0d6efd;
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
  outline: none;
}

.modern-table-wrapper.no-bootstrap.theme-dark
  .modern-table
  .column-search-row
  .column-search-input:hover {
  background-color: #5a6268;
}

/* ========================================
   PAGINATION
   ======================================== */

/* Pagination */
:is([data-bs-theme="dark"], .theme-dark) .modern-table-wrapper .page-link {
  background-color: #2d2d2d !important;
  border-color: #495057 !important;
  color: #adb5bd !important;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .page-link:hover {
  background-color: #495057 !important;
  border-color: #6c757d !important;
  color: #adb5bd !important;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .page-item.active
  .page-link {
  background-color: #6c757d !important;
  border-color: #6c757d !important;
  color: #adb5bd !important;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-wrapper
  .modern-table-pagination
  .modern-table-info {
  color: #adb5bd !important;
}

/* Column Visibility Dropdown */
:is([data-bs-theme="dark"], .theme-dark) .column-visibility-dropdown {
  background-color: #212529 !important;
  color: #adb5bd !important;
  border: 1px solid #333 !important;
  padding: 0.5rem !important;
  border-radius: 6px !important;
}

:is([data-bs-theme="dark"], .theme-dark) .column-visibility-dropdown button {
  background: linear-gradient(180deg, #333 0%, #1f1f1f 100%) !important;
  color: #adb5bd !important;
  border: 1px solid #495057 !important;
  padding: 0.3rem 0.75rem !important;
  font-size: 0.85rem !important;
  border-radius: 4px !important;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  button:hover {
  background: linear-gradient(180deg, #444 0%, #2a2a2a 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  button:active {
  transform: scale(0.96);
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  button:focus-visible {
  outline: 2px solid #6c63ff;
  outline-offset: 2px;
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  border: 1px solid #495057;
  border-radius: 3px;
  background-color: #2d2d2d;
  cursor: pointer;
  vertical-align: middle;
  margin-right: 0.5rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  input[type="checkbox"]:hover {
  background-color: #3a3a3a;
  border-color: #6c757d;
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  input[type="checkbox"]:checked {
  background-color: #6c63ff;
  border-color: #6c63ff;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M3 8l3 3 7-7'/%3e%3c/svg%3e");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 70% 70%;
}

/* ========================================
   NOTIFICATIONS - DARK MODE
   ======================================== */

:is([data-bs-theme="dark"], .theme-dark) .modern-table-notification {
  background: #343a40;
  border: 1px solid #495057;
  color: #dee2e6;
}

:is([data-bs-theme="dark"], .theme-dark) .modern-table-notification.success {
  background: #1e4d3a;
  border-left-color: #198754;
  color: #75b798;
}

:is([data-bs-theme="dark"], .theme-dark) .modern-table-notification.danger,
:is([data-bs-theme="dark"], .theme-dark) .modern-table-notification.error {
  background: #4a1e24;
  border-left-color: #dc3545;
  color: #ea868f;
}

:is([data-bs-theme="dark"], .theme-dark) .modern-table-notification.warning {
  background: #4d3619;
  border-left-color: #ffc107;
  color: #ffda6a;
}

:is([data-bs-theme="dark"], .theme-dark) .modern-table-notification.info {
  background: #1f4a54;
  border-left-color: #0dcaf0;
  color: #6edff6;
}

:is([data-bs-theme="dark"], .theme-dark) .modern-table-notification .close {
  color: #adb5bd;
}

:is([data-bs-theme="dark"], .theme-dark)
  .modern-table-notification
  .close:hover {
  color: #fff;
}
bility-dropdown {
  background-color: #212529 !important;
  color: #adb5bd !important;
  border: 1px solid #333 !important;
  padding: 0.5rem !important;
  border-radius: 6px !important;
}

:is([data-bs-theme="dark"], .theme-dark) .column-visibility-dropdown button {
  background: linear-gradient(180deg, #333 0%, #1f1f1f 100%) !important;
  color: #adb5bd !important;
  border: 1px solid #495057 !important;
  padding: 0.3rem 0.75rem !important;
  font-size: 0.85rem !important;
  border-radius: 4px !important;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  button:hover {
  background: linear-gradient(180deg, #444 0%, #2a2a2a 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  button:active {
  transform: scale(0.96);
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  button:focus-visible {
  outline: 2px solid #6c63ff;
  outline-offset: 2px;
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  border: 1px solid #495057;
  border-radius: 3px;
  background-color: #2d2d2d;
  cursor: pointer;
  vertical-align: middle;
  margin-right: 0.5rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  input[type="checkbox"]:hover {
  background-color: #3a3a3a;
  border-color: #6c757d;
}

:is([data-bs-theme="dark"], .theme-dark)
  .column-visibility-dropdown
  input[type="checkbox"]:checked {
  background-color: #6c63ff;
  border-color: #6c63ff;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M3 8l3 3 7-7'/%3e%3c/svg%3e");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 70% 70%;
}

/* ========================================
   LOADING STATES & ANIMATIONS
   ======================================== */

.modern-table-wrapper.loading {
  opacity: 0.7;
  pointer-events: none;
}

.modern-table-wrapper.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border: 3px solid #dee2e6;
  border-top-color: #0d6efd;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

:is([data-bs-theme="dark"], .theme-dark) .modern-table-wrapper.loading::after {
  border: 3px solid #333333;
  border-top-color: #0d6efd;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   ACCESSIBILITY & RESPONSIVE
   ======================================== */

/* High contrast support */
@media (prefers-contrast: high) {
  .modern-table {
    border: 2px solid #000000;
  }

  .modern-table th,
  .modern-table td {
    border: 1px solid #000000;
  }

  :is([data-bs-theme="dark"], .theme-dark) .modern-table {
    border: 2px solid #ffffff;
  }

  :is([data-bs-theme="dark"], .theme-dark) .modern-table th,
  :is([data-bs-theme="dark"], .theme-dark) .modern-table td {
    border: 1px solid #ffffff;
  }
}

/* Print styles */
@media print {
  :is([data-bs-theme="dark"], .theme-dark) {
    --mt-bg-color: #ffffff;
    --mt-text-color: #000000;
    --mt-border-color: #000000;
  }

  .modern-table-wrapper {
    background: white !important;
    color: black !important;
  }

  .modern-table {
    border: 1px solid black !important;
  }

  .modern-table th,
  .modern-table td {
    border: 1px solid black !important;
    background: white !important;
    color: black !important;
  }
}
