/* public/ui-kit.css — v0.37.0
 *
 * Styles for the shared UI kit:
 *   1. .pxs-*  — searchable dropdown popup (ui-kit.js)
 *   2. .tt-*   — table tools: column picker + per-column filters (table-tools.js)
 *   3. .tk-*   — support ticket widget (tickets.js)
 *
 * Loaded AFTER styles.css so it can win specificity ties without !important.
 */

/* ═══════════════════════════════════════════════════════════════════════════
   1. Searchable dropdown
   ═══════════════════════════════════════════════════════════════════════════ */

.pxs-pop {
  position: fixed;
  z-index: 100000;
  display: none;
  background: #fff;
  border: 1px solid #dbe1ea;
  border-radius: 12px;
  box-shadow: 0 4px 8px -2px rgba(15, 23, 42, .08),
              0 16px 40px -12px rgba(15, 23, 42, .22);
  overflow: hidden;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13.5px;
  color: #0f172a;
  animation: pxs-in 110ms ease-out;
}

@keyframes pxs-in {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: none; }
}

.pxs-search-wrap {
  padding: 8px;
  border-bottom: 1px solid #eef1f6;
  background: #fbfcfe;
}

.pxs-search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid #d8dee9;
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  color: #0f172a;
  background: #fff;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.pxs-search:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}
.pxs-search::placeholder { color: #9aa5b6; }

.pxs-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px;
}

.pxs-group {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #94a3b8;
}

