/*
 * EcoRotas DataTables Corporate Theme
 * Professional styling for data tables
 */

/* ===== DATATABLE WRAPPER ===== */
.dataTables_wrapper {
  margin-bottom: 2rem;
}

/* ===== TABLE STYLING ===== */
.dataTable {
  width: 100% !important;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* Header Styling */
.dataTable thead {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
}

.dataTable thead th {
  background: transparent;
  color: var(--text-white) !important;
  font-weight: 600;
  padding: 15px 12px;
  border: none;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: relative;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.dataTable thead th:first-child {
  border-top-left-radius: var(--radius-lg);
}

.dataTable thead th:last-child {
  border-top-right-radius: var(--radius-lg);
}

/* Sorting indicators */
.dataTable thead th.sorting,
.dataTable thead th.sorting_asc,
.dataTable thead th.sorting_desc {
  cursor: pointer;
  position: relative;
  padding-right: 30px;
}

.dataTable thead th.sorting:after,
.dataTable thead th.sorting_asc:after,
.dataTable thead th.sorting_desc:after {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
}

.dataTable thead th.sorting:after {
  content: '\f0dc';
}

.dataTable thead th.sorting_asc:after {
  content: '\f0de';
  color: var(--accent-color);
}

.dataTable thead th.sorting_desc:after {
  content: '\f0dd';
  color: var(--accent-color);
}

.dataTable thead th.sorting:hover:after,
.dataTable thead th.sorting_asc:hover:after,
.dataTable thead th.sorting_desc:hover:after {
  color: var(--text-white);
}

/* Body Styling */
.dataTable tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: middle;
  background: var(--bg-primary);
  transition: all var(--transition-fast);
}

.dataTable tbody tr {
  transition: all var(--transition-fast);
}

.dataTable tbody tr:hover {
  background: var(--bg-tertiary) !important;
}

.dataTable tbody tr:hover td {
  background: transparent;
  color: var(--text-primary);
}

/* Striped rows */
.dataTable.table-striped tbody tr:nth-child(even) {
  background: rgba(248, 250, 252, 0.5);
}

.dataTable.table-striped tbody tr:nth-child(even):hover {
  background: var(--bg-tertiary) !important;
}

/* ===== DATATABLE CONTROLS ===== */

/* Length Menu */
.dataTables_length {
  margin-bottom: 1rem;
}

.dataTables_length label {
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dataTables_length select {
  padding: 6px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-width: 80px;
}

.dataTables_length select:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

/* Search Box */
.dataTables_filter {
  margin-bottom: 1rem;
}

.dataTables_filter label {
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

.dataTables_filter input {
  padding: 8px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 250px;
  transition: all var(--transition-fast);
}

.dataTables_filter input:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
  width: 300px;
}

.dataTables_filter input::placeholder {
  color: var(--text-muted);
}

/* Info Text */
.dataTables_info {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 1rem;
  padding: 8px 0;
}

/* ===== PAGINATION ===== */
.dataTables_paginate {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
}

.dataTables_paginate .paginate_button {
  display: inline-block;
  padding: 8px 12px;
  margin: 0 2px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary) !important;
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-weight: 500;
  font-size: 13px;
  min-width: 40px;
  text-align: center;
}

.dataTables_paginate .paginate_button:hover {
  background: var(--primary-color) !important;
  color: var(--text-white) !important;
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.dataTables_paginate .paginate_button.current {
  background: var(--primary-color) !important;
  color: var(--text-white) !important;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

.dataTables_paginate .paginate_button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dataTables_paginate .paginate_button.disabled:hover {
  background: var(--bg-primary) !important;
  color: var(--text-muted) !important;
  border-color: var(--border-medium);
  transform: none;
}

/* Previous/Next buttons */
.dataTables_paginate .paginate_button.previous,
.dataTables_paginate .paginate_button.next {
  font-weight: 600;
}

.dataTables_paginate .paginate_button.previous:before {
  content: '‹ ';
  font-size: 16px;
}

.dataTables_paginate .paginate_button.next:after {
  content: ' ›';
  font-size: 16px;
}

/* ===== PROCESSING INDICATOR ===== */
.dataTables_processing {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150px;
  height: 60px;
  margin-left: -75px;
  margin-top: -30px;
  padding: 14px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  box-shadow: var(--shadow-lg);
  text-align: center;
  font-weight: 600;
  color: var(--text-primary);
  z-index: 1000;
}

.dataTables_processing:before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-light);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

/* ===== RESPONSIVE DATATABLE ===== */
.dataTables_wrapper .dataTables_scroll {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.dataTables_wrapper .dataTables_scrollHead,
.dataTables_wrapper .dataTables_scrollBody {
  border-radius: 0;
}

.dataTables_wrapper .dataTables_scrollHead .dataTable {
  margin-bottom: 0;
}

.dataTables_wrapper .dataTables_scrollBody .dataTable {
  border-top: none;
  margin-top: 0;
  margin-bottom: 0;
}

/* ===== ROW DETAILS (Responsive) ===== */
.dataTable tbody td.child {
  padding: 0;
  border-bottom: none;
}

.dataTable tbody td.child ul {
  list-style: none;
  padding: 1rem;
  margin: 0;
  background: var(--bg-tertiary);
}

.dataTable tbody td.child ul li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.dataTable tbody td.child ul li:last-child {
  border-bottom: none;
}

.dataTable tbody td.child ul li span.dtr-title {
  font-weight: 600;
  color: var(--text-primary);
  display: inline-block;
  min-width: 120px;
}

.dataTable tbody td.child ul li span.dtr-data {
  color: var(--text-secondary);
}

/* Control column for responsive */
.dataTable tbody td.control,
.dataTable thead th.control {
  width: 30px;
  text-align: center;
}

.dataTable tbody td.control:before {
  content: '+';
  font-weight: bold;
  color: var(--primary-color);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  text-align: center;
  transition: all var(--transition-fast);
}

.dataTable tbody tr.parent td.control:before {
  content: '-';
  background: var(--primary-color);
  color: var(--text-white);
}

.dataTable tbody td.control:hover:before {
  background: var(--primary-color);
  color: var(--text-white);
  transform: scale(1.1);
}

/* ===== BUTTONS EXTENSION ===== */
.dt-buttons {
  margin-bottom: 1rem;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dt-button {
  padding: 8px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  transition: all var(--transition-fast);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dt-button:hover {
  background: var(--primary-color);
  color: var(--text-white);
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.dt-button i {
  font-size: 12px;
}

/* ===== SELECT EXTENSION ===== */
.dataTable tbody tr.selected {
  background: rgba(26, 54, 93, 0.1) !important;
}

.dataTable tbody tr.selected td {
  background: transparent;
  color: var(--primary-color);
}

/* Select checkbox styling */
.dataTable tbody td.select-checkbox,
.dataTable thead th.select-checkbox {
  text-align: center;
  width: 30px;
}

.dataTable tbody td.select-checkbox:before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-medium);
  border-radius: 3px;
  background: var(--bg-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dataTable tbody tr.selected td.select-checkbox:before {
  background: var(--primary-color);
  border-color: var(--primary-color);
  background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='m13.854 3.646-8 8a.5.5 0 0 1-.708 0l-4-4a.5.5 0 1 1 .708-.708L5.5 10.293l7.646-7.647a.5.5 0 0 1 .708.708z'/%3e%3c/svg%3e");
  background-size: 12px;
  background-position: center;
  background-repeat: no-repeat;
}

/* ===== COMPACT TABLE VARIATION ===== */
.dataTable.compact thead th,
.dataTable.compact tbody td {
  padding: 8px;
}

.dataTable.compact {
  font-size: 13px;
}

/* ===== MOBILE RESPONSIVENESS ===== */
@media (max-width: 768px) {
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    text-align: center;
    margin-bottom: 1rem;
  }
  
  .dataTables_filter input {
    width: 100%;
    max-width: 250px;
  }
  
  .dataTables_filter input:focus {
    width: 100%;
    max-width: 250px;
  }
  
  .dt-buttons {
    justify-content: center;
  }
  
  .dataTables_paginate {
    text-align: center;
  }
  
  .dataTables_paginate .paginate_button {
    padding: 6px 8px;
    margin: 0 1px;
    font-size: 12px;
    min-width: 32px;
  }
}

@media (max-width: 480px) {
  .dataTable thead th,
  .dataTable tbody td {
    padding: 8px 6px;
    font-size: 12px;
  }
  
  .dataTables_paginate .paginate_button {
    padding: 4px 6px;
    font-size: 11px;
    min-width: 28px;
  }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
  .dataTables_wrapper {
    /* Dark mode styles would go here if needed */
  }
}

/* ===== CUSTOM STATUS BADGES IN TABLES ===== */
.dataTable .status-badge {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.dataTable .status-badge.active {
  background: rgba(5, 150, 105, 0.1);
  color: var(--success-color);
  border: 1px solid var(--success-light);
}

.dataTable .status-badge.inactive {
  background: rgba(107, 114, 128, 0.1);
  color: var(--gray-600);
  border: 1px solid var(--gray-400);
}

.dataTable .status-badge.pending {
  background: rgba(217, 119, 6, 0.1);
  color: var(--warning-color);
  border: 1px solid var(--warning-light);
}

.dataTable .status-badge.error {
  background: rgba(220, 38, 38, 0.1);
  color: var(--error-color);
  border: 1px solid var(--error-light);
}

/* ===== ACTION BUTTONS IN TABLES ===== */
.dataTable .action-buttons {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.dataTable .action-buttons .btn {
  padding: 4px 8px;
  font-size: 11px;
  min-width: auto;
  border-radius: var(--radius-sm);
}

.dataTable .action-buttons .btn i {
  margin: 0;
  font-size: 12px;
}

/* ===== EXPORT BUTTONS STYLING ===== */
.dt-buttons .buttons-excel,
.dt-buttons .buttons-pdf,
.dt-buttons .buttons-print {
  background: var(--success-color);
  color: var(--text-white);
  border-color: var(--success-color);
}

.dt-buttons .buttons-excel:hover,
.dt-buttons .buttons-pdf:hover,
.dt-buttons .buttons-print:hover {
  background: var(--success-light);
  border-color: var(--success-light);
}

.dt-buttons .buttons-copy {
  background: var(--info-color);
  color: var(--text-white);
  border-color: var(--info-color);
}

.dt-buttons .buttons-copy:hover {
  background: var(--info-light);
  border-color: var(--info-light);
}
