/* =========================
   KALLE WIDGET – FIXED
   - bigger mascot
   - NO circle avatar
   - responsive sizing
   ========================= */

:root{
  --kalle-size: clamp(140px, 18vw, 200px);  /* VIEL Größer! */
  --kalle-radius: 0;
  --kalle-bg: transparent;
  --kalle-border: transparent;
  --kalle-shadow: none;
  --kalle-glow: none;
  --kalle-text: rgba(229,231,235,0.95);
  --kalle-muted: rgba(156,163,175,0.9);
}

/* Widget container (support different ids/classes) */
#kalle,
.kalle,
.kalle-widget,
#kalle-widget,
#kalle-assistant,
.kalle-assistant{
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: row;  /* Bubble LINKS von Avatar */
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

/* Clickable button / mascot */
#kalle .kalle-btn,
.kalle .kalle-btn,
.kalle-widget .kalle-btn,
#kalle-widget .kalle-btn,
#kalle-assistant .kalle-btn,
.kalle-assistant .kalle-btn{
  pointer-events: auto;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  transform: translateY(120px);
  opacity: 0;
  transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 400ms ease;
}

/* Kalle eingeblendet */
#kalle.visible .kalle-btn,
.kalle.visible .kalle-btn,
.kalle-widget.visible .kalle-btn{
  transform: translateY(0);
  opacity: 1;
}

/* Avatar wrapper - transparent, no border */
#kalle .kalle-avatar,
.kalle .kalle-avatar,
.kalle-widget .kalle-avatar,
#kalle-widget .kalle-avatar,
#kalle-assistant .kalle-avatar,
.kalle-assistant .kalle-avatar{
  width: var(--kalle-size);
  height: var(--kalle-size);
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
  display: grid;
  place-items: center;
  transform: translateZ(0);
  transition: transform 180ms ease;
}

/* Make image fill nicely */
#kalle .kalle-avatar img,
.kalle .kalle-avatar img,
.kalle-widget .kalle-avatar img,
#kalle-widget .kalle-avatar img,
#kalle-assistant .kalle-avatar img,
.kalle-assistant .kalle-avatar img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.4));
}

/* Hover / active feel */
#kalle .kalle-btn:hover .kalle-avatar,
.kalle .kalle-btn:hover .kalle-avatar,
.kalle-widget .kalle-btn:hover .kalle-avatar,
#kalle-widget .kalle-btn:hover .kalle-avatar,
#kalle-assistant .kalle-btn:hover .kalle-avatar,
.kalle-assistant .kalle-btn:hover .kalle-avatar{
  transform: translateY(-4px) scale(1.05);
}

/* Optional: small status dot (if you use it) */
#kalle .kalle-dot,
.kalle .kalle-dot,
.kalle-widget .kalle-dot{
  position: absolute;
  width: 10px;
  height: 10px;
  right: 6px;
  bottom: 6px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(12,15,22,0.9);
}

