/* =============================================================================
   CDP GLOBAL THEME  (single source of design for the whole admin)
   Loaded once in base_site.html, so EVERY page gets it:
     - changelist pages (encounter, participant, question, imd, location, ...)
     - custom pages (Mongo Logs, future reports)
   Edit design HERE and nowhere else.
   ============================================================================= */

/* ============================================================
   NATIVE Django changelist table  (used by most changelist modules)
   ============================================================ */
#changelist .results {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-top: 16px;
}
#changelist .results::-webkit-scrollbar { height: 8px; }
#changelist .results::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
#changelist .results::-webkit-scrollbar-thumb { background: #6c35a0; border-radius: 4px; }

#result_list {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
#result_list thead th {
  background: #6c35a0 !important;
  border-right: 1px solid #7e4ab0;
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
}
#result_list thead th,
#result_list thead th *,
#result_list thead th a,
#result_list thead th a:link,
#result_list thead th a:visited { color: #fff !important; }
#result_list thead th.sorted,
#result_list thead th.sortable:hover { background: #5a2b88 !important; }

#result_list tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid #eee;
  border-right: 1px solid #f0e8f8;
  vertical-align: middle;
}
#result_list tbody tr:nth-child(even) { background: #faf6fd; }
#result_list tbody tr:hover { background: #ede4f5 !important; }
#result_list tbody td a { color: #6c35a0; font-weight: 600; text-decoration: none; }
#result_list tbody td a:hover { text-decoration: underline; }

.paginator {
  padding-top: 12px;
  font-size: 13px;
  color: #555;
  border-top: none !important;
  background: transparent !important;
}
.paginator a,
.paginator .this-page,
.paginator .end {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 8px; margin: 0 2px;
  border: 1px solid #c8a8e9; border-radius: 4px;
  color: #6c35a0 !important; text-decoration: none; font-size: 12px;
}
.paginator .this-page { background: #6c35a0; color: #fff !important; font-weight: 700; }

/* ============================================================
   REUSABLE FILTER PANEL  (standardised to encounter look)
   ============================================================ */
.cdp-filter-panel {
  background: #f8f8f8; border: 1px solid #ddd;
  border-radius: 6px; padding: 16px 20px; margin-bottom: 20px;
}
.cdp-filter-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }

.cdp-field { display: flex; flex-direction: column; min-width: 160px; }
.cdp-field.w-md { min-width: 180px; }
.cdp-field.w-lg { min-width: 200px; }
.cdp-field.w-xl { min-width: 280px; }
.cdp-field label { font-size: 12px; font-weight: 600; margin-bottom: 4px; }

.cdp-input {
  padding: 6px 10px; border-radius: 4px;
  border: 1px solid #ccc; font-size: 13px;
  box-sizing: border-box;
}
select.cdp-input { min-height: 38px; line-height: 1.5; vertical-align: middle; }

