/* LeadFive AI Chat Widget
 * すべてのクラスを lf-chat- でプレフィックスし、サイト既存スタイルと衝突しないようにする。
 */

.lf-chat-launcher,
.lf-chat-panel,
.lf-chat-panel * {
  box-sizing: border-box;
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Floating launcher button */
.lf-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(139, 92, 246, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.lf-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(236, 72, 153, 0.4);
}
.lf-chat-launcher:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}
.lf-chat-launcher[aria-expanded="true"] {
  opacity: 0;
  pointer-events: none;
}
.lf-chat-launcher svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

/* Chat panel */
.lf-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 100px));
  display: none;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  background: #ffffff;
  color: #111;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.lf-chat-panel[data-open="true"] {
  display: flex;
  animation: lfChatIn 0.22s ease-out;
}
@keyframes lfChatIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Header */
.lf-chat-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}
.lf-chat-header__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
}
.lf-chat-header__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
}
.lf-chat-header__sub {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.85;
  margin-top: 2px;
}
.lf-chat-close {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.lf-chat-close:hover { background: rgba(255, 255, 255, 0.15); }

/* Body / messages */
.lf-chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fb;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.lf-chat-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.lf-chat-msg--bot {
  align-self: flex-start;
  background: #ffffff;
  color: #111;
  border: 1px solid #e9e9ee;
  border-bottom-left-radius: 4px;
}
.lf-chat-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.lf-chat-msg--system {
  align-self: center;
  background: transparent;
  color: #6b7280;
  font-size: 11px;
  border: 0;
  padding: 4px 8px;
}
.lf-chat-msg a {
  color: inherit;
  text-decoration: underline;
}
.lf-chat-msg--user a { color: #fff; }

/* Typing indicator */
.lf-chat-typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #e9e9ee;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.lf-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: lfChatTyping 1.2s infinite ease-in-out;
}
.lf-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.lf-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes lfChatTyping {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* Quick replies */
.lf-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 8px;
  background: #f8f9fb;
  flex: 0 0 auto;
}
.lf-chat-quick button {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.15s;
}
.lf-chat-quick button:hover {
  border-color: #8b5cf6;
  color: #8b5cf6;
}

/* Input area */
.lf-chat-input {
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #eaeaef;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}
.lf-chat-input textarea {
  flex: 1 1 auto;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  background: #fff;
  color: #111;
  transition: border-color 0.15s;
}
.lf-chat-input textarea:focus {
  border-color: #8b5cf6;
}
.lf-chat-send {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.15s;
}
.lf-chat-send:hover { transform: scale(1.05); }
.lf-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.lf-chat-send svg { width: 16px; height: 16px; }

/* Footer note */
.lf-chat-footer {
  padding: 6px 12px 10px;
  background: #fff;
  font-size: 10.5px;
  color: #9ca3af;
  text-align: center;
  flex: 0 0 auto;
  border-top: 1px solid #f3f4f6;
}
.lf-chat-footer a {
  color: #8b5cf6;
  text-decoration: none;
}
.lf-chat-footer a:hover { text-decoration: underline; }

/* Mobile */
@media (max-width: 480px) {
  .lf-chat-launcher {
    right: 14px;
    bottom: 14px;
    padding: 12px 16px;
    font-size: 13px;
  }
  .lf-chat-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    /* vh fallback → dvh (modern) */
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
}

/* Header clear button */
.lf-chat-clear {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 999px;
  opacity: 0.85;
  margin-right: 6px;
}
.lf-chat-clear:hover { background: rgba(255, 255, 255, 0.15); opacity: 1; }
.lf-chat-header__actions { display: inline-flex; align-items: center; }
