/**
 * Minimal and Fixed CSS for Secure Dynamic JSON Table
 * Optimized for performance and compatibility
 */

/* Base container styling */
.dynamic-json-table-container {
  margin: 20px 0;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.4;
}

/* Table search and controls */
.djt-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.djt-search {
  flex: 1;
  max-width: 300px;
  margin-right: 10px;
}

.djt-search-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}

.djt-per-page {
  display: flex;
  align-items: center;
}

.djt-per-page label {
  margin-right: 8px;
  white-space: nowrap;
}

/* Fix for per page selector */
#djt-table-[a-f0-9]+-per-page, /* Using attribute selector for dynamic IDs */
.djt-per-page-select {
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #f2f2f2; /* Clearly visible background */
  cursor: pointer;
  color: #333;
}

/* Table styling */
.djt-table-wrapper {
  overflow-x: auto;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-bottom: 15px;
}

.djt-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.djt-table th,
.djt-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

/* Head styling */
.djt-table thead th {
  background-color: #d9edf7;
  font-weight: bold;
  border-bottom: 2px solid #ccc;
}

/* Sorting indicators */
.djt-table th.sortable {
  cursor: pointer;
  position: relative;
  padding-right: 20px;
}

.djt-table th.sortable:hover {
  background-color: #c4e3f3;
}

.djt-table th.sortable .sort-indicator {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  opacity: 0.3;
}

.djt-table th.sorted-asc .sort-indicator:after {
  content: "▲";
  opacity: 1;
}

.djt-table th.sorted-desc .sort-indicator:after {
  content: "▼";
  opacity: 1;
}

/* Row styling */
.djt-table tbody tr:nth-child(even) {
  background-color: #f9f9f9;
}

.djt-table tbody tr:hover {
  background-color: #f3f3f3;
}

/* Masked ID styling */
.djt-table .masked-id {
  font-family: monospace;
  background-color: #f9f9f9;
  padding: 2px 4px;
  border-radius: 3px;
}

/* Pagination */
.djt-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.djt-pagination-info {
  color: #666;
  margin-bottom: 5px;
}

.djt-pagination-controls {
  display: flex;
  align-items: center;
}

/* Fixed pagination buttons to ensure they're always clickable */
.djt-prev-page,
.djt-next-page {
  background-color: #f2f2f2;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 5px 12px;
  margin: 0 5px;
  cursor: pointer !important; /* Force cursor */
  color: #333;
  font-weight: normal;
  transition: background-color 0.2s ease;
  pointer-events: auto !important; /* Force clickability */
}

.djt-prev-page:hover,
.djt-next-page:hover {
  background-color: #e0e0e0;
  border-color: #999;
}

.djt-prev-page[disabled],
.djt-next-page[disabled] {
  opacity: 0.5;
  background-color: #f9f9f9;
  color: #aaa;
}

.djt-pagination-controls button {
  pointer-events: auto !important;
}

.djt-page-number {
  margin: 0 10px;
  color: #666;
}

/* Security notice */
.security-notice {
  font-size: 11px;
  color: #777;
  text-align: right;
  margin-top: 10px;
  font-style: italic;
}

/* No results message */
.djt-table .no-results {
  text-align: center;
  padding: 20px;
  color: #666;
  font-style: italic;
}

/* Responsive adjustments */
@media screen and (max-width: 767px) {
  .djt-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .djt-search {
    max-width: 100%;
    margin-right: 0;
    margin-bottom: 10px;
  }
  
  .djt-per-page {
    margin-bottom: 10px;
  }
  
  .djt-pagination {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .djt-pagination-info {
    margin-bottom: 10px;
  }
  
  .djt-pagination-controls {
    margin-top: 5px;
    width: 100%;
    justify-content: center;
  }
}

/* Secure table features */
.secure-table-container {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Fix for pagination buttons to ensure they're properly clickable */
.djt-pagination-controls button.djt-prev-page,
.djt-pagination-controls button.djt-next-page {
  pointer-events: auto !important;
  cursor: pointer;
  opacity: 1;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

/* Only apply disabled styling when the disabled attribute is present */
.djt-pagination-controls button.djt-prev-page[disabled],
.djt-pagination-controls button.djt-next-page[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #f9f9f9;
  color: #aaa;
}

/* Fix for per page selector to ensure it's always visible and functional */
.djt-per-page-select,
[id^="djt-table-"][id$="-per-page"] {
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #f2f2f2;
  cursor: pointer;
  color: #333;
  pointer-events: auto !important;
  min-width: 60px;
}

/* Fix for search input to ensure it's properly styled */
.djt-search-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  pointer-events: auto !important;
}

/* Mobile styling improvements for controls */
@media screen and (max-width: 767px) {
  .djt-controls {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 20px;
  }
  
  .djt-search {
    max-width: 100%;
    margin-right: 0;
    margin-bottom: 15px;
  }
  
  .djt-per-page {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
  }
  
  .djt-per-page-select,
  [id^="djt-table-"][id$="-per-page"] {
    min-width: 100px;
  }
  
  .djt-pagination {
    margin-top: 20px;
  }
  
  .djt-pagination-info {
    margin-bottom: 15px;
    text-align: center;
  }
  
  .djt-pagination-controls {
    display: flex;
    justify-content: center;
    width: 100%;
  }
  
  .djt-page-number {
    margin: 0 15px;
  }
}

/* Fix for button hover states */
.djt-pagination-controls button.djt-prev-page:not([disabled]):hover,
.djt-pagination-controls button.djt-next-page:not([disabled]):hover {
  background-color: #e0e0e0;
  border-color: #999;
}