/* Speech bubble panel - echte Sprechblase */
#kalle .kalle-bubble,
.kalle .kalle-bubble,
.kalle-widget .kalle-bubble,
#kalle-widget .kalle-bubble,
#kalle-assistant .kalle-bubble,
.kalle-assistant .kalle-bubble{
  pointer-events: auto;
  position: relative;
  width: min(320px, calc(100vw - 40px));
  background: #ffffff;
  border: none;
  border-radius: 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  padding: 18px 20px 16px;
  margin-right: -100px;
  margin-left: 0px;
  margin-bottom: 35px;
  margin-top: 0px;
  transform-origin: right center;
  transform: translateX(30px) scale(0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 350ms ease, transform 500ms cubic-bezier(0.34, 1.56, 0.64, 1), visibility 350ms ease;
}

/* Sprechblasen-Pfeil - rechts zeigend zu Kalle */
#kalle .kalle-bubble::after,
.kalle .kalle-bubble::after,
.kalle-widget .kalle-bubble::after,
#kalle-widget .kalle-bubble::after,
#kalle-assistant .kalle-bubble::after,
.kalle-assistant .kalle-bubble::after{
  content: '';
  position: absolute;
  right: -16px;
  bottom: 25px;
  width: 0;
  height: 0;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-left: 18px solid #ffffff;
  filter: drop-shadow(4px 2px 4px rgba(0,0,0,0.1));
}

/* visible bubble state (toggle with .open / .active) */
#kalle.open .kalle-bubble,
.kalle.open .kalle-bubble,
.kalle-widget.open .kalle-bubble,
#kalle-widget.open .kalle-bubble,
#kalle-assistant.open .kalle-bubble,
.kalle-assistant.open .kalle-bubble,
#kalle.active .kalle-bubble,
.kalle.active .kalle-bubble,
.kalle-widget.active .kalle-bubble{
  opacity: 1;
  visibility: visible;
  transform: translateX(0) scale(1);
  animation: bubblePop 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes bubblePop {
  0% {
    transform: translateX(30px) scale(0.3);
    opacity: 0;
  }
  50% {
    transform: translateX(-5px) scale(1.05);
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

/* Bubble text - dunkler Text auf weißem Hintergrund */
#kalle .kalle-title,
.kalle .kalle-title,
.kalle-widget .kalle-title{
  color: #1f2937;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  margin: 0 0 8px;
  transition: color 200ms ease;
}

/* ALERT MODE - Warnung Styling */
#kalle.alert-mode .kalle-bubble,
.kalle.alert-mode .kalle-bubble{
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 2px solid #f59e0b;
  box-shadow: 0 10px 40px rgba(245, 158, 11, 0.3);
}

#kalle.alert-mode .kalle-bubble::after,
.kalle.alert-mode .kalle-bubble::after{
  border-left-color: #fde68a;
}

#kalle.alert-mode .kalle-title,
.kalle.alert-mode .kalle-title{
  color: #b45309;
}

#kalle.alert-mode .kalle-text,
.kalle.alert-mode .kalle-text{
  color: #92400e;
}

#kalle.alert-mode .kalle-avatar,
.kalle.alert-mode .kalle-avatar{
  animation: kalleShake 0.5s ease-in-out;
}

@keyframes kalleShake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-5px) rotate(-5deg); }
  40% { transform: translateX(5px) rotate(5deg); }
  60% { transform: translateX(-5px) rotate(-5deg); }
  80% { transform: translateX(5px) rotate(5deg); }
}

#kalle .kalle-text,
.kalle .kalle-text,
.kalle-widget .kalle-text{
  color: #4b5563;
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
  max-width: 250px;
}

/* Bubble actions (if you have buttons) */
#kalle .kalle-actions,
.kalle .kalle-actions,
.kalle-widget .kalle-actions{
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

#kalle .kalle-actions a,
#kalle .kalle-actions button,
.kalle .kalle-actions a,
.kalle .kalle-actions button,
.kalle-widget .kalle-actions a,
.kalle-widget .kalle-actions button{
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
  padding: 8px 14px;
  border: none;
  background: #f5b301;
  color: #1a1a1a;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease;
}

#kalle .kalle-actions a:hover,
#kalle .kalle-actions button:hover,
.kalle .kalle-actions a:hover,
.kalle .kalle-actions button:hover,
.kalle-widget .kalle-actions a:hover,
.kalle-widget .kalle-actions button:hover{
  background: #e5a501;
}

#kalle .kalle-actions button:last-child,
.kalle .kalle-actions button:last-child,
.kalle-widget .kalle-actions button:last-child{
  background: #e5e7eb;
  color: #374151;
}

#kalle .kalle-actions button:last-child:hover,
.kalle .kalle-actions button:last-child:hover,
.kalle-widget .kalle-actions button:last-child:hover{
  background: #d1d5db;
}

/* Mobile tuning */
@media (max-width: 480px){
  #kalle,
  .kalle,
  .kalle-widget,
  #kalle-widget,
  #kalle-assistant,
  .kalle-assistant{
    right: 10px;
    bottom: 10px;
  }

  :root{
    --kalle-size: clamp(100px, 25vw, 140px);
  }
  
  #kalle .kalle-bubble,
  .kalle .kalle-bubble{
    width: min(260px, calc(100vw - 30px));
    padding: 14px 16px 12px;
  }
}

/* Respect safe areas (iPhone) */
@supports (padding: env(safe-area-inset-bottom)) {
  #kalle,
  .kalle,
  .kalle-widget,
  #kalle-widget,
  #kalle-assistant,
  .kalle-assistant{
    bottom: calc(12px + env(safe-area-inset-bottom));
    right: calc(12px + env(safe-area-inset-right));
  }
}
