﻿/* Cocoyoka Kokonyan Chatbot Styles */
#cocoyoka-chatbot {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  font-family: 'Zen Maru Gothic', 'Noto Sans JP', sans-serif;
}

#chat-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(12, 19, 29, 0.58);
  backdrop-filter: blur(3px) saturate(0.78);
  -webkit-backdrop-filter: blur(3px) saturate(0.78);
  pointer-events: auto;
  transition: background-color .2s ease, backdrop-filter .2s ease;
}

#cocoyoka-chatbot.is-answering #chat-overlay {
  background: rgba(8, 13, 22, 0.72);
  backdrop-filter: blur(5px) saturate(0.68);
  -webkit-backdrop-filter: blur(5px) saturate(0.68);
}

#chat-window {
  display: none;
  position: absolute;
  right: 26px;
  bottom: 26px;
  width: min(760px, calc(100vw - 52px));
  max-height: min(640px, calc(100vh - 96px));
  pointer-events: auto;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}

#koko-mascot {
  width: 264px;
  aspect-ratio: 2 / 3;
  transform-origin: 54% 92%;
  animation: kokonyanIdle 3.2s ease-in-out infinite;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.24));
  flex-shrink: 0;
}

#koko-mascot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: kokonyanWave 1.8s ease-in-out 1s infinite;
  transform-origin: 24% 52%;
}

@keyframes kokonyanIdle {
  0%, 100% { transform: translateY(0) rotate(-1.2deg); }
  35% { transform: translateY(-12px) rotate(2deg); }
  70% { transform: translateY(-4px) rotate(-1.8deg); }
}

@keyframes kokonyanWave {
  0%, 100% { transform: rotate(0); }
  18% { transform: rotate(-2.8deg); }
  36% { transform: rotate(2.2deg); }
  54% { transform: rotate(-1.6deg); }
  72% { transform: rotate(1deg); }
}

#speech-bubble {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  max-height: 560px;
  padding: 12px 10px 10px;
  background:
    radial-gradient(circle at 10% 16%, #fff 0 42px, transparent 43px),
    radial-gradient(circle at 24% 3%, #fff 0 54px, transparent 55px),
    radial-gradient(circle at 48% 0%, #fff 0 62px, transparent 63px),
    radial-gradient(circle at 76% 8%, #fff 0 58px, transparent 59px),
    radial-gradient(circle at 96% 28%, #fff 0 46px, transparent 47px),
    radial-gradient(circle at 88% 92%, #fff 0 58px, transparent 59px),
    radial-gradient(circle at 54% 101%, #fff 0 64px, transparent 65px),
    radial-gradient(circle at 18% 88%, #fff 0 56px, transparent 57px),
    linear-gradient(#fff, #fff);
  border-radius: 54px 62px 58px 68px / 58px 48px 66px 54px;
  box-shadow:
    0 18px 42px rgba(88, 52, 45, 0.16),
    0 0 0 2px rgba(244, 91, 106, 0.14);
}

#speech-bubble::before {
  content: '';
  position: absolute;
  top: 44%;
  left: -30px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    -24px 18px 0 -3px #fff,
    -45px 32px 0 -8px #fff,
    0 8px 16px rgba(88, 52, 45, 0.09),
    -24px 22px 14px -6px rgba(88, 52, 45, 0.08);
}

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

#chat-close {
  cursor: pointer;
  color: #c8a2a6;
  font-size: 34px;
  line-height: 1;
  font-weight: 900;
  transition: color 0.2s ease;
}
#chat-close:hover { color: #f45b6a; }

#chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 24px 16px;
  overflow-y: auto;
}

.msg {
  max-width: 86%;
  padding: 14px 18px;
  border-radius: 22px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.6;
  word-break: break-word;
  animation: slideInMsg 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.msg.bot {
  align-self: flex-start;
  background: #fff;
  border: 2px solid #ffd4db;
  color: #24272c;
  border-radius: 26px 24px 24px 12px;
  box-shadow: 0 6px 16px rgba(42, 24, 29, .10);
}

.msg.user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(135deg, #ff7f50, #f45b6a);
  border-radius: 24px 26px 12px 24px;
}

#chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 24px 24px;
  border-top: 2px dotted #ffd3d8;
}

.chat-btn {
  padding: 13px;
  border: 2px solid #f45b6a;
  border-radius: 999px;
  color: #e9495c;
  background: #fffafa;
  text-align: center;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chat-btn:hover {
  transform: translateY(-2px);
  color: #fff;
  background: linear-gradient(135deg, #ff7f50, #f45b6a);
  box-shadow: 0 6px 15px rgba(244, 91, 106, 0.26);
}

.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.6rem;
  line-height: 1;
  color: #f45b6a;
}

.chat-form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #ffe0e5;
  border-radius: 14px;
  margin-bottom: 10px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 700;
  box-sizing: border-box;
  background: #fffafa;
}

.chat-form-submit {
  width: 100%;
  color: #fff;
  border: 0;
  padding: 15px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff7f50, #f45b6a);
  font: inherit;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 15px rgba(244, 91, 106, 0.26);
}

#koko-mini-icon {
  pointer-events: auto;
  display: none;
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 100px;
  height: 100px;
  border: 4px solid #f45b6a;
  border-radius: 50%;
  background: transparent url('images/robot_avatar.png') center / contain no-repeat;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  z-index: 10001;
  animation: miniBounce 2.8s ease-in-out infinite;
}

@keyframes miniBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  42% { transform: translateY(-8px) scale(1.04); }
}

@media (max-width: 800px) {
  #chat-window {
    left: 50%;
    right: auto;
    bottom: 18px;
    width: min(94vw, 420px);
    max-height: calc(100vh - 36px);
    flex-direction: column;
    transform: translateX(-50%);
    gap: 8px;
  }

  #koko-mascot {
    width: 180px;
  }

  #speech-bubble {
    width: 100%;
    max-height: 58vh;
  }

  #speech-bubble::before {
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow:
      -20px -14px 0 -4px #fff,
      18px -10px 0 -6px #fff,
      0 0 0 3px rgba(244, 91, 106, 0.12) inset;
  }

  .msg {
    font-size: 15px;
  }
}

