/* =========================================
   Chat Bar - Fixed bottom panel
   ========================================= */
.chat-bar {
  position: fixed;
  bottom: 0;
  right: 24px;
  width: 360px;
  z-index: 9999;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -2px 24px rgba(0, 0, 0, 0.14);
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header (always visible) */
.chat-bar-header {
  background: linear-gradient(135deg, #0056b3 0%, #003d80 100%);
  color: white;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

/* Online status dot */
.chat-bar-status {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  flex-shrink: 0;
  animation: chatStatusPulse 2.5s ease-in-out infinite;
}

@keyframes chatStatusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chat-bar-title {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.95em;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-bar-hint {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.78em;
  opacity: 0.85;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-bar--open .chat-bar-hint {
  display: none;
}

.chat-bar-chevron {
  flex-shrink: 0;
  transition: transform 0.3s ease;
  line-height: 1;
  font-size: 0.8em;
  opacity: 0.9;
}

.chat-bar--open .chat-bar-chevron {
  transform: rotate(180deg);
}

/* Body - expands on open */
.chat-bar-body {
  height: 0;
  overflow: hidden;
  transition: height 0.3s ease;
  display: flex;
  flex-direction: column;
  background: white;
}

.chat-bar--open .chat-bar-body {
  height: 400px;
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f9f9f9;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9em;
  line-height: 1.6;
  padding: 10px 14px;
  max-width: 85%;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-msg--user {
  align-self: flex-end;
  background: #0056b3;
  color: white;
  border-radius: 12px 12px 2px 12px;
}

.chat-msg--bot {
  align-self: flex-start;
  background: white;
  color: #333;
  border-radius: 12px 12px 12px 2px;
  border-left: 3px solid #0056b3;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Typing Indicator */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  background: #0056b3;
  border-radius: 50%;
  opacity: 0.4;
  animation: chatTypingDot 1.4s infinite;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chatTypingDot {
  0%, 80%, 100% {
    opacity: 0.4;
    transform: scale(1);
  }
  40% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* Input Area */
.chat-input-area {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid #eee;
  background: white;
  gap: 8px;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 16px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9em;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #0056b3;
}

.chat-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #0056b3;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.chat-send:hover {
  background: #003d80;
}

.chat-send:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.chat-send svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* Warning */
.chat-warning {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.7em;
  color: #999;
  text-align: center;
  padding: 4px 12px 8px;
  background: white;
  flex-shrink: 0;
}

/* Suggestion chips */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: flex-start;
  max-width: 100%;
  padding: 2px 0;
}

.chat-suggestion-btn {
  background: white;
  border: 1.5px solid #0056b3;
  color: #0056b3;
  border-radius: 16px;
  padding: 5px 12px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.78em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.chat-suggestion-btn:hover {
  background: #0056b3;
  color: white;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .chat-bar {
    right: 0;
    left: 0;
    width: 100%;
    border-radius: 12px 12px 0 0;
  }

  .chat-bar--open .chat-bar-body {
    height: 50vh;
  }
}
