/**
 * Literature Survey Table - Stylesheet
 * Custom styles for DataTables with multi-select dropdown filters
 * 
 * @author Lennart Pape
 * @date 2026-01-04
 * @version 1.0.0
 */

/* Body */
body { 
  padding: 2rem; 
  background: #f8f9fa; 
}

/* DataTable - Main Container */
.dataTables_wrapper {
  overflow: visible !important;
}

#csvTable_wrapper {
  overflow: visible !important;
  width: 100%;
}

.dataTables_scroll {
  overflow-x: visible !important;
}

/* DataTable - Table Structure */
#csvTable.dataTable {
  table-layout: fixed;
}

.dataTables_scrollBody table {
  width: 100% !important;
}

/* DataTable - Header */
table.dataTable thead {
  pointer-events: auto !important;
}

thead th {
  overflow: visible !important;
  position: relative;
  pointer-events: auto !important;
}

table.dataTable thead tr:first-child th {
  text-align: center;
  vertical-align: middle;
  position: relative;
  z-index: 10 !important;
  pointer-events: auto !important;
}

table.dataTable thead tr:nth-child(2) th {
  overflow: visible !important;
  pointer-events: auto !important;
  white-space: nowrap;
  z-index: 20 !important;
  position: relative;
}

table.dataTable thead tr:nth-child(2) th .multi-select {
  max-width: 100%;
}

table.dataTable thead tr:nth-child(2) th .multi-select-dropdown {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dataTables_scrollHead .table thead th {
  overflow: hidden;
  white-space: nowrap;
  box-sizing: border-box;
  vertical-align: middle;
}

/* DataTable - Scrolling */
.dataTables_scrollHead {
  overflow: hidden !important;
  width: 100% !important;
}

.dataTables_scrollHeadInner {
  overflow: hidden !important;
  width: 100% !important;
  transition: margin-left 0s !important;
  box-sizing: content-box !important;
}

.dataTables_scrollBody {
  overflow-x: auto !important; 
  box-sizing: content-box !important;
  position: relative;
  z-index: 1 !important;
}

.dataTables_scrollHead table {
  transition: margin-left 0s !important;
}

/* DataTable - Controls */
div.dataTables_length,
div.dataTables_filter {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

div.dataTables_length {
  float: left;
}

div.dataTables_filter {
  float: right;
  text-align: right;
}

div.dataTables_info {
  float: left;
  padding-top: 0.85em;
}

div.dataTables_paginate {
  float: right;
  margin-top: 0.25em;
}

/* DataTable - Form Elements */
.dataTables_filter input[type="search"]:focus {
  background-color: white;
  border-color: #86b7fe;
  outline: none;
  box-shadow: none;
}

.dataTables_filter input[type="search"]::-webkit-search-cancel-button,
.dataTables_filter input[type="search"]::-webkit-search-clear-button {
  cursor: pointer;
}

.dataTables_length select {
  cursor: pointer;
}

.dataTables_length select:focus {
  background-color: white;
  border-color: #86b7fe;
  outline: none;
  box-shadow: none;
}

.dataTables_length select:hover {
  border-color: #86b7fe;
  cursor: pointer;
}

/* Multi-Select Dropdown */
.multi-select {
  position: relative;
  width: 100%;
  max-width: 100%;
  pointer-events: auto !important;
  z-index: 100 !important;
}

.multi-select-dropdown {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 0 0.75rem;
  padding-right: 1.7rem;
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 38px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  user-select: none;
  pointer-events: auto !important;
  z-index: 100 !important;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.multi-select-dropdown:hover {
  border-color: #86b7fe;
  background-color: #f8f9fa;
}

.dropdown-text {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto; 
  min-width: 0;   
  width: 0;
  color: #495057;
  font-weight: normal;
}

.dropdown-text.selected-values {
  max-width: none !important;
}

/* Multi-Select Options Menu */
body > .multi-select-options {
  position: fixed !important;
  background: white !important;
  border: 1px solid #dee2e6 !important;
  border-radius: 0.375rem !important;
  max-height: 200px !important;
  overflow-y: auto !important;
  z-index: 10000 !important;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
  display: none;
  min-width: 150px !important;
}

body > .multi-select-options.show {
  display: block !important;
}

.multi-select-option {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: normal;
  user-select: none;
}

.multi-select-option:hover {
  background-color: #f8f9fa !important;
}

.multi-select-option.selected {
  background-color: #0d6efd !important;
  color: white !important;
}

/* Active Filters Display */
.active-filters {
  background: #e9ecef;
  padding: 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  min-height: 60px;
}

/* Filter Badges */
.filter-badge {
  display: inline-block;
  background: #0d6efd;
  color: white;
  padding: 0.25rem 0.5rem;
  margin: 0.125rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.filter-badge:hover {
  background: #0b5ed7;
}

.filter-badge .remove {
  margin-left: 0.5rem;
  font-weight: bold;
}

/* Clear All Button */
.clear-all-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  cursor: pointer;
  margin-left: 0.5rem;
}

.clear-all-btn:hover {
  background: #bb2d3b;
}

/* Responsive Design */
@media (max-width: 768px) {
  div.dataTables_length,
  div.dataTables_filter {
    float: none;
    text-align: left;
    justify-content: flex-start;
    width: 100%;
  }
  
  div.dataTables_info,
  div.dataTables_paginate {
    float: none;
    text-align: left;
    width: 100%;
    margin-bottom: 0.5rem;
  }
}