.pxs-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pxs-opt-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pxs-opt mark {
  background: #fde68a;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
  font-weight: 600;
}
.pxs-opt.is-cursor   { background: #f1f5f9; }
.pxs-opt.is-selected { color: #6d28d9; font-weight: 600; }
.pxs-opt.is-selected.is-cursor { background: #f3efff; }
.pxs-opt.is-disabled { color: #b6bfcc; cursor: not-allowed; }
.pxs-tick { color: #7c3aed; font-size: 12px; }

.pxs-empty {
  padding: 18px 12px;
  text-align: center;
  color: #94a3b8;
  font-size: 12.5px;
}

.pxs-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border-top: 1px solid #eef1f6;
  background: #fbfcfe;
  font-size: 11px;
  color: #94a3b8;
}
.pxs-hint { white-space: nowrap; }

/* The native select stays in place; we only mark it while our popup is up. */
select.pxs-open {
  border-color: #7c3aed !important;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}

@media (max-width: 620px) {
  .pxs-hint { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   2. Table tools — column picker + per-column filters
   ═══════════════════════════════════════════════════════════════════════════ */

/* Horizontal scroll so the trailing column can never be clipped off-screen.
   This was the "last column hides from display" report. */
.table-card { overflow-x: auto; }
.table-card > table { min-width: 100%; }

.tt-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 10px;
  border-bottom: 1px solid #eef1f6;
  background: #fbfcfe;
  font-size: 12.5px;
  position: sticky;
  left: 0;
}

.tt-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid #d8dee9;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.tt-btn:hover { border-color: #b9c2d0; background: #f8fafc; }
.tt-btn.is-active {
  border-color: #7c3aed;
  background: #f5f1ff;
  color: #6d28d9;
}

.tt-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 9px;
  border-radius: 999px;
  background: #ede9fe;
  color: #5b21b6;
  font-size: 11.5px;
  font-weight: 600;
}
.tt-chip button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  opacity: .65;
}
.tt-chip button:hover { opacity: 1; }

.tt-count { color: #64748b; margin-left: auto; white-space: nowrap; }

/* Header filter caret injected into each <th> */
th.tt-th { position: relative; white-space: nowrap; }
.tt-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #94a3b8;
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  transition: background 120ms ease, color 120ms ease;
}
.tt-caret:hover { background: #e8edf4; color: #475569; }
.tt-caret.is-on { background: #7c3aed; color: #fff; }

/* Shared popup for both the column picker and the column filters */
.tt-pop {
  position: fixed;
  z-index: 100000;
  display: none;
  width: 268px;
  background: #fff;
  border: 1px solid #dbe1ea;
  border-radius: 12px;
  box-shadow: 0 4px 8px -2px rgba(15, 23, 42, .08),
              0 16px 40px -12px rgba(15, 23, 42, .22);
  overflow: hidden;
  font-size: 13px;
  color: #0f172a;
}
.tt-pop-title {
  padding: 10px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #94a3b8;
}
.tt-pop-search { padding: 0 10px 8px; }
.tt-pop-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 9px;
  border: 1px solid #d8dee9;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  outline: none;
}
.tt-pop-search input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}
.tt-pop-list {
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 6px 6px;
}
.tt-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  line-height: 1.35;
}
.tt-opt:hover { background: #f4f6fa; }
.tt-opt input { margin: 0; flex: none; }
.tt-opt span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tt-opt.is-locked { opacity: .5; cursor: not-allowed; }
.tt-pop-empty { padding: 16px 12px; text-align: center; color: #94a3b8; font-size: 12.5px; }
.tt-pop-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid #eef1f6;
  background: #fbfcfe;
}
.tt-pop-actions .tt-spacer { flex: 1; }
.tt-link {
  border: 0;
  background: none;
  color: #6d28d9;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 2px;
}
.tt-link:hover { text-decoration: underline; }
.tt-apply {
  padding: 5px 14px;
  border: 0;
  border-radius: 8px;
  background: #7c3aed;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.tt-apply:hover { filter: brightness(1.08); }

/* Row hidden by a column filter */
tr.tt-row-hidden { display: none !important; }

/* "0 of N rows" placeholder when a filter empties the table */
tr.tt-no-rows td {
  padding: 26px 12px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   3. Support ticket widget
   ═══════════════════════════════════════════════════════════════════════════ */

.tk-launch {
  width: calc(100% - 8px);
  margin: 2px 4px 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tk-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100001;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 24px;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(2px);
  overflow-y: auto;
}
.tk-backdrop.is-open { display: flex; }

.tk-modal {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px -16px rgba(15, 23, 42, .35);
  overflow: hidden;
  animation: tk-in 140ms ease-out;
}
@keyframes tk-in {
  from { opacity: 0; transform: translateY(-8px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

.tk-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #eef1f6;
}
.tk-head h3 { margin: 0; font-size: 16px; font-weight: 650; color: #0f172a; }
.tk-head p  { margin: 4px 0 0; font-size: 12.5px; color: #64748b; line-height: 1.5; }
.tk-close {
  margin-left: auto;
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 4px;
}
.tk-close:hover { color: #475569; }

.tk-body { padding: 16px 20px 4px; }
.tk-row { display: flex; gap: 12px; flex-wrap: wrap; }
.tk-field { margin-bottom: 14px; flex: 1 1 200px; min-width: 0; }
.tk-field label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
.tk-field select,
.tk-field input[type="text"],
.tk-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #d8dee9;
  border-radius: 9px;
  font-family: inherit;
  font-size: 13.5px;
  color: #0f172a;
  background: #fff;
  outline: none;
}
.tk-field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.tk-field select:focus,
.tk-field input:focus,
.tk-field textarea:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}

.tk-drop {
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  color: #64748b;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.tk-drop:hover, .tk-drop.is-over { border-color: #7c3aed; background: #faf8ff; }
.tk-drop strong { color: #6d28d9; }

.tk-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.tk-thumb {
  position: relative;
  width: 76px;
  height: 60px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}
.tk-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tk-thumb button {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, .72);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.tk-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 18px;
  border-top: 1px solid #eef1f6;
  background: #fbfcfe;
}
.tk-foot .tk-spacer { flex: 1; }
.tk-msg { font-size: 12.5px; }
.tk-msg.is-err { color: #b91c1c; }
.tk-msg.is-ok  { color: #047857; }
.tk-submit {
  padding: 9px 20px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #8b5cf6 0%, #7c3aed 100%);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px -1px rgba(124, 58, 237, .35);
}
.tk-submit:hover:not(:disabled) { filter: brightness(1.08); }
.tk-submit:disabled { background: #cbd5e1; box-shadow: none; cursor: not-allowed; }

.tk-prio-P1 { color: #b91c1c; font-weight: 700; }
.tk-prio-P2 { color: #c2410c; font-weight: 600; }
.tk-prio-P3 { color: #a16207; }
.tk-prio-P4 { color: #64748b; }

/* ═══════════════════════════════════════════════════════════════════════════
   4. Reports tab
   ═══════════════════════════════════════════════════════════════════════════ */

.rp-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.rp-tile {
  padding: 14px 16px;
  border: 1px solid #e8ecf2;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}
.rp-tile-v { font-size: 26px; font-weight: 680; line-height: 1.1; color: #0f172a; letter-spacing: -.02em; }
.rp-tile-l { margin-top: 4px; font-size: 12.5px; font-weight: 600; color: #475569; }
.rp-tile-s { margin-top: 2px; font-size: 11.5px; color: #94a3b8; }
.rp-tile.is-good { border-left: 3px solid #34d399; }
.rp-tile.is-warn { border-left: 3px solid #f59e0b; }
.rp-tile.is-bad  { border-left: 3px solid #ef4444; }
.rp-tile.is-bad  .rp-tile-v { color: #b91c1c; }

.rp-card {
  border: 1px solid #e8ecf2;
  border-radius: 14px;
  background: #fff;
  padding: 16px 18px 18px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}
.rp-card-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.rp-card-head h3 { margin: 0; font-size: 15.5px; font-weight: 650; color: #0f172a; }
.rp-card-head p  { margin: 3px 0 0; font-size: 12.5px; color: #64748b; line-height: 1.5; max-width: 62ch; }
.rp-card-head select {
  margin-left: auto;
  padding: 6px 10px;
  border: 1px solid #d8dee9;
  border-radius: 9px;
  font-size: 13px;
  background: #fff;
  color: #334155;
}

.rp-chart {
  position: relative;
  height: 280px;
  margin-bottom: 14px;
}
.rp-chart canvas { max-height: 280px; }

.rp-sub-head {
  margin: 18px 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #94a3b8;
}

.rp-empty, .rp-nochart {
  padding: 26px 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  background: #fbfcfe;
  border: 1px dashed #e2e8f0;
  border-radius: 10px;
}

/* Report tables are read-only summaries — no column tools, no chrome. */
.rp-card .table-card { border-radius: 10px; overflow-x: auto; }
.rp-card .table-card table { font-size: 13px; }
.rp-card .table-card th { white-space: nowrap; }

@media (max-width: 720px) {
  .rp-chart { height: 240px; }
  .rp-card-head select { margin-left: 0; width: 100%; }
}