/* AI hybrid mode */
#chat-header {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 20px 6px;
}

.kokonyan-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #59464a;
  font-size: 18px;
}

.kokonyan-ai-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #007da8, #00a8c8);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
}

#chat-close {
  appearance: none;
  border: 0;
  padding: 0 4px;
  background: transparent;
}

.kokonyan-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  max-height: 176px;
  overflow-y: auto;
  padding: 2px;
}

.kokonyan-quick-actions .chat-btn {
  min-width: 0;
  padding: 9px 12px;
  font-size: 13px;
}

.kokonyan-ai-form {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px;
}

#kokonyan-ai-input {
  width: 100%;
  min-height: 54px;
  max-height: 112px;
  resize: vertical;
  box-sizing: border-box;
  border: 2px solid #ffd3d8;
  border-radius: 16px;
  padding: 10px 12px;
  color: #333;
  background: #fff;
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
  outline: none;
}

#kokonyan-ai-input:focus {
  border-color: #f45b6a;
  box-shadow: 0 0 0 3px rgba(244, 91, 106, .12);
}

#kokonyan-ai-send {
  min-width: 66px;
  height: 48px;
  border: 0;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(135deg, #ff7f50, #f45b6a);
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 12px rgba(244, 91, 106, .22);
}

#kokonyan-ai-send:disabled {
  cursor: wait;
  opacity: .55;
}

.kokonyan-privacy {
  margin: -2px 2px 0;
  color: #786b6e;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.45;
}

.kokonyan-form-notice {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid #f2b9bd;
  border-radius: 8px;
  background: #fff4f5;
  color: #b00010;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

.msg.typing {
  color: #766;
  font-size: 14px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#koko-mini-icon {
  width: 108px;
  height: 108px;
  padding: 3px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  overflow: hidden;
  color: #e9495c;
  background: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 900;
}

#koko-mini-icon img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

#koko-mini-icon span {
  margin-top: -7px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  background: #f45b6a;
  line-height: 1.2;
}

@media (max-width: 800px) {
  #speech-bubble { max-height: 66vh; }
  #chat-messages { min-height: 132px; padding: 0 18px 12px; }
  #chat-input-area { padding: 12px 18px 18px; }
  .kokonyan-ai-form { grid-template-columns: 1fr 58px; }
  #kokonyan-ai-send { min-width: 58px; }
  #koko-mini-icon { right: 12px; bottom: 12px; width: 88px; height: 88px; }
  #koko-mini-icon img { width: 58px; height: 58px; }
  .kokonyan-quick-actions { max-height: 150px; }
  #chat-overlay {
    background: rgba(12, 19, 29, 0.52);
    backdrop-filter: blur(2px) saturate(0.82);
    -webkit-backdrop-filter: blur(2px) saturate(0.82);
  }
  #cocoyoka-chatbot.is-answering #chat-overlay {
    background: rgba(8, 13, 22, 0.66);
    backdrop-filter: blur(4px) saturate(0.72);
    -webkit-backdrop-filter: blur(4px) saturate(0.72);
  }
}

@media (prefers-reduced-motion: reduce) {
  #koko-mascot, #koko-mascot img, #koko-mini-icon, .msg { animation: none !important; }
}
