/* ROJGARPATH Chatbot — sticky bottom-right */

.rp-chatbot {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: 10050;
  font-family: var(--rp-font-sans, 'Hind', sans-serif);
}

body.rp-chatbot-open {
  overflow: hidden;
}

/* Launcher button */
.rp-chatbot__launcher {
  position: relative;
  width: 3.5rem;
  height: 3.5rem;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow:
    0 6px 22px rgba(102, 126, 234, 0.45),
    0 2px 8px rgba(15, 23, 42, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.25s ease;
}

.rp-chatbot__launcher:hover {
  transform: scale(1.06);
  box-shadow:
    0 10px 28px rgba(102, 126, 234, 0.5),
    0 4px 12px rgba(15, 23, 42, 0.18);
}

.rp-chatbot__launcher:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.45);
  outline-offset: 3px;
}

.rp-chatbot__launcher-icon--close {
  display: none;
}

.rp-chatbot.is-open .rp-chatbot__launcher-icon--open {
  display: none;
}

.rp-chatbot.is-open .rp-chatbot__launcher-icon--close {
  display: block;
}

.rp-chatbot__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: #ff6b35;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
  box-shadow: 0 2px 6px rgba(255, 107, 53, 0.45);
}

.rp-chatbot.is-open .rp-chatbot__badge {
  display: none;
}

/* External visitor teaser bubble */
.rp-chatbot__teaser {
  position: absolute;
  right: calc(3.5rem + 0.65rem);
  bottom: 0.35rem;
  max-width: min(13.5rem, calc(100vw - 6rem));
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  border-radius: 12px;
  background: #fff;
  color: #1e293b;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
  box-shadow:
    0 8px 24px rgba(15, 23, 42, 0.14),
    0 2px 6px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(102, 126, 234, 0.2);
  animation: rp-chatbot-teaser-in 0.35s ease-out;
  z-index: 1;
}

.rp-chatbot__teaser::after {
  content: '';
  position: absolute;
  right: -6px;
  bottom: 1rem;
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 1px solid rgba(102, 126, 234, 0.2);
  border-bottom: 1px solid rgba(102, 126, 234, 0.2);
  transform: rotate(-45deg);
}

.rp-chatbot__teaser[hidden] {
  display: none !important;
}

.rp-chatbot__teaser-text {
  margin: 0;
}

.rp-chatbot__teaser-close {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 1.35rem;
  height: 1.35rem;
  border: none;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #64748b;
  cursor: pointer;
}

.rp-chatbot__teaser-close:hover {
  background: #f1f5f9;
  color: #334155;
}

.rp-chatbot.is-open .rp-chatbot__teaser {
  display: none;
}

@keyframes rp-chatbot-teaser-in {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Chat panel */
.rp-chatbot__panel {
  position: absolute;
  right: 0;
  bottom: calc(3.5rem + 0.75rem);
  width: min(22rem, calc(100vw - 2rem));
  max-height: min(32rem, calc(100vh - 6rem));
  background: #fff;
  border-radius: 16px;
  box-shadow:
    0 16px 48px rgba(15, 23, 42, 0.18),
    0 4px 16px rgba(102, 126, 234, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  border: 1px solid rgba(102, 126, 234, 0.12);
}

.rp-chatbot.is-open .rp-chatbot__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.rp-chatbot__header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  flex-shrink: 0;
}

.rp-chatbot__avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: -0.02em;
}

.rp-chatbot__header-text {
  flex: 1;
  min-width: 0;
}

.rp-chatbot__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.2;
}

.rp-chatbot__subtitle {
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
  opacity: 0.88;
}

.rp-chatbot__header-close {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rp-chatbot__header-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.rp-chatbot__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #f8f9fc;
  -webkit-overflow-scrolling: touch;
}

