/**
 * Agleam Toolkit - Frontend Chat Widget Styles
 */

#agm-chat-widget {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  left: auto !important;
  top: auto !important;
  z-index: 9999 !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#agm-chat-widget.visible {
  opacity: 1;
  transform: translateY(0);
}

/* トグルボタン（最小化時） */
.agm-chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dfb055 0%, #c9994a 100%);
  border: none;
  box-shadow: 0 4px 12px rgba(223, 176, 85, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: all 0.3s ease;
  position: relative;
}

.agm-chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(223, 176, 85, 0.5);
  background: linear-gradient(135deg, #c9994a 0%, #b8883a 100%);
}

.agm-chat-toggle:active {
  transform: scale(0.95);
}

.agm-chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #e74c3c;
  color: #fff;
  border-radius: 12px;
  min-width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  padding: 0 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* チャットウィンドウ */
.agm-chat-window {
  width: 360px;
  height: 500px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.8);
  transform-origin: bottom right;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

#agm-chat-widget:not(.minimized) .agm-chat-window {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

#agm-chat-widget.minimized .agm-chat-toggle {
  display: flex;
}

#agm-chat-widget:not(.minimized) .agm-chat-toggle {
  display: none;
}

/* ヘッダー */
.agm-chat-header {
  background: linear-gradient(135deg, #142037 0%, #1a2d4d 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.agm-chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.agm-chat-minimize {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.agm-chat-minimize:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* メッセージエリア */
.agm-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agm-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.agm-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.agm-chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.agm-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* ウェルカムメッセージ */
.agm-chat-welcome {
  text-align: center;
  color: #666;
  font-size: 14px;
  padding: 20px;
}

.agm-chat-welcome p {
  margin: 0;
}

/* メッセージ */
.agm-chat-message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.agm-chat-message.visitor {
  align-self: flex-end;
  background: linear-gradient(135deg, #142037 0%, #1a2d4d 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.agm-chat-message.admin {
  align-self: flex-start;
  background: #f1f3f4;
  color: #142037;
  border: 1px solid #dfb055;
  border-left: 3px solid #dfb055;
  border-bottom-left-radius: 4px;
}

.agm-chat-message-content {
  white-space: pre-wrap;
}

.agm-chat-message-time {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.7;
}

.agm-chat-message.visitor .agm-chat-message-time {
  text-align: right;
}

.agm-chat-message.admin .agm-chat-message-time {
  text-align: left;
  color: #999;
}

/* エラーメッセージ */
.agm-chat-error {
  background: #ffe8e8;
  color: #c33;
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  animation: slideIn 0.3s ease;
}

/* 入力エリア */
.agm-chat-input-area {
  padding: 16px;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#agm-chat-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
}

#agm-chat-input:focus {
  outline: none;
  border-color: #dfb055;
  box-shadow: 0 0 0 2px rgba(223, 176, 85, 0.1);
}

#agm-chat-send {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #dfb055 0%, #c9994a 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

#agm-chat-send:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(223, 176, 85, 0.4);
  background: linear-gradient(135deg, #c9994a 0%, #b8883a 100%);
}

#agm-chat-send:active:not(:disabled) {
  transform: scale(0.95);
}

#agm-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* レスポンシブ */
@media (max-width: 480px) {
  #agm-chat-widget {
    bottom: 10px;
    right: 10px;
    left: 10px;
  }

  .agm-chat-window {
    width: 100%;
    height: 450px;
  }

  .agm-chat-toggle {
    position: absolute;
    bottom: 0;
    right: 0;
  }
}

@media (max-height: 600px) {
  .agm-chat-window {
    height: 400px;
  }
}
