/* ===== HISTORY TAB STYLES ===== */

/* History Section Container */
#historyResultBox {
  display: none;
  animation: slideIn 0.4s ease-in-out;
  overflow-x: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  position: relative;
  border: 2px solid #1a0f33;
  border-radius: 16px;
  background: white !important;
}

#historyResultBox.show {
  display: block;
}

/* History Header */
.history-header {
  border-bottom: 2px solid #1a0f33;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.history-header h5 {
  color: #241443;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
}

.history-header h5 i {
  font-size: 1.8rem;
  color: #1a0f33;
}

/* History Table Container */
#historyTableContainer {
  border-radius: 12px;
  background: white !important;
  display: block !important;
  width: 100% !important;
  overflow: visible !important;
  box-shadow: 0 2px 8px rgba(26, 15, 51, 0.05);
}

/* Main History Table Styling */
#historyTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0 !important;
  background: white !important;
  table-layout: auto;
  border-spacing: 0;
}

/* Table Body */
#historyTable tbody {
  margin: 0;
  padding: 0;
}

/* Table Header Styling */
#historyTable thead {
  background: linear-gradient(135deg, #1a0f33 0%, #2d1b4e 100%) !important;
  color: white !important;
  font-weight: 600 !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 100 !important;
  box-shadow: 0 4px 8px rgba(26, 15, 51, 0.25) !important;
}

#historyTable thead tr {
  background: transparent !important;
  color: white !important;
}

#historyTable thead th {
  padding: 12px 16px !important;
  font-weight: 600 !important;
  color: white !important;
  text-align: left;
  border: none !important;
  min-width: 150px;
  white-space: nowrap;
  font-size: 0.95rem;
  position: relative;
  background: transparent !important;
  vertical-align: middle !important;
  line-height: 1.1 !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Column Width - Header */
#historyTable thead th:nth-child(1) {
  width: 11%;
  min-width: 80px;
}

#historyTable thead th:nth-child(2) {
  width: 9%;
  min-width: 70px;
}

#historyTable thead th:nth-child(3) {
  width: 9%;
  min-width: 70px;
}

#historyTable thead th:nth-child(4) {
  width: 10%;
  min-width: 75px;
}

#historyTable thead th:nth-child(5) {
  width: 9%;
  min-width: 70px;
}

#historyTable thead th:nth-child(6) {
  width: 7%;
  min-width: 50px;
}

#historyTable thead th:nth-child(7) {
  width: 7%;
  min-width: 50px;
}

#historyTable thead th:nth-child(8) {
  width: 18%;
  min-width: 120px;
}

#historyTable thead th:nth-child(9) {
  width: 7%;
  min-width: 50px;
}

#historyTable thead th:nth-child(12) {
  width: 4%;
  min-width: 40px;
}

/* Table Body Rows */
#historyTable tbody tr {
  border-bottom: 1px solid #1a0f33;
  transition: all 0.2s ease;
  margin: 0 !important;
  padding: 0 !important;
  background: white !important;
}

#historyTable tbody tr:hover {
  background: #f8f9fa !important;
  box-shadow: none;
  cursor: pointer;
  transform: scale(1.01);
}

#historyTable tbody tr:last-child {
  border-bottom: none;
}

/* Table Cells */
#historyTable tbody td {
  padding: 12px 16px !important;
  color: #333;
  vertical-align: middle;
  word-break: break-word;
  font-size: 0.8rem;
  overflow: visible;
  white-space: normal;
  margin: 0 !important;
  border: none !important;
  line-height: 1.4;
  background: white !important;
}

/* Column Width - Body */
#historyTable tbody td:nth-child(1) {
  width: 11%;
  min-width: 80px;
}

#historyTable tbody td:nth-child(2) {
  width: 9%;
  min-width: 70px;
}

#historyTable tbody td:nth-child(3) {
  width: 9%;
  min-width: 70px;
}

