/**
 * KiruH Widget v4.1.2
 * CSS corregido: visibilidad, clic, panel y responsive.
 */

/* =========================================================
   CONTENEDOR PRINCIPAL
   ========================================================= */

#kiruh-widget-container {
  position: fixed !important;

  top: auto !important;
  right: 0 !important;
  bottom: 0 !important;
  left: auto !important;

  width: 0 !important;
  height: 0 !important;

  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;

  overflow: visible !important;
  pointer-events: auto !important;

  z-index: 2147483000 !important;

  font-family:
    Inter,
    Arial,
    Helvetica,
    sans-serif !important;

  color: #111;
}

#kiruh-widget-container,
#kiruh-widget-container *,
#kiruh-widget-container *::before,
#kiruh-widget-container *::after {
  box-sizing: border-box;
}

/* Respetar elementos ocultos por JavaScript */

#kiruh-widget-container [hidden] {
  display: none !important;
}

/* =========================================================
   AVATAR
   ========================================================= */

html body #kiruh-avatar {
  position: fixed !important;

  right: 24px !important;
  bottom: 24px !important;
  left: auto !important;
  top: auto !important;

  width: 64px !important;
  height: 64px !important;

  min-width: 64px !important;
  min-height: 64px !important;

  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;

  align-items: center !important;
  justify-content: center !important;

  padding: 0 !important;
  margin: 0 !important;

  border: 1px solid rgba(255, 255, 255, 0.45) !important;
  border-radius: 50% !important;

  background:
    linear-gradient(
      135deg,
      #b89650 0%,
      #e5ce91 48%,
      #b89650 100%
    ) !important;

  box-shadow:
    0 5px 20px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25) !important;

  filter:
    drop-shadow(
      0 4px 14px rgba(184, 150, 80, 0.35)
    );

  cursor: pointer !important;
  pointer-events: auto !important;

  user-select: none !important;
  -webkit-user-select: none !important;

  touch-action: manipulation !important;
  -webkit-tap-highlight-color: transparent;

  overflow: hidden !important;

  z-index: 2147483003 !important;

  transition:
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.25s ease;
}

html body #kiruh-avatar::before {
  content: "K" !important;

  position: relative !important;
  z-index: 5 !important;

  display: block !important;

  color: #fff !important;

  font-family:
    Arial,
    Helvetica,
    sans-serif !important;

  font-size: 26px !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  letter-spacing: -1px !important;

  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.22);

  pointer-events: none !important;
}

html body #kiruh-avatar:hover {
  transform: scale(1.12);

  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35) !important;
}

html body #kiruh-avatar:active {
  transform: scale(0.96);
}

html body #kiruh-avatar:focus-visible {
  outline: 3px solid rgba(184, 150, 80, 0.45) !important;
  outline-offset: 4px !important;
}

html body #kiruh-avatar.kiruh-dragging {
  transition: none !important;
  transform: scale(1.18);

  filter:
    drop-shadow(
      0 8px 24px rgba(0, 0, 0, 0.35)
    );

  cursor: grabbing !important;
}

#kiruh-avatar .kiruh-avatar-svg {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;

  pointer-events: none !important;
}

/* Elementos internos no utilizados */

.kiruh-avatar-face,
.kiruh-avatar-eyes,
.kiruh-avatar-mouth,
.kiruh-avatar-glow {
  display: none !important;
}

/* =========================================================
   PERSONALIDADES
   ========================================================= */

html body #kiruh-avatar.kiruh-personality-mayordomo {
  filter:
    drop-shadow(
      0 4px 14px rgba(212, 175, 55, 0.4)
    );
}

html body #kiruh-avatar.kiruh-personality-promotor {
  filter:
    drop-shadow(
      0 4px 14px rgba(255, 152, 0, 0.4)
    );
}

html body #kiruh-avatar.kiruh-personality-ingeniero {
  filter:
    drop-shadow(
      0 4px 14px rgba(21, 101, 192, 0.4)
    );
}

