/* =========================================================
   List pages (form/list-*.php)
   - .list-card    : the card that wraps a list
   - .list-header  : title + count pill + summary + Add button
   - .list-table   : the DataTable itself
   DataTables controls (length / search / info / paging) are
   restyled for every .dataTables_wrapper on the site.
   ========================================================= */

:root {
  --list-primary: #4154f1;
  --list-primary-dark: #2f3fd8;
  --list-title: #012970;
  --list-text: #3d4461;
  --list-muted: #8a93ad;
  --list-border: #eef1f7;
  --list-head-bg: #f7f9fc;
  --list-hover-bg: #f8faff;
}

/* ---------- Card ---------- */
.list-card {
  border: 1px solid var(--list-border);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(1, 41, 112, 0.05);
}
.list-card > .card-body {
  padding: 24px 24px 20px;
}

/* ---------- Header ---------- */
.list-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.list-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: "Nunito", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--list-title);
}
.list-count {
  display: inline-block;
  min-width: 34px;
  padding: 3px 11px;
  border-radius: 999px;
  background: #eef0f5;
  color: #444c66;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.list-subtitle {
  margin-top: 4px;
  font-size: 14px;
  color: var(--list-muted);
}
.list-subtitle:empty {
  display: none;
}
.list-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
  background: var(--list-primary);
  border-color: var(--list-primary);
  box-shadow: 0 4px 12px rgba(65, 84, 241, 0.25);
}
.list-add-btn:hover,
.list-add-btn:focus {
  background: var(--list-primary-dark);
  border-color: var(--list-primary-dark);
}
.list-add-btn i {
  font-size: 16px;
}