#historyTable tbody td:nth-child(4) {
  width: 10%;
  min-width: 75px;
}

#historyTable tbody td:nth-child(5) {
  width: 9%;
  min-width: 70px;
}

#historyTable tbody td:nth-child(6) {
  width: 7%;
  min-width: 50px;
}

#historyTable tbody td:nth-child(7) {
  width: 7%;
  min-width: 50px;
}

#historyTable tbody td:nth-child(8) {
  width: 18%;
  min-width: 120px;
}

#historyTable tbody td:nth-child(9) {
  width: 7%;
  min-width: 50px;
}

#historyTable tbody td:nth-child(12) {
  width: 4%;
  min-width: 40px;
}

/* Icons in Cells */
#historyTable tbody i {
  font-size: 1rem;
  margin-right: 2px;
  color: #1a0f33;
}

/* Badge Styling */
#historyTable .badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
  text-align: center;
  min-width: 45px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

#historyTable .badge.bg-info {
  background: linear-gradient(145deg, #667eea, #764ba2) !important;
  color: white;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

#historyTable .badge.bg-success {
  background: linear-gradient(145deg, #28a745, #20c997) !important;
  color: white;
  box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

#historyTable .badge.bg-danger {
  background: linear-gradient(145deg, #dc3545, #ff5252) !important;
  color: white;
  box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

#historyTable .badge.bg-warning {
  background: linear-gradient(145deg, #ff9800, #ffa726) !important;
  color: white;
  box-shadow: 0 2px 6px rgba(255, 152, 0, 0.3);
}

#historyTable .badge.bg-success {
  background: linear-gradient(145deg, #28a745, #20c997) !important;
  color: white;
  box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

#historyTable .badge.bg-danger {
  background: linear-gradient(145deg, #dc3545, #ff5252) !important;
  color: white;
  box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

#historyTable .badge.bg-warning {
  background: linear-gradient(145deg, #ff9800, #ffa726) !important;
  color: white;
  box-shadow: 0 2px 6px rgba(255, 152, 0, 0.3);
}

/* Text Handling */
#historyTable small {
  display: block;
  max-width: 100%;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  line-height: 1.3;
  font-size: 0.8rem;
  word-break: break-word;
  word-wrap: break-word;
  color: var(--text-secondary);
}

#historyTable small[title] {
  cursor: help;
  text-decoration: underline dotted;
}

#historyTable strong {
  color: var(--primary-dark);
  font-weight: 700;
}

/* Search Box Styling */
.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 0;
  animation: slideIn 0.4s ease-in-out;
  height: 44px;
  width: 100%;
}

.search-input-wrapper i {
  position: absolute;
  left: 12px;
  color: #1a0f33;
  font-size: 1.1rem;
  pointer-events: none;
  top: 50%;
  transform: translateY(-50%);
}

#historySearchInput {
  border: 2px solid #1a0f33 !important;
  border-radius: 20px !important;
  padding: 8px 15px 8px 40px !important;
  font-size: 0.95rem !important;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(26, 15, 51, 0.1);
  width: 100% !important;
  background: linear-gradient(135deg, rgba(245, 243, 249, 0.8) 0%, rgba(255, 255, 255, 0.9) 100%) !important;
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  line-height: 44px !important;
  vertical-align: middle !important;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  margin: 0 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}

#historySearchInput:focus {
  border-color: #1a0f33 !important;
  box-shadow: 0 4px 15px rgba(26, 15, 51, 0.2);
  outline: none;
  background: linear-gradient(135deg, rgba(245, 243, 249, 1) 0%, rgba(255, 255, 255, 1) 100%) !important;
}

#historySearchInput::placeholder {
  color: #999;
  font-weight: 500;
}

.search-box-container {
  animation: slideIn 0.4s ease-in-out;
  margin-bottom: 0;
  flex: 1;
  height: 44px;
  display: flex;
  align-items: center;
}

