/* KChat Widget Styles — Kerala State Portal Assistant */
:root {
  /* Matches the portal theme in assets/webassets/css/main.css */
  --kchat-navy: #242a48;   /* navbar / footer (.nav-bg, .footer) */
  --kchat-accent: #5d6dbf; /* links / highlights */
}

/* Floating launcher: round bot avatar */
#kchat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--kchat-accent), var(--kchat-navy));
  border: 2px solid #fff;
  cursor: pointer;
  z-index: 9999;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
  transition: transform .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#kchat-btn .kchat-icon {
  width: 30px;
  height: 30px;
}

.kchat-avatar .kchat-icon {
  width: 24px;
  height: 24px;
}

#kchat-btn img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

#kchat-btn:hover {
  transform: scale(1.08);
}

#kchat-btn:focus-visible,
.kchat-hbtn:focus-visible {
  outline: 3px solid var(--kchat-accent);
  outline-offset: 2px;
}

#kchat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #e53935;
  color: #ffffff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

#kchat-badge[hidden] {
  display: none;
}

/* Panel */
#kchat-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 520px;
  max-height: calc(100vh - 120px);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  background: var(--kchat-navy);
  font-family: "Roboto", "Segoe UI", Arial, sans-serif;
  transform: translateY(20px) scale(.97);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform .25s, opacity .2s, visibility .25s, width .25s, height .25s;
}

#kchat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#kchat-panel.expanded {
  width: min(720px, calc(100vw - 48px));
  height: calc(100vh - 124px);
}

/* Header */
#kchat-header {
  background: linear-gradient(90deg, var(--kchat-navy), var(--kchat-accent));
  padding: 14px 14px 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.kchat-avatar {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(255, 255, 255, .85);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--kchat-accent);
}

.kchat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#kchat-header-info {
  flex: 1;
  min-width: 0;
}

#kchat-header-name {
  color: #ffffff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#kchat-header-sub {
  color: rgba(255, 255, 255, .85);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.kchat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  animation: kchat-pulse 2s infinite;
}

@keyframes kchat-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.kchat-hbtn {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  border: none;
  color: #ffffff;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}

.kchat-hbtn:hover {
  background: rgba(255, 255, 255, .3);
}

/* Body: white card overlapping the header's rounded bottom */
#kchat-body {
  flex: 1;
  display: flex;
  margin-top: -10px;
  background: #fff;
  border-radius: 18px 18px 0 0;
  overflow: hidden;
}

#kchat-iframe {
  flex: 1;
  border: none;
  width: 100%;
  background: #fff;
}

/* Hide the UserWay accessibility button while the chat is open — it sits on
   the right edge above everything and would otherwise cover the panel.
   display (not visibility): UserWay forces inline `visibility: visible !important`
   on its .uwif iframe, which a stylesheet can't override, but it never sets display. */
body.kchat-open .uwy,
body.kchat-open .uwif,
body.kchat-open .userway_buttons_wrapper {
  display: none !important;
}

/* Move the site's scroll-to-top button above the KChat launcher so they don't overlap */
.scroll-top {
  bottom: 100px !important;
  right: 36px !important;
}

/* Mobile: near full-screen */
@media (max-width: 480px) {
  #kchat-panel,
  #kchat-panel.expanded {
    width: calc(100vw - 16px);
    right: 8px;
    height: 75vh;
  }

  #kchat-expand {
    display: none;
  }
}
