/* AiChat Integrated Styles (Merged from chat.css) */

/* フローティングAIチャットトリガー */
.ai-chat-floating-trigger {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-chat-floating-trigger:hover {
  transform: translateY(-8px) scale(1.05);
}

.floating-character {
  width: 90px;
  height: auto;
  filter: drop-shadow(2px 4px 8px rgba(0,0,0,0.2));
  margin-bottom: -5px; /* 吹き出しテキストに少し被せる */
  z-index: 2;
  position: relative;
}

.floating-icon {
  font-size: 50px;
  margin-bottom: -10px;
  z-index: 2;
  position: relative;
  filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.15));
}

.floating-text {
  background-color: #fff;
  color: #000;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: bold;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  border: 2px solid #52473f;
  z-index: 1;
  line-height: 1.4;
  position: relative;
}

/* モバイル向け微調整 */
@media (max-width: 767px) {
  .ai-chat-floating-trigger {
    bottom: 10px;
    left: 10px;
  }
  .floating-character {
    width: 60px;
  }
  .floating-text {
    font-size: 10px;
    padding: 4px 8px;
    line-height: 1.2;
    border-width: 1px;
  }
}

/* MicroModal Base Styles */
.modal__overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal__container {
  background-color: #fff;
  padding: 0;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  border-radius: 12px;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #52473f;
  background: #52473f;
  color: #fff;
}

.modal__title {
  margin-top: 0;
  margin-bottom: 0;
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.25;
  color: #fff;
}

.modal__close {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  color: #fff;
}

.modal__close:before { content: "\2715"; }

.modal__content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* MicroModal Animations */
@keyframes mmfadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes mmfadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes mmslideIn {
  from { transform: translateY(15%); }
  to { transform: translateY(0); }
}
@keyframes mmslideOut {
  from { transform: translateY(0); }
  to { transform: translateY(-10%); }
}

.micromodal-slide {
  display: none;
}
.micromodal-slide.is-open {
  display: block;
}
.micromodal-slide[aria-hidden="false"] .modal__overlay {
  animation: mmfadeIn 0.3s cubic-bezier(0, 0, 0.2, 1);
}
.micromodal-slide[aria-hidden="false"] .modal__container {
  animation: mmslideIn 0.3s cubic-bezier(0, 0, 0.2, 1);
}
.micromodal-slide[aria-hidden="true"] .modal__overlay {
  animation: mmfadeOut 0.3s cubic-bezier(0, 0, 0.2, 1);
}
.micromodal-slide[aria-hidden="true"] .modal__container {
  animation: mmslideOut 0.3s cubic-bezier(0, 0, 0.2, 1);
}

/* Chat UI Styles */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 60vh;
  max-height: 500px;
  position: relative;
}
.chat-character-wrapper {
  position: absolute;
  bottom: -20px;
  left: -20px;
  width: 100px;
  z-index: 1001;
  pointer-events: none;
  transition: transform 0.3s ease;
}
.chat-character {
  width: 100%;
  height: auto;
  filter: drop-shadow(4px 4px 10px rgba(0,0,0,0.2));
  vertical-align: bottom;
}
.chat-input-wrapper {
  padding-left: 100px;
}
@media (max-width: 767px) {
  .chat-character-wrapper {
    display: none; /* スマホでは入力を優先するため非表示（またはお好みで薄く小さく） */
  }
  .chat-input-wrapper {
    padding-left: 0;
  }
  .modal__container {
    width: 95%;
    max-height: 95vh;
  }
  .modal__content {
    padding: 8px 8px 15px 8px;
  }
  .chat-display {
    padding: 8px 8px 8px 12px;
    margin-bottom: 8px;
  }
  .chat-bubble-content {
    font-size: 13px;
    max-width: 95%;
    padding: 6px 10px;
  }
}
.chat-display {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #fdfcfb;
  border-radius: 8px;
  margin-bottom: 15px;
  border: 1px solid #eee;
}
.chat-bubble {
  margin-bottom: 15px;
  display: flex;
}
.chat-bubble.assistant {
  justify-content: flex-start;
}
.chat-bubble.user {
  justify-content: flex-end;
}
.chat-bubble-content {
  max-width: 80%;
  padding: 10px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.chat-bubble.assistant .chat-bubble-content {
  background: #fff;
  color: #000;
  border: 1px solid #ddd;
  border-top-left-radius: 2px;
}
.chat-bubble.user .chat-bubble-content {
  background: #52473f;
  color: #fff;
  border-top-right-radius: 2px;
}
.chat-bubble.loading .chat-bubble-content {
  color: #000;
}
.chat-bubble.loading .chat-bubble-content:after {
  content: " ●";
  animation: blink 1s infinite;
  color: #52473f;
}
@keyframes blink {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}
.chat-input-group {
  display: flex;
  gap: 10px;
  position: relative;
  align-items: center;
}
.chat-input-field {
  flex: 1;
  padding: 10px 70px 10px 15px; /* 右側に長方形ボタン用の余白を確保 */
  border: 1px solid #ccc;
  border-radius: 25px;
  outline: none;
  font-size: 16px;
  color: #000;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}
.chat-input-field:focus {
  border-color: #52473f;
}
.chat-submit-btn {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  padding: 0 15px;
  background: #52473f;
  color: #fff;
  border: none;
  border-radius: 20px; /* 角丸長方形 */
  cursor: pointer;
  transition: opacity 0.2s;
  font-size: 13px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
}
.chat-submit-btn:hover {
  opacity: 0.9;
}
.chat-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 767px) {
  .chat-input-group {
    padding-bottom: 2px;
  }
  .chat-input-field {
    font-size: 16px;
    padding: 8px 65px 8px 12px;
  }
  .chat-submit-btn {
    min-width: 55px;
    font-size: 12px;
    padding: 0 12px;
    right: 3px;
    top: 3px;
    bottom: 3px;
  }
}

/* Markdown Specifics */
.chat-bubble-content blockquote {
    border-left: 4px solid #52473f;
    padding-left: 10px;
    color: #666;
    margin: 10px 0;
}
.chat-bubble-content code {
    background: #f0f0f0;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}
.chat-bubble-content pre {
    background: #f0f0f0;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 10px 0;
}