/* No Search Results */
#noSearchResults {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 1.1rem;
  font-weight: 500;
  background: linear-gradient(135deg, rgba(26, 15, 51, 0.05) 0%, rgba(26, 15, 51, 0.02) 100%);
  border-radius: 12px;
  border: 2px dashed #1a0f33;
  animation: slideIn 0.3s ease-in-out;
}

/* Export/Action Buttons */
.history-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  animation: slideIn 0.4s ease-in-out;
}

.btn-export {
  background: linear-gradient(145deg, #1a0f33, #150b2b) !important;
  border: none !important;
  color: white !important;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 16px;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(26, 15, 51, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  height: 44px;
  min-height: 44px;
}

.btn-export:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(26, 15, 51, 0.3);
}

.btn-export:active {
  transform: translateY(0);
}

.btn-delete {
  background: linear-gradient(145deg, #265f3d, #1a4d2e) !important;
  border: none !important;
  color: white !important;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 16px;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(38, 95, 61, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  height: 44px;
  min-height: 44px;
}

.btn-delete:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(38, 95, 61, 0.3);
}

.btn-delete:active {
  transform: translateY(0);
}

/* Pagination Styling */
.history-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  animation: slideIn 0.4s ease-in-out;
}

.pagination {
  display: flex;
  list-style: none;
  gap: 0.25rem;
  padding: 0;
  margin: 0;
}

.pagination .page-item {
  transition: all 0.3s ease;
}

.pagination .page-item.active .page-link {
  background: linear-gradient(145deg, #1a0f33, #150b2b);
  border-color: #1a0f33;
  color: white;
  box-shadow: 0 4px 15px rgba(26, 15, 51, 0.3);
}

.pagination .page-link {
  color: #241443;
  border: 1px solid #1a0f33;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(245, 243, 249, 0.6) 0%, rgba(255, 255, 255, 0.8) 100%);
}

.pagination .page-link:hover {
  background: linear-gradient(135deg, rgba(245, 243, 249, 0.9) 0%, rgba(255, 255, 255, 1) 100%);
  color: #241443;
  transform: translateY(-2px);
}

/* ===== ANIMATIONS ===== */

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ===== RESPONSIVE STYLES ===== */

/* Tablet Responsive (768px and below) */
@media (max-width: 768px) {
  #historyTable {
    font-size: 0.8rem;
  }

  #historyTable thead th {
    padding: 8px 4px;
    font-size: 0.75rem;
  }

  #historyTable tbody td {
    padding: 8px 4px;
    font-size: 0.75rem;
  }

  #historyTable .badge {
    font-size: 0.7rem;
    padding: 2px 6px;
  }

  #historyTable small {
    font-size: 0.75rem;
  }

  /* Adjust column widths for tablet */
  #historyTable thead th:nth-child(1) {
    width: 12%;
  }

  #historyTable thead th:nth-child(2) {
    width: 10%;
  }

  #historyTable thead th:nth-child(3) {
    width: 10%;
  }

  #historyTable thead th:nth-child(4) {
    width: 10%;
  }

  #historyTable thead th:nth-child(5) {
    width: 8%;
  }

  #historyTable thead th:nth-child(6) {
    width: 6%;
  }

  #historyTable thead th:nth-child(7) {
    width: 6%;
  }

  #historyTable thead th:nth-child(8) {
    width: 18%;
  }

  #historyTable thead th:nth-child(9) {
    width: 6%;
  }

  #historyTable thead th:nth-child(10) {
    width: 14%;
  }

  #historyTable tbody td:nth-child(1) {
    width: 12%;
  }

  #historyTable tbody td:nth-child(2) {
    width: 10%;
  }

  #historyTable tbody td:nth-child(3) {
    width: 10%;
  }

  #historyTable tbody td:nth-child(4) {
    width: 10%;
  }

  #historyTable tbody td:nth-child(5) {
    width: 8%;
  }

  #historyTable tbody td:nth-child(6) {
    width: 6%;
  }

  #historyTable tbody td:nth-child(7) {
    width: 6%;
  }

  #historyTable tbody td:nth-child(8) {
    width: 18%;
  }

  #historyTable tbody td:nth-child(9) {
    width: 6%;
  }

  #historyTable tbody td:nth-child(10) {
    width: 14%;
  }

  .history-actions {
    gap: 0.5rem;
  }

  .btn-export,
  .btn-delete {
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  .search-input-wrapper i {
    left: 10px;
    font-size: 1rem;
  }

  #historySearchInput {
    padding: 8px 12px 8px 35px !important;
    font-size: 0.95rem !important;
  }
}

