/* ========== Base Styles ========== */
body {
  font-family: "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 20px;
  background: #f2f2f2;
  color: #2e2d2d;
}
h1 {
  text-align: center;
  margin-bottom: 20px;
  color: #357EC7;
}

/* ========== Dropdown Filters Container ========== */
#filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  background: #357EC7;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  margin-bottom: 16px;
}
.filter {
  display: flex;
  flex-direction: column;
}
.filter label {
  margin-bottom: 6px;
  font-weight: 600;
  color: #ffffff;
  font-size: 0.9rem;
}
.filter select {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fafafa;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}
.filter select:focus {
  outline: none;
  border-color: #357EC7;
}

/* ========== Combined Filter Row ========== */
.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  background: #357EC7;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  margin-bottom: 16px;
  align-items: start;
}
/* Power Units */
.filter-power {
  background: #fff;
  padding: 12px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}
.filter-power label {
  margin-bottom: 6px;
}
.filter-power input {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fafafa;
  transition: border-color 0.2s;
}
.filter-power input:focus {
  outline: none;
  border-color: #357EC7;
}

/* Unlimited Radius */
.unlimited-field {
  background: #fff;
  padding: 18px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}
.unlimited-field label {
  margin-bottom: 6px;
}
.unlimited-field input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Min Years In Business */
.filter-years {
  background: #fff;
  padding: 12px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}
.filter-years label {
  margin-bottom: 6px;
}
.filter-years input {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fafafa;
  transition: border-color 0.2s;
}
.filter-years input:focus {
  outline: none;
  border-color: #357EC7;
}

/* ========== Reset Button ========== */
#resetBtn {
  display: block;
  margin: 0 auto 30px;
  padding: 10px 20px;
  font-size: 0.9rem;
  color: #fff;
  background: #357EC7;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
#resetBtn:hover {
  background: #184b7f;
}
/* ========== Table Styling ========== */
.table-container {
  max-width: 2048px;
  margin: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  overflow-x: auto;
  overflow-y: visible;
  max-height: 600px;
}
#resultsTable {
  width: 100%;
  border-collapse: collapse;
  min-width: max-content;
}
#resultsTable th,
#resultsTable td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}
#resultsTable th {
  background: #357EC7;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: normal;
  word-break: break-word;
}
#resultsTable tr:nth-child(odd) {
  background: #dff4ff;
}
#resultsTable tr:nth-child(even) {
  background: #fff;
}
#resultsTable tr:hover {
  background: #dff4ff;
}
#resultsTable td a {
  color: #357EC7;
  text-decoration: none;
  font-weight: 500;
}
#resultsTable td a:hover {
  text-decoration: underline;
}

/* ========== Sortable Column Headers ========== */
th.sortable {
  cursor: pointer;
  white-space: nowrap;
}
th.sortable::after {
  content: " ⬍";
  font-size: 0.8rem;
  color: #fdfdfd;
  padding-left: 4px;
}
th.sortable.sorted-asc::after {
  content: " ▲";
}
th.sortable.sorted-desc::after {
  content: " ▼";
}

/* ========== Icon Buttons ========== */
.view-btn {
  background: none;
  border: none;
  color: #357EC7;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  transition: opacity 0.1s;
}
.view-btn:hover {
  color: #0d3d6d;
}
.view-btn:active {
  opacity: 0.6;
}

/* ========== Modal Styling ========== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
  overflow: auto;
  z-index: 10;
}
.modal-content {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.modal-close {
  float: right;
  font-size: 1.5rem;
  cursor: pointer;
}
.modal-content h2 {
  margin: 0;
  color: #357EC7;
}
.modal-body {
  margin-top: 10px;
  line-height: 1.5;
}

/* ========== No Results Message ========== */
#no-results-message {
  text-align: center;
  margin: 20px 0;
  color: #7f8c8d;
  font-style: italic;
}

@media print {
  @page {
    size: landscape;
    margin: 1cm;
  }

  body * {
    visibility: hidden;
  }

  .table-container,
  .table-container * {
    visibility: visible;
  }

  .table-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    overflow: visible;
  }

  /* Hide UI elements and interactive controls */
  #resetBtn,
  #printBtn,
  .view-btn,
  .sort-btn,
  input[type="checkbox"],
  select,
  input,
  label,
  button,
  #filters,
  .filter-row,
  #no-results-message {
    display: none !important;
  }

  /* Table layout and font tweaks */
  #resultsTable {
    table-layout: fixed;
    width: 100%;
  }

  #resultsTable th,
  #resultsTable td {
    padding: 6px 4px;
    font-size: 10pt;
    white-space: normal;
    word-break: break-word;
  }

  /* === HIDE SPECIFIC COLUMNS === */
  #resultsTable th:nth-child(1),
  #resultsTable td:nth-child(1),   /* ✓ Checkbox */
  #resultsTable th:nth-child(2),
  #resultsTable td:nth-child(2),   /* Guideline */
  #resultsTable th:nth-child(6),
  #resultsTable td:nth-child(6),   /* States */
  #resultsTable th:nth-child(11),
  #resultsTable td:nth-child(11),  /* Business Type */
  #resultsTable th:nth-child(18),
  #resultsTable td:nth-child(18)   /* URL */
  {
    display: none;
  }

  /* === SORT ICON HANDLING === */
  th.sortable::after {
    content: none !important;
  }

  th.sortable.sorted-asc::after {
    content: " (sorted ↑)" !important;
    font-size: 10pt;
    color: #fff;
    padding-left: 4px;
  }

  th.sortable.sorted-desc::after {
    content: " (sorted ↓)" !important;
    font-size: 10pt;
    color: #fff;
    padding-left: 4px;
  }
}


#printBtn {
  display: block;
  margin: 0 auto 20px;
  padding: 10px 20px;
  font-size: 0.9rem;
  color: #fff;
  background: #357EC7;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
#printBtn:hover {
  background: #134678;
}

.company-search {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  max-width: 300px;
}
.company-search label {
  font-weight: 600;
  margin-bottom: 4px;
}
#companySearch {
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #fafafa;
  font-size: 0.9rem;
}

.wholesaler-search {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  max-width: 300px;
}
.wholesaler-search label {
  font-weight: 600;
  margin-bottom: 4px;
}
#wholesalerSearch {
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #fafafa;
  font-size: 0.9rem;
}

.search-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-bar > div {
  flex: 1 1 300px;
}
