/* jkbmsr.com chat widget styles — mirrors the web app's chat (Unified Design
 * System v1.0 tokens). Uses the theme's CSS variables so light/dark just works. */
#jkbmsr-chat-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
}

.jkchat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.jkchat-panel {
  display: none;
  flex-direction: column;
  width: min(22rem, calc(100vw - 2rem));
  height: 32rem;
  max-height: calc(100vh - 6rem);
  margin-bottom: 0.75rem;
  overflow: hidden;
  border: 1px solid rgb(var(--line) / 0.6);
  border-radius: 1rem;
  background: rgb(var(--panel));
  box-shadow: var(--shadow-elevation-3);
}

/* The panel stays hidden until the launcher (or a badge click) toggles
   .jkchat--open on the wrapper — without this the panel rendered open on
   every page load. */
.jkchat--open .jkchat-panel {
  display: flex;
}

.jkchat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgb(var(--accent));
  color: rgb(var(--on-accent));
}

.jkchat-panel-header__title {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.95rem;
  font-weight: 700;
}

.jkchat-panel-header__status {
  margin-top: 0.1rem;
  font-size: 0.72rem;
  opacity: 0.82;
}

.jkchat-panel-header__close {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.4rem;
  line-height: 1;
}

.jkchat-panel-header__close:hover {
  background: rgb(255 255 255 / 0.12);
}

.jkchat-contact {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgb(var(--line) / 0.6);
  background: rgb(var(--inset) / 0.45);
  font-size: 0.8rem;
  color: rgb(var(--text-subtle));
}

.jkchat-contact__fields {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.jkchat-contact__fields input {
  flex: 1;
  min-width: 7rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  border: 1px solid rgb(var(--line) / 0.8);
  border-radius: 0.4rem;
  background: rgb(var(--canvas));
  color: rgb(var(--text-primary));
}

.jkchat-contact__fields input:focus {
  outline: none;
  border-color: rgb(var(--signal));
}

.jkchat-contact__toggle {
  margin-top: 0.5rem;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.72rem;
  text-align: left;
  color: rgb(var(--text-subtle));
  cursor: pointer;
}

.jkchat-contact__toggle:hover {
  color: rgb(var(--text-secondary));
}

.jkchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.jkchat-message--welcome {
  margin: 0;
  color: rgb(var(--text-secondary));
}

.jkchat-message {
  display: flex;
}

.jkchat-message--visitor {
  justify-content: flex-end;
}

.jkchat-message--admin,
.jkchat-message--bot {
  justify-content: flex-start;
}

.jkchat-bubble {
  max-width: 80%;
  padding: 0.45rem 0.8rem;
  font-size: 0.88rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 0.75rem;
}

.jkchat-message--visitor .jkchat-bubble {
  background: rgb(var(--accent));
  color: rgb(var(--on-accent));
}

.jkchat-message--admin .jkchat-bubble {
  border: 1px solid rgb(var(--line) / 0.6);
  background: rgb(var(--inset));
  color: rgb(var(--text-primary));
}

.jkchat-message--bot .jkchat-bubble {
  border: 1px solid rgb(var(--accent) / 0.25);
  background: rgb(var(--accent) / 0.1);
  color: rgb(var(--text-primary));
}

.jkchat-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.jkchat-quick {
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid rgb(var(--accent) / 0.35);
  border-radius: 999px;
  background: rgb(var(--accent) / 0.1);
  color: rgb(var(--accent));
  cursor: pointer;
  transition: background 0.15s ease;
}

.jkchat-quick:hover {
  background: rgb(var(--accent) / 0.2);
}

.jkchat-error {
  padding: 0 1rem 0.35rem;
  font-size: 0.78rem;
  color: rgb(var(--critical));
}

.jkchat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgb(var(--line) / 0.6);
}

.jkchat-form input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  border: 1px solid rgb(var(--line) / 0.8);
  border-radius: 0.5rem;
  background: rgb(var(--canvas));
  color: rgb(var(--text-primary));
}

.jkchat-form input:focus {
  outline: none;
  border-color: rgb(var(--signal));
}

.jkchat-form__send {
  padding: 0.6rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  border: 0;
  border-radius: 0.5rem;
  background: rgb(var(--accent));
  color: rgb(var(--on-accent));
  cursor: pointer;
}

.jkchat-form__send:disabled {
  opacity: 0.5;
  cursor: default;
}

.jkchat-launcher {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 999px;
  background: rgb(var(--accent));
  color: rgb(var(--on-accent));
  box-shadow: var(--shadow-elevation-3);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.jkchat-launcher:hover {
  transform: scale(1.05);
}

.jkchat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: rgb(var(--critical));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .jkchat-quick,
  .jkchat-launcher {
    transition: none;
  }
}