/* Mobile Responsive (576px and below) - Compact View */
@media (max-width: 576px) {
  #historyTable {
    font-size: 0.75rem;
  }

  #historyTable thead th {
    padding: 6px 2px;
    font-size: 0.65rem;
    min-width: auto;
  }

  #historyTable tbody td {
    padding: 6px 2px;
    font-size: 0.7rem;
  }

  #historyTable .badge {
    font-size: 0.65rem;
    padding: 2px 4px;
    min-width: auto;
  }

  #historyTable small {
    font-size: 0.7rem;
  }

  #historyTable i {
    font-size: 0.9rem;
    margin-right: 1px;
  }

  /* Adjust column widths for mobile */
  #historyTable thead th:nth-child(1) {
    width: 13%;
  }

  #historyTable thead th:nth-child(2) {
    width: 10%;
  }

  #historyTable thead th:nth-child(3) {
    width: 10%;
  }

  #historyTable thead th:nth-child(4) {
    width: 10%;
  }

  #historyTable thead th:nth-child(5) {
    width: 8%;
  }

  #historyTable thead th:nth-child(6) {
    width: 6%;
  }

  #historyTable thead th:nth-child(7) {
    width: 6%;
  }

  #historyTable thead th:nth-child(8) {
    width: 15%;
  }

  #historyTable thead th:nth-child(9) {
    width: 6%;
  }

  #historyTable tbody td:nth-child(1) {
    width: 13%;
  }

  #historyTable tbody td:nth-child(2) {
    width: 10%;
  }

  #historyTable tbody td:nth-child(3) {
    width: 10%;
  }

  #historyTable tbody td:nth-child(4) {
    width: 10%;
  }

  #historyTable tbody td:nth-child(5) {
    width: 8%;
  }

  #historyTable tbody td:nth-child(6) {
    width: 6%;
  }

  #historyTable tbody td:nth-child(7) {
    width: 6%;
  }

  #historyTable tbody td:nth-child(8) {
    width: 15%;
  }

  #historyTable tbody td:nth-child(9) {
    width: 6%;
  }

  .history-header h5 {
    font-size: 1.2rem;
  }

  .history-header h5 i {
    font-size: 1.4rem;
  }

  .history-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-export,
  .btn-delete {
    width: 100%;
    justify-content: center;
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .search-input-wrapper i {
    left: 8px;
    font-size: 0.9rem;
  }

  #historySearchInput {
    padding: 8px 10px 8px 30px !important;
    font-size: 0.9rem !important;
  }

  .history-pagination {
    gap: 0.25rem;
  }

  .pagination .page-link {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  #noSearchResults {
    padding: 20px 10px;
    font-size: 0.95rem;
  }
}

/* Extra Small Devices (480px and below) */
@media (max-width: 480px) {
  #historyTable thead th {
    font-size: 0.6rem;
    padding: 4px 1px;
  }

  #historyTable tbody td {
    font-size: 0.65rem;
    padding: 4px 1px;
  }

  .history-header {
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .search-box-container {
    margin-bottom: 1rem;
  }

  .history-actions {
    margin-bottom: 1rem;
  }
}
