/* ==================== AI Chat Widget ==================== */
.acm-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #c4956a;
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 9999;
  transition: transform 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.acm-chat-fab:hover { transform: scale(1.08); background: #b8845c; }

.acm-chat-panel {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 360px;
  height: 480px;
  background: #faf7f2;
  border: 1px solid #d4c5b0;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  animation: acmSlideUp 0.25s ease;
}
@keyframes acmSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.acm-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #c4956a;
  color: white;
  font-size: 14px;
  font-weight: 600;
}
.acm-chat-header-close {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.8;
}
.acm-chat-header-close:hover { opacity: 1; }

.acm-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.acm-chat-welcome {
  text-align: center;
  color: #a0937e;
  font-size: 13px;
  padding: 40px 16px;
}
.acm-chat-welcome p { margin: 0 0 8px; }

.acm-chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.acm-chat-msg.user {
  align-self: flex-end;
  background: #c4956a;
  color: white;
  border-bottom-right-radius: 4px;
}
.acm-chat-msg.assistant {
  align-self: flex-start;
  background: #f0ebe3;
  color: #4a3f32;
  border-bottom-left-radius: 4px;
}
.acm-chat-msg-quote {
  font-size: 12px;
  font-style: italic;
  color: rgba(255,255,255,0.8);
  border-left: 2px solid rgba(255,255,255,0.5);
  padding-left: 8px;
  margin-bottom: 6px;
}
.acm-chat-msg.assistant .acm-chat-msg-quote {
  color: #a0937e;
  border-left-color: #c4956a;
}
.acm-chat-typing {
  color: #a0937e;
  animation: acmPulse 1.2s infinite;
}
@keyframes acmPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Selected text bar */
.acm-chat-selected {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #f0ebe3;
  border-top: 1px solid #d4c5b0;
  font-size: 12px;
  color: #6b5e4f;
}
.acm-chat-selected-label {
  color: #c4956a;
  font-weight: 600;
  white-space: nowrap;
}
.acm-chat-selected-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
}
.acm-chat-selected-clear {
  background: none;
  border: none;
  color: #a0937e;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
}
.acm-chat-selected-clear:hover { color: #c4956a; }

/* Input area */
.acm-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #d4c5b0;
  background: #faf7f2;
  align-items: flex-end;
}
.acm-chat-input {
  flex: 1;
  border: 1px solid #d4c5b0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: #4a3f32;
  outline: none;
  resize: none;
  max-height: 80px;
}
.acm-chat-input:focus { border-color: #c4956a; }
.acm-chat-input::placeholder { color: #a0937e; }
.acm-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #c4956a;
  color: white;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.acm-chat-send:disabled { opacity: 0.4; cursor: not-allowed; }
.acm-chat-send:not(:disabled):hover { background: #b8845c; }

.acm-chat-disclaimer {
  text-align: center;
  font-size: 10px;
  color: #a0937e;
  padding: 4px 16px 8px;
}

/* Text selection tooltip */
.acm-selection-tooltip {
  position: absolute;
  background: #c4956a;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: -apple-system, sans-serif;
  cursor: pointer;
  z-index: 9997;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  white-space: nowrap;
  animation: acmFadeIn 0.15s ease;
}
.acm-selection-tooltip:hover { background: #b8845c; }
@keyframes acmFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Responsive */
@media (max-width: 480px) {
  .acm-chat-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 80px;
    height: 60vh;
  }
}