.rp-chatbot__msg {
  max-width: 88%;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  font-size: 0.8125rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.rp-chatbot__msg--bot {
  align-self: flex-start;
  background: #fff;
  color: #2c3e50;
  border: 1px solid #e8ecf4;
  border-bottom-left-radius: 4px;
}

.rp-chatbot__msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.rp-chatbot__msg a {
  color: #667eea;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Result cards ─────────────────────────────── */
.rp-chatbot__result {
  margin: 0.55rem 0;
  padding: 0.65rem 0.75rem;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e8ecf4;
  border-left: 3px solid #667eea;
}

.rp-chatbot__result-title {
  font-weight: 700;
  font-size: 0.8125rem;
  line-height: 1.4;
  margin-bottom: 0.3rem;
}

.rp-chatbot__result-meta {
  font-size: 0.68rem;
  color: #64748b;
  margin-bottom: 0.45rem;
}

/* label-value detail rows */
.rp-chatbot__detail {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.5rem;
  margin: 0.28rem 0;
  font-size: 0.78rem;
  line-height: 1.4;
}

.rp-chatbot__detail-label {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  background: #667eea;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.rp-chatbot__detail-val {
  font-weight: 600;
  color: #1e293b;
  font-size: 0.8125rem;
}

.rp-chatbot__excerpt {
  font-size: 0.75rem;
  color: #475569;
  line-height: 1.45;
  margin: 0.3rem 0;
}

.rp-chatbot__faq {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed #e2e8f0;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.rp-chatbot__faq-q {
  font-weight: 700;
  color: #374151;
}

.rp-chatbot__faq-a {
  color: #4b5563;
}

.rp-chatbot__result-link {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  padding-top: 0.4rem;
  border-top: 1px solid #f1f5f9;
}

/* ── Focused single-field card ───────────────── */
.rp-chatbot__focused {
  margin: 0.4rem 0;
  padding: 0.75rem 0.85rem;
  background: linear-gradient(135deg, #f0f3ff 0%, #f8f9ff 100%);
  border-radius: 10px;
  border-left: 4px solid #667eea;
}

.rp-chatbot__focused-job {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0.55rem;
}

.rp-chatbot__focused-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0.4rem 0;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(102, 126, 234, 0.12);
}

.rp-chatbot__focused-row:last-of-type {
  border-bottom: none;
}

.rp-chatbot__focused-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: #667eea;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rp-chatbot__focused-val {
  font-size: 1rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.3;
}

.rp-chatbot__focused-val--full {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}

.rp-chatbot__focused .rp-chatbot__result-link {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(102, 126, 234, 0.18);
  border-bottom: none;
}

.rp-chatbot__msg--user a {
  color: #fff;
}

.rp-chatbot__msg time {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.65rem;
  opacity: 0.65;
}

.rp-chatbot__typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.65rem 0.85rem;
  background: #fff;
  border: 1px solid #e8ecf4;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}

.rp-chatbot__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #667eea;
  animation: rp-chat-typing 1.2s ease-in-out infinite;
}

.rp-chatbot__typing span:nth-child(2) { animation-delay: 0.15s; }
.rp-chatbot__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes rp-chat-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.rp-chatbot__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.85rem 0.65rem;
  background: #f8f9fc;
  flex-shrink: 0;
}

.rp-chatbot__chip {
  padding: 0.35rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  color: #667eea;
  background: #fff;
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.rp-chatbot__chip:hover {
  background: #667eea;
  color: #fff;
}

.rp-chatbot__form {
  display: flex;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid #e8ecf4;
  background: #fff;
  flex-shrink: 0;
}

.rp-chatbot__input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  font-size: 0.8125rem;
  font-family: inherit;
  border: 1px solid #dde1ea;
  border-radius: 999px;
  outline: none;
}

.rp-chatbot__input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.rp-chatbot__send,
.rp-chatbot__mic {
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: filter 0.15s;
}

.rp-chatbot__send {
  color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.rp-chatbot__mic {
  color: #667eea;
  background: #f0f3ff;
}

.rp-chatbot__mic.is-listening {
  color: #fff;
  background: #e74c3c;
  animation: rp-chat-mic-pulse 1.2s ease-in-out infinite;
}

.rp-chatbot__mic:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.rp-chatbot__send:hover,
.rp-chatbot__mic:hover:not(:disabled) {
  filter: brightness(1.06);
}

.rp-chatbot__mic[hidden] {
  display: none;
}

@keyframes rp-chat-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
}

@media (max-width: 768px) {
  .rp-chatbot.is-open .rp-chatbot__panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: none;
    transform: none;
    transform-origin: center;
    z-index: 10051;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .rp-chatbot.is-open .rp-chatbot__launcher {
    display: none;
  }

  .rp-chatbot__header {
    padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
  }

  .rp-chatbot__form {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }

  .rp-chatbot__teaser {
    max-width: min(12rem, calc(100vw - 5rem));
    right: calc(3.5rem + 0.5rem);
  }
}