.cdp-filter-actions { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

.cdp-info-bar {
  display: none; margin-top: 10px;
  font-size: 13px; color: #856404;
  background: #fff3cd; border: 1px solid #ffc107;
  padding: 8px 14px; border-radius: 4px;
}

/* ============================================================
   BUTTONS / LINKS
   ============================================================ */
.cdp-btn {
  border: none; border-radius: 4px; padding: 7px 14px;
  cursor: pointer; font-size: 13px; text-decoration: none; display: inline-block;
}
.cdp-btn-primary   { background: #6c35a0; color: #fff !important; padding: 7px 18px; }
.cdp-btn-secondary { background: #555;    color: #fff !important; }
.cdp-btn-export    { background: #1cc88a; color: #fff !important; font-weight: 600; }
.cdp-link { color: #6c35a0; font-weight: 600; text-decoration: none; }

/* ============================================================
   CUSTOM TABLE  (encounter / mongo / report style)
   ============================================================ */
.cdp-table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid #ddd; border-radius: 4px; margin-top: 16px;
}
.cdp-table-wrap::-webkit-scrollbar { height: 8px; }
.cdp-table-wrap::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.cdp-table-wrap::-webkit-scrollbar-thumb { background: #6c35a0; border-radius: 4px; }

.cdp-table {
  width: 100%; min-width: 2400px; border-collapse: collapse;
  font-size: 12px; white-space: nowrap;
}
.cdp-table thead tr { background: #6c35a0; color: #fff; }
.cdp-table thead th {
  padding: 9px 12px; text-align: left; font-weight: 600;
  border-right: 1px solid #7e4ab0;
}
.cdp-table tbody tr:nth-child(even) { background: #faf6fd; }
.cdp-table tbody tr:hover { background: #ede4f5; }
.cdp-table tbody td {
  padding: 7px 12px; border-bottom: 1px solid #eee;
  border-right: 1px solid #f0e8f8; vertical-align: middle;
}
.cdp-table tbody td a { color: #6c35a0; font-weight: 600; text-decoration: none; }
.cell-truncate { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

.badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-male    { background:#d0e8ff; color:#155fa0; }
.badge-female  { background:#ffe0f0; color:#a0155a; }
.badge-other   { background:#e8ffe0; color:#2a7a00; }
.badge-unknown { background:#eee;    color:#666;    }
.badge-yes     { background:#e8ffe0; color:#2a7a00; }
.badge-no      { background:#eee;    color:#666;    }
.badge-status  { background:#d0e8ff; color:#155fa0; }

.cdp-pagination {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; font-size: 13px; flex-wrap: wrap; gap: 8px;
}
.cdp-pagination .page-info { color: #555; }
.cdp-pagination .page-links { display: flex; gap: 4px; }
.cdp-pagination .page-links a,
.cdp-pagination .page-links span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 6px;
  border: 1px solid #c8a8e9; border-radius: 4px;
  color: #6c35a0; text-decoration: none; font-size: 12px; cursor: pointer;
}
.cdp-pagination .page-links .current  { background: #6c35a0; color: #fff; font-weight: 700; }
.cdp-pagination .page-links .disabled { color: #ccc; border-color: #e0e0e0; pointer-events: none; }
.cdp-pagination .page-meta { border: none; color: #555; }

.cdp-empty { text-align: center; padding: 48px; color: #999; font-size: 14px; }

/* ============================================================
   REUSABLE MULTI-SELECT DROPDOWN  (IMD warnings widget)
   ============================================================ */
.cdp-dd { position: relative; }
.cdp-dd-btn {
  min-width: 230px; min-height: 38px; padding: 7px 10px;
  border: 1px solid #ccc; border-radius: 4px; font-size: 13px;
  background: #fff; cursor: pointer; text-align: left;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; box-sizing: border-box;
}
.cdp-dd-caret { color: #6c35a0; font-size: 11px; }
.cdp-dd-panel {
  display: none; position: absolute; z-index: 1000; top: 100%; left: 0;
  margin-top: 4px; min-width: 290px; max-height: 260px; overflow-y: auto;
  background: #fff; border: 1px solid #c8a8e9; border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12); padding: 6px 0;
}
.cdp-dd-panel label {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  font-size: 13px; font-weight: 400; color: #333; cursor: pointer; white-space: nowrap;
}
.cdp-dd-panel label:hover { background: #f3ecfa; }
.cdp-dd-panel input[type="checkbox"] { accent-color: #6c35a0; }
.cdp-dd-clear {
  border-top: 1px solid #eee; padding: 7px 14px;
  font-size: 12px; color: #6c35a0; cursor: pointer; font-weight: 600;
}
.cdp-dd-clear:hover { text-decoration: underline; }

/* ============================================================
   REUSABLE AUTOCOMPLETE SEARCH  (Location search widget)
   ============================================================ */
.cdp-ac { position: relative; }
.cdp-ac-results {
  display: none; position: absolute; z-index: 1000; top: 100%; left: 0;
  margin-top: 4px; min-width: 280px; max-height: 280px; overflow-y: auto;
  background: #fff; border: 1px solid #c8a8e9; border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}
.cdp-ac-results div { padding: 8px 14px; font-size: 13px; color: #333; cursor: pointer; white-space: nowrap; }
.cdp-ac-results div:hover { background: #f3ecfa; }
.cdp-ac-results .cdp-ac-empty { color: #999; cursor: default; }


/* CDP numbered pagination - small white boxes, purple numbers */
.paginator a, .paginator a:link, .paginator a:visited,
.paginator .this-page {
    display:inline-block; min-width:20px; padding:2px 6px; margin:0 2px;
    text-align:center; border-radius:4px; font-size:12px; line-height:18px;
    text-decoration:none;
}
.paginator a, .paginator a:link, .paginator a:visited {
    background:#ffffff !important; color:#6c35a0 !important;
    border:1px solid #6c35a0 !important;
}
.paginator a:hover { background:#6c35a0 !important; color:#ffffff !important; }
.paginator .this-page {
    background:#6c35a0 !important; color:#ffffff !important;
    border:1px solid #6c35a0 !important; font-weight:600;
}