/* =========================================================
   ESTADOS DEL AVATAR
   ========================================================= */

#kiruh-avatar.kiruh-state-greet {
  animation: kiruh-bounce 0.6s ease;
}

#kiruh-avatar.kiruh-state-smile {
  animation: kiruh-pulse 0.5s ease;
}

#kiruh-avatar.kiruh-state-thinking {
  animation: kiruh-wobble 1.2s infinite;
}

#kiruh-avatar.kiruh-state-offering {
  animation: kiruh-shake 0.5s ease;
}

#kiruh-avatar.kiruh-state-celebrating {
  animation: kiruh-bounce 0.8s ease;
}

#kiruh-avatar.kiruh-state-listening {
  animation: kiruh-pulse 1.5s infinite;
}

#kiruh-avatar.kiruh-state-speaking {
  animation: kiruh-bob 0.8s ease;
}

#kiruh-avatar.kiruh-state-human_mode {
  animation: kiruh-pulse 1s infinite;
}

#kiruh-avatar.kiruh-state-owner_mode {
  animation: kiruh-glow 1.5s infinite alternate;
}

html body #kiruh-avatar.kiruh-state-blocked_guard {
  animation: kiruh-shake 0.4s ease;
  opacity: 0.6 !important;
}

@keyframes kiruh-bounce {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-12px);
  }
}

@keyframes kiruh-pulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }
}

@keyframes kiruh-wobble {
  0%,
  100% {
    transform: rotate(0deg);
  }

  25% {
    transform: rotate(-6deg);
  }

  75% {
    transform: rotate(6deg);
  }
}

@keyframes kiruh-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  75% {
    transform: translateX(4px);
  }
}

@keyframes kiruh-bob {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

@keyframes kiruh-glow {
  0% {
    filter:
      drop-shadow(
        0 4px 14px rgba(212, 175, 55, 0.35)
      );
  }

  100% {
    filter:
      drop-shadow(
        0 4px 24px rgba(212, 175, 55, 0.7)
      );
  }
}

/* =========================================================
   BURBUJA DE SALUDO
   ========================================================= */

.kiruh-bubble {
  position: fixed !important;

  right: 24px !important;
  bottom: 100px !important;

  max-width: 260px;

  padding: 12px 34px 12px 16px;

  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;

  background: #fff;
  color: #111;

  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.14);

  font-size: 14px;
  line-height: 1.4;

  pointer-events: auto !important;

  z-index: 2147483002 !important;

  animation:
    kiruh-bubble-in
    0.35s
    cubic-bezier(0.34, 1.56, 0.64, 1);
}

.kiruh-bubble::after {
  content: "";

  position: absolute;

  right: 24px;
  bottom: -8px;

  width: 0;
  height: 0;

  border-top: 8px solid #fff;
  border-right: 8px solid transparent;
  border-left: 8px solid transparent;
}

.kiruh-bubble-close {
  position: absolute;

  top: 4px;
  right: 8px;

  width: 28px;
  height: 28px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: 0;
  background: transparent;

  color: #777;

  font-size: 19px;
  line-height: 1;

  cursor: pointer;
  pointer-events: auto !important;
}

@keyframes kiruh-bubble-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* =========================================================
   CONTROLES RÁPIDOS
   ========================================================= */

.kiruh-controls {
  position: fixed !important;

  right: 24px !important;
  bottom: 100px !important;

  display: flex;
  flex-direction: column;
  gap: 8px;

  pointer-events: auto !important;

  z-index: 2147483002 !important;
}

.kiruh-btn {
  width: 44px;
  height: 44px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 50%;

  background: #fff;
  color: #111;

  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.12);

  font-size: 20px;

  cursor: pointer;
  pointer-events: auto !important;

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.kiruh-btn:hover {
  transform: scale(1.1);

  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.17);
}

