/* ============================================================================
   KPI Recruiter Chat Widget
   Floating launcher + slide-up FAQ panel — matches KPI Cupboard design language.
   ============================================================================ */

#kpi-chat-root,
#kpi-chat-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ============ Launcher (floating bubble bottom-right) ============ */
#kpi-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: linear-gradient(180deg, #ef4444 0%, #c62a2a 100%);
  color: #fff;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.22) inset,
    0 6px 20px rgba(232,53,56,0.45),
    0 0 0 1px rgba(0,0,0,0.2);
  display: grid;
  place-items: center;
  transition: transform 0.16s, box-shadow 0.2s;
  font-size: 0;
}
#kpi-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.28) inset,
    0 10px 28px rgba(232,53,56,0.55),
    0 0 0 1px rgba(0,0,0,0.2);
}
#kpi-chat-launcher:active { transform: translateY(0); }
#kpi-chat-launcher svg { width: 26px; height: 26px; display: block; }

#kpi-chat-launcher.pulse::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #ef4444;
  animation: kpiChatPulse 2.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes kpiChatPulse {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.5); opacity: 0; }
}

#kpi-chat-launcher .badge {
  position: absolute;
  top: -4px; right: -4px;
  background: #fff;
  color: #c62a2a;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 100px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

@media (max-width: 480px) {
  #kpi-chat-launcher { width: 52px; height: 52px; right: 16px; bottom: 16px; }
  #kpi-chat-launcher svg { width: 22px; height: 22px; }
}

/* ============ Panel (expanded chat window) ============ */
#kpi-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 96px;
  z-index: 9999;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: min(620px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.07);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 35%),
    radial-gradient(circle at 50% -10%, rgba(232,53,56,0.18), transparent 55%),
    linear-gradient(180deg, #15161b 0%, #0c0d11 100%);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 20px 50px -12px rgba(0,0,0,0.8),
    0 0 0 1px rgba(0,0,0,0.45);
  color: #e8e8ec;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s, transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#kpi-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (max-width: 640px) {
  #kpi-chat-panel {
    right: 0; left: 0; bottom: 0; top: 0;
    width: 100vw; height: 100vh; max-width: none;
    border-radius: 0;
  }
}

/* ============ Header ============ */
#kpi-chat-panel .head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
}
#kpi-chat-panel .head-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(180deg, #ef4444 0%, #c62a2a 100%);
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 2px 6px rgba(232,53,56,0.3);
}
#kpi-chat-panel .head-icon svg { width: 18px; height: 18px; color: #fff; }
#kpi-chat-panel .head-text { flex: 1; min-width: 0; }
#kpi-chat-panel .head-title {
  font-size: 14px;
  font-weight: 700;
  color: #e8e8ec;
  letter-spacing: -0.005em;
}
#kpi-chat-panel .head-sub {
  font-size: 11px;
  color: #6b6e78;
  margin-top: 2px;
}
#kpi-chat-panel .head-close {
  width: 32px; height: 32px;
  border: 0;
  background: rgba(255,255,255,0.04);
  color: #9ea1ac;
  border-radius: 8px;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 18px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}
#kpi-chat-panel .head-close:hover {
  background: rgba(255,255,255,0.08);
  color: #e8e8ec;
}

/* ============ Search bar ============ */
#kpi-chat-panel .search-wrap {
  position: relative;
  padding: 14px 18px 10px;
}
#kpi-chat-panel .search-wrap svg.s-icon {
  position: absolute;
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: #6b6e78;
  pointer-events: none;
}
#kpi-chat-panel input.search-input {
  width: 100%;
  background: rgba(0,0,0,0.4);
  color: #e8e8ec;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 11px 14px 11px 38px;
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
#kpi-chat-panel input.search-input::placeholder { color: #6b6e78; }
#kpi-chat-panel input.search-input:focus {
  outline: none;
  border-color: rgba(232,53,56,0.55);
  background: rgba(0,0,0,0.55);
  box-shadow: 0 0 0 3px rgba(232,53,56,0.14);
}

/* ============ Category tabs ============ */
#kpi-chat-panel .cat-tabs {
  display: flex;
  gap: 6px;
  padding: 0 18px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#kpi-chat-panel .cat-tabs::-webkit-scrollbar { display: none; }
#kpi-chat-panel .cat-tab {
  flex-shrink: 0;
  background: rgba(255,255,255,0.04);
  color: #9ea1ac;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 100px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
  font-family: inherit;
}
#kpi-chat-panel .cat-tab:hover {
  background: rgba(255,255,255,0.08);
  color: #e8e8ec;
}
#kpi-chat-panel .cat-tab.active {
  background: rgba(232,53,56,0.15);
  color: #ef4444;
  border-color: rgba(232,53,56,0.35);
}

/* ============ Q&A list (scrollable) ============ */
#kpi-chat-panel .qa-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
#kpi-chat-panel .qa-list::-webkit-scrollbar { width: 6px; }
#kpi-chat-panel .qa-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

#kpi-chat-panel .qa-item {
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.12s, background 0.12s;
}
#kpi-chat-panel .qa-item:hover {
  border-color: rgba(232,53,56,0.25);
}
#kpi-chat-panel .qa-item.open {
  border-color: rgba(232,53,56,0.45);
  background: rgba(232,53,56,0.04);
}
#kpi-chat-panel .qa-q {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #e8e8ec;
  padding: 12px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  line-height: 1.4;
}
#kpi-chat-panel .qa-q .chev {
  width: 14px; height: 14px;
  flex-shrink: 0;
  color: #6b6e78;
  transition: transform 0.2s, color 0.12s;
}
#kpi-chat-panel .qa-item.open .qa-q .chev {
  transform: rotate(180deg);
  color: #ef4444;
}
#kpi-chat-panel .qa-a {
  padding: 0 14px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s, padding 0.25s;
  color: #c9ccd4;
  font-size: 13px;
  line-height: 1.6;
}
#kpi-chat-panel .qa-item.open .qa-a {
  max-height: 600px;
  padding: 0 14px 14px;
}
#kpi-chat-panel .qa-a strong { color: #e8e8ec; }

#kpi-chat-panel .qa-empty,
#kpi-chat-panel .qa-no-match {
  text-align: center;
  padding: 32px 24px;
  color: #9ea1ac;
  font-size: 13px;
  line-height: 1.6;
}
#kpi-chat-panel .qa-no-match {
  background: rgba(245,158,11,0.06);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: 10px;
  margin: 8px 0;
}
#kpi-chat-panel .qa-no-match strong { color: #f59e0b; display: block; margin-bottom: 6px; }

#kpi-chat-panel .cat-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6b6e78;
  margin: 12px 4px 6px;
}
#kpi-chat-panel .cat-header:first-child { margin-top: 4px; }

/* ============ Footer hint ============ */
#kpi-chat-panel .foot {
  padding: 10px 18px 14px;
  border-top: 1px solid rgba(255,255,255,0.05);
  font-size: 11px;
  color: #6b6e78;
  line-height: 1.5;
  text-align: center;
  background: rgba(0,0,0,0.2);
}
#kpi-chat-panel .foot strong { color: #c9ccd4; }