/* ---------- Filter chips (e.g. dashboard Today / Upcoming / Past) ---------- */
.list-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  border: 1px solid var(--list-border);
  border-radius: 999px;
  background: #fff;
  color: var(--list-text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.list-chip:hover,
.list-chip:focus {
  border-color: #d5dafb;
  background: #f5f6ff;
  color: var(--list-primary);
}
.list-chip-count {
  display: inline-block;
  min-width: 26px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}
.list-chip-count.is-success { background: #e3f6ea; color: #1a7f3c; }
.list-chip-count.is-info    { background: #e2f5fb; color: #0b7593; }
.list-chip-count.is-primary { background: #eaedff; color: #3142d6; }
.list-chip-count.is-muted   { background: #eef0f5; color: #5b6380; }
.list-chip-count.is-danger  { background: #fdecec; color: #c62828; }
.list-chip-count.is-warning { background: #fff4de; color: #a86400; }
.list-chip-count.is-orange  { background: #ffeddf; color: #c2410c; }
button.list-chip {
  font-family: inherit;
  cursor: pointer;
}
.list-chip.is-active {
  border-color: var(--list-primary);
  background: #f0f2ff;
  color: var(--list-primary);
}
.list-add-btn.list-add-btn-sm {
  padding: 6px 16px;
  font-size: 14px;
  border-radius: 999px;
}

/* ---------- DataTables controls (site-wide) ---------- */
.dataTables_wrapper {
  color: var(--list-text);
}
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  margin-bottom: 14px;
  color: var(--list-text);
}
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid #dfe3ec;
  border-radius: 8px;
  background-color: #fff;
  color: var(--list-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dataTables_wrapper .dataTables_length select {
  padding: 5px 8px;
  margin: 0 6px;
}
.dataTables_wrapper .dataTables_filter input {
  width: 240px;
  max-width: 100%;
  padding: 6px 12px;
  margin-left: 8px;
}
.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--list-primary);
  box-shadow: 0 0 0 3px rgba(65, 84, 241, 0.12);
}
.dataTables_wrapper .dataTables_info {
  padding-top: 16px;
  font-size: 13px;
  color: var(--list-muted);
}
.dataTables_wrapper .dataTables_paginate {
  padding-top: 12px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
  min-width: 34px;
  margin-left: 4px;
  padding: 5px 10px;
  border: 1px solid transparent !important;
  border-radius: 8px;
  color: var(--list-text) !important;
  font-size: 13px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: #eef0fd !important;
  border-color: transparent !important;
  color: var(--list-primary) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--list-primary) !important;
  border-color: var(--list-primary) !important;
  color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  background: transparent !important;
  color: #c3c8d6 !important;
}

/* ---------- Table ---------- */
table.list-table.dataTable,
table.list-table {
  width: 100% !important;
  margin: 0 !important;
  border-collapse: collapse !important;
  border: 0;
  color: var(--list-text);
}
table.list-table > thead > tr > th {
  padding: 14px 16px !important;
  background: var(--list-head-bg);
  border: 0 !important;
  border-bottom: 1px solid var(--list-border) !important;
  color: var(--list-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
table.list-table > thead > tr > th:first-child {
  border-top-left-radius: 10px;
}
table.list-table > thead > tr > th:last-child {
  border-top-right-radius: 10px;
}
table.list-table > tbody > tr > td {
  padding: 16px !important;
  border: 0 !important;
  border-bottom: 1px solid var(--list-border) !important;
  background: transparent !important;
  box-shadow: none !important;
  vertical-align: middle;
  font-size: 14px;
}
table.list-table > tbody > tr {
  background: #fff !important;
  transition: background-color 0.12s;
}
table.list-table > tbody > tr:hover {
  background: var(--list-hover-bg) !important;
}
table.list-table.dataTable.no-footer {
  border-bottom: 0 !important;
}
table.list-table td strong,
table.list-table td .fw-bold {
  color: #1f2640;
}
table.list-table td small,
table.list-table td .text-muted {
  color: var(--list-muted) !important;
}

/* Sort arrows: quieter, primary when active */
table.list-table.dataTable thead > tr > th.sorting:before,
table.list-table.dataTable thead > tr > th.sorting:after,
table.list-table.dataTable thead > tr > th.sorting_asc:before,
table.list-table.dataTable thead > tr > th.sorting_asc:after,
table.list-table.dataTable thead > tr > th.sorting_desc:before,
table.list-table.dataTable thead > tr > th.sorting_desc:after {
  opacity: 0.25;
}
table.list-table.dataTable thead > tr > th.sorting_asc:before,
table.list-table.dataTable thead > tr > th.sorting_desc:after {
  opacity: 1;
  color: var(--list-primary);
}

/* Responsive child-row toggle (a CSS triangle drawn with borders) */
table.list-table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before {
  border-left-color: var(--list-primary);
  opacity: 0.7;
}
table.list-table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before {
  border-top-color: var(--list-primary);
  border-left-color: transparent;
}

/* ---------- Soft badges / status pills ---------- */
table.list-table .badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
table.list-table .badge.bg-success   { background: #e3f6ea !important; color: #1a7f3c !important; }
table.list-table .badge.bg-secondary { background: #eef0f5 !important; color: #5b6380 !important; }
table.list-table .badge.bg-danger    { background: #fdecec !important; color: #c62828 !important; }
table.list-table .badge.bg-primary   { background: #eaedff !important; color: #3142d6 !important; }
table.list-table .badge.bg-warning   { background: #fff4de !important; color: #a86400 !important; }
table.list-table .badge.bg-info      { background: #e2f5fb !important; color: #0b7593 !important; }
table.list-table .badge.bg-light     { background: #f4f5f8 !important; color: var(--list-muted) !important; border: 0 !important; }

/* ---------- Row actions ---------- */
table.list-table .actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
table.list-table .actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0 !important;
  border-radius: 8px;
  background: transparent !important;
  color: #8a93ad;
  font-size: 16px;
  text-decoration: none;
  transition: background-color 0.12s, color 0.12s;
}
table.list-table .actions a:hover {
  background: #eef0fd !important;
  color: var(--list-primary);
}
table.list-table .actions a[href*="md=2"]:hover {
  background: #fdecec !important;
  color: #d32f2f;
}

/* Labelled action (e.g. "Track"): a small outlined pill instead of a bare icon */
table.list-table .actions a.list-action-label {
  width: auto;
  gap: 5px;
  padding: 0 12px;
  border: 1px solid #d5dafb !important;
  border-radius: 999px;
  color: var(--list-primary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
table.list-table .actions a.list-action-label:hover {
  border-color: var(--list-primary) !important;
  background: var(--list-primary) !important;
  color: #fff;
}
table.list-table .actions a.list-action-label i {
  font-size: 14px;
}

/* ---------- Enquiry follow-up status ---------- */
/* One colour per status, used by the pill, its dot and the row's left edge. */
.fu-overdue   { --fu: #d32f2f; --fu-bg: #fdecec; --fu-text: #b71c1c; }
.fu-pending   { --fu: #ea580c; --fu-bg: #ffeddf; --fu-text: #c2410c; }
.fu-due       { --fu: #f59e0b; --fu-bg: #fff4de; --fu-text: #a86400; }
.fu-scheduled { --fu: #0ea5c6; --fu-bg: #e2f5fb; --fu-text: #0b7593; }
.fu-done      { --fu: #22a355; --fu-bg: #e3f6ea; --fu-text: #1a7f3c; }
.fu-new       { --fu: #9aa3bb; --fu-bg: #eef0f5; --fu-text: #5b6380; }
.fu-completed { --fu: #7c3aed; --fu-bg: #f1eafe; --fu-text: #5b21b6; }

.fu-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--fu-bg);
  color: var(--fu-text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.fu-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fu);
  flex-shrink: 0;
}
.fu-detail {
  margin-top: 5px;
  font-size: 12px;
  color: var(--list-muted);
}
.fu-overdue .fu-detail,
.fu-due .fu-detail {
  color: var(--fu-text);
  font-weight: 600;
}

/* Row highlight: every enquiry row is tinted in its status colour with a
   thick left edge (board: first cell; dashboard: the time cell). */
table.list-table > tbody > tr.fu-row > td,
tr.fu-row > td {
  background-color: color-mix(in srgb, var(--fu-bg) 60%, #fff) !important;
}
table.list-table > tbody > tr.fu-row:hover > td,
tr.fu-row:hover > td {
  background-color: var(--fu-bg) !important;
}
/* Nothing to act on yet: keep "Awaiting meeting" rows plain so the others stand out. */
table.list-table > tbody > tr.fu-row.fu-new > td,
tr.fu-row.fu-new > td {
  background-color: #fff !important;
}
table.list-table > tbody > tr.fu-row.fu-new:hover > td,
tr.fu-row.fu-new:hover > td {
  background-color: var(--list-hover-bg) !important;
}
table.list-table > tbody > tr.fu-row > td:first-child,
tr.fu-row > td.enq-today-time {
  box-shadow: inset 5px 0 0 var(--fu) !important;
  padding-left: 16px !important;
}

/* Urgent statuses get a solid pill so they stand out from across the room. */
.fu-overdue .fu-pill,
.fu-pill.fu-overdue,
.fu-pending .fu-pill,
.fu-pill.fu-pending,
.fu-due .fu-pill,
.fu-pill.fu-due {
  background: var(--fu);
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--fu) 35%, transparent);
}
.fu-overdue .fu-pill .fu-dot,
.fu-pill.fu-overdue .fu-dot,
.fu-pending .fu-pill .fu-dot,
.fu-pill.fu-pending .fu-dot,
.fu-due .fu-pill .fu-dot,
.fu-pill.fu-due .fu-dot {
  background: #fff;
  animation: fu-blink 1.4s ease-in-out infinite;
}
@keyframes fu-blink {
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  .fu-pill .fu-dot { animation: none !important; }
}

/* The next follow-up date is the useful bit for scheduled rows. */
.fu-scheduled .fu-detail {
  color: var(--fu-text);
  font-weight: 600;
}

/* Status chips on the board take their status colour when selected. */
.list-chip[class*="fu-"]:hover {
  border-color: var(--fu);
  background: var(--fu-bg);
  color: var(--fu-text);
}
.list-chip[class*="fu-"].is-active {
  border-color: var(--fu);
  background: var(--fu);
  color: #fff;
}
.list-chip[class*="fu-"].is-active .fu-dot {
  background: #fff;
}
.list-chip[class*="fu-"].is-active .list-chip-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* ---------- Tabs above a list (e.g. Enquiry Board) ---------- */
.list-card .nav-tabs {
  border-bottom: 1px solid var(--list-border);
}
.list-card .nav-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--list-muted);
  font-weight: 600;
}
.list-card .nav-tabs .nav-link.active,
.list-card .nav-tabs .nav-link:hover {
  border-bottom-color: var(--list-primary);
  background: transparent;
  color: var(--list-primary);
}

/* "Show entries" left and "Search" right on one row; style.css stacks them,
   which is kept for phones below. */
@media (min-width: 768px) {
  .dataTables_wrapper .dataTables_length {
    float: left;
    width: auto;
  }
  .dataTables_wrapper .dataTables_filter {
    float: right;
    width: auto;
  }
}

/* A table wider than the card scrolls inside it instead of stretching the page. */
.list-card .dataTables_wrapper {
  overflow-x: auto;
}

@media (max-width: 767.98px) {
  table.list-table > thead > tr > th {
    white-space: normal;
  }
  .list-card > .card-body {
    padding: 18px 16px 16px;
  }
  .dataTables_wrapper .dataTables_filter input {
    width: 100%;
    margin-left: 0;
  }
}