/* =========================================================
   PANEL DE CHAT
   ========================================================= */

.kiruh-chat {
  position: fixed !important;

  right: 24px !important;
  bottom: 100px !important;

  width: 360px;
  max-width: calc(100vw - 48px);

  height: 520px;
  max-height: calc(100vh - 124px);

  display: flex;
  flex-direction: column;

  overflow: hidden;

  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 20px;

  background: #fff;
  color: #111;

  box-shadow:
    0 18px 52px rgba(0, 0, 0, 0.18);

  pointer-events: auto !important;

  z-index: 2147483001 !important;

  animation:
    kiruh-chat-in
    0.3s
    cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes kiruh-chat-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.kiruh-chat-header {
  min-height: 62px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  flex: 0 0 auto;

  padding: 14px 18px;

  border-bottom: 1px solid #ececec;

  background: #fff;
}

.kiruh-chat-title {
  color: #111;

  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.kiruh-chat-close {
  width: 34px;
  height: 34px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: 0;
  border-radius: 50%;

  background: transparent;
  color: #777;

  font-size: 22px;
  line-height: 1;

  cursor: pointer;
  pointer-events: auto !important;
}

.kiruh-chat-close:hover {
  background: #f3f3f3;
  color: #111;
}

.kiruh-chat-messages {
  flex: 1 1 auto;

  min-height: 0;

  display: flex;
  flex-direction: column;
  gap: 12px;

  padding: 16px;

  overflow-x: hidden;
  overflow-y: auto;

  background: #fff;
}

.kiruh-message {
  max-width: 82%;

  padding: 10px 14px;

  border-radius: 14px;

  font-size: 14px;
  line-height: 1.45;

  overflow-wrap: anywhere;
  word-break: break-word;
}

.kiruh-message-user {
  align-self: flex-end;

  border-bottom-right-radius: 4px;

  background: #111;
  color: #fff;
}

.kiruh-message-bot {
  align-self: flex-start;

  border-bottom-left-radius: 4px;

  background: #f3f3f3;
  color: #111;
}

.kiruh-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;

  flex: 0 0 auto;

  padding: 12px 14px;

  border-top: 1px solid #ececec;

  background: #fff;

  pointer-events: auto !important;
}

.kiruh-chat-input-area input {
  flex: 1 1 auto;

  width: auto;
  min-width: 0;
  height: 42px;

  padding: 0 14px;

  border: 1px solid #dcdcdc;
  border-radius: 13px;

  background: #fff;
  color: #111;

  font-family: inherit;
  font-size: 14px;

  outline: none;

  pointer-events: auto !important;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.kiruh-chat-input-area input:focus {
  border-color: #b89650;

  box-shadow:
    0 0 0 3px rgba(184, 150, 80, 0.15);
}

.kiruh-chat-input-area button {
  flex: 0 0 auto;

  width: 42px;
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: 0;
  border-radius: 50%;

  background: #111;
  color: #fff;

  font-size: 18px;

  cursor: pointer;
  pointer-events: auto !important;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 480px) {
  html body #kiruh-avatar {
    right: 16px !important;
    bottom: 16px !important;

    width: 60px !important;
    height: 60px !important;

    min-width: 60px !important;
    min-height: 60px !important;
  }

  .kiruh-chat {
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;

    width: 100vw !important;
    max-width: 100vw !important;

    height: 100vh !important;
    height: 100dvh !important;

    max-height: 100vh !important;
    max-height: 100dvh !important;

    border: 0 !important;
    border-radius: 0 !important;
  }

  .kiruh-controls {
    right: 16px !important;
    bottom: 88px !important;
  }

  .kiruh-bubble {
    right: 16px !important;
    bottom: 88px !important;

    max-width: calc(100vw - 32px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #kiruh-avatar,
  .kiruh-bubble,
  .kiruh-chat,
  .kiruh-btn {
    animation: none !important;
    transition: none !important;
  }
}