/* Koko-chan Mascot Widget Styles - CLEAN V8 */
#cocoyoka-chatbot {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  font-family: 'Zen Maru Gothic', 'Noto Sans JP', sans-serif;
  pointer-events: none;
}

#chat-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

#chat-window {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 98vw;
  max-width: 1400px; /* HUGE window */
  height: auto;
  max-height: 90vh;
  transform: translate(-50%, -50%) scale(0.5);
  pointer-events: auto;
  
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 20px;
  animation: popOutCenter 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popOutCenter {
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

#koko-mascot {
  width: 45%;
  max-width: 600px; /* HUGE Mascot */
  height: auto;
  aspect-ratio: 1/1;
  margin-bottom: 0;
  animation: floatMascot 3s ease-in-out infinite;
  filter: drop-shadow(0 10px 15px rgba(0,0,0,0.3));
  flex-shrink: 0;
}

#koko-mascot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes floatMascot {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

#speech-bubble {
  position: relative;
  background: #fff;
  border-radius: 30px;
  flex: 1;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 15px 40px rgba(0,0,0,0.2);
  border: 5px solid #3baf76;
}

/* Tail pointing LEFT */
#speech-bubble::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -25px;
  transform: translateY(-50%);
  border-width: 25px 25px 25px 0;
  border-style: solid;
  border-color: transparent #3baf76 transparent transparent;
  display: block;
  width: 0;
}
#speech-bubble::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -18px;
  transform: translateY(-50%);
  border-width: 20px 20px 20px 0;
  border-style: solid;
  border-color: transparent #fff transparent transparent;
  display: block;
  width: 0;
}

#chat-header {
  padding: 15px 20px;
  display: flex;
  justify-content: flex-end;
}

#chat-close {
  cursor: pointer;
  font-size: 2.5rem;
  line-height: 1;
  color: #ccc;
  transition: color 0.2s;
  font-weight: bold;
}
#chat-close:hover { color: #ff7f50; }

#chat-messages {
  flex: 1;
  padding: 0 25px 20px 25px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.msg {
  max-width: 85%;
  padding: 15px 20px;
  border-radius: 20px;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.6;
  word-break: break-word;
  animation: slideInMsg 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideInMsg {
  from { opacity: 0; transform: translateY(15px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.msg.bot {
  background: #f4fbf7;
  color: #333;
  border: 2px solid #e2f3eb;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.msg.user {
  background: #ff7f50;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

#chat-input-area {
  padding: 20px 25px;
  background: #fff;
  border-top: 2px dashed #e2f3eb;
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-btn {
  background: #fff;
  border: 3px solid #3baf76;
  color: #3baf76;
  padding: 15px;
  border-radius: 30px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-align: center;
  font-size: 1.2rem;
}

.chat-btn:hover {
  background: #3baf76;
  color: #fff;
  transform: translateY(-3px);
  box-shadow: 0 6px 15px rgba(59, 175, 118, 0.3);
}

.chat-btn.decline {
  border-color: #ddd;
  color: #999;
}
.chat-btn.decline:hover {
  background: #999;
  color: #fff;
  box-shadow: none;
}

.typing-indicator {
  display: inline-block;
  font-size: 1.8rem;
  line-height: 1;
  color: #3baf76;
  animation: typing 1.5s infinite;
}

@keyframes typing {
  0% { content: "."; }
  33% { content: ".."; }
  66% { content: "..."; }
}

.chat-form-input {
  width: 100%;
  padding: 15px;
  border: 2px solid #e2f3eb;
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 700;
  box-sizing: border-box;
}

.chat-form-submit {
  width: 100%;
  background: #ff7f50;
  color: white;
  border: none;
  padding: 16px;
  border-radius: 30px;
  font-weight: 900;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
  box-shadow: 0 6px 15px rgba(255, 127, 80, 0.3);
}
.chat-form-submit:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(255, 127, 80, 0.4);
}

#koko-mini-icon {
  pointer-events: auto; /* IMPORTANT for click */
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 100px;
  height: 100px;
  background-color: #fff;
  border: 4px solid #3baf76;
  border-radius: 50%;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  cursor: pointer;
  z-index: 10001;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  background-image: url('images/robot_avatar.png');
  background-size: cover;
  background-position: center;
  animation: floatMascot 3s ease-in-out infinite;
}

#koko-mini-icon:hover {
  transform: scale(1.1) rotate(-5deg);
}

@media (max-width: 800px) {
  #chat-window {
    flex-direction: column;
    max-width: 95vw;
    gap: 10px;
    height: 90vh;
  }
  
  #koko-mascot {
    width: 250px;
    height: 250px;
    aspect-ratio: auto;
  }
  
  #speech-bubble {
    flex: 1;
    overflow-y: hidden;
  }
  
  /* Tail pointing UP */
  #speech-bubble::before {
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 20px 25px 20px;
    border-color: transparent transparent #3baf76 transparent;
  }
  #speech-bubble::after {
    top: -13px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 15px 20px 15px;
    border-color: transparent transparent #fff transparent;
  }
}