/* PerformanceLens Customer Agent — Chat Widget Styles */

/* ============================================================
   Container & Positioning
   ============================================================ */
.agent-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 9998;
}

.agent-chat-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
}

.agent-chat-launcher svg {
  width: 24px;
  height: 24px;
  fill: #fff;
}

.agent-chat-launcher .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}

.agent-chat-launcher .badge.visible {
  display: flex;
}

/* ============================================================
   Chat Panel
   ============================================================ */
.agent-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #1a1b2e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

.agent-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ============================================================
   Header
   ============================================================ */
.agent-chat-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.1));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.agent-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.agent-chat-header-info h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
}

.agent-chat-header-info p {
  margin: 0;
  font-size: 11px;
  color: #94a3b8;
}

.agent-chat-header-actions {
  display: flex;
  gap: 6px;
}

.agent-chat-header-actions button {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.agent-chat-header-actions button:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.06);
}

.agent-chat-header-actions .agent-close-btn {
  color: #fff;
  margin-left: 6px;
  background: rgba(239, 68, 68, 0.8);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 17px;
  line-height: 1;
}

.agent-chat-header-actions .agent-close-btn:hover {
  color: #fff;
  background: rgba(239, 68, 68, 1);
}

/* ============================================================
   Messages Area
   ============================================================ */
.agent-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.agent-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.agent-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* Welcome message */
.agent-chat-welcome {
  text-align: center;
  padding: 24px 16px;
  color: #94a3b8;
}

.agent-chat-welcome h4 {
  color: #f1f5f9;
  font-size: 16px;
  margin: 0 0 8px 0;
}

.agent-chat-welcome p {
  font-size: 13px;
  margin: 0 0 16px 0;
  line-height: 1.5;
}

.agent-chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-chat-suggestion {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  color: #c7d2fe;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.agent-chat-suggestion:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.35);
}

/* Message bubbles */
.agent-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.agent-msg-user {
  align-self: flex-end;
  background: #6366f1;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.agent-msg-assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.agent-msg-system {
  align-self: center;
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
}

/* Feedback buttons on assistant messages */
.agent-msg-feedback {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.agent-msg-feedback button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #64748b;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.15s;
}

.agent-msg-feedback button svg {
  display: block;
}

.agent-msg-feedback button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  transform: scale(1.05);
}

.agent-msg-feedback button:disabled {
  cursor: default;
  opacity: 0.5;
  transform: none;
}

.agent-msg-feedback button.active-up {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.3);
  opacity: 1;
  transform: scale(1.1);
}

.agent-msg-feedback button.active-down {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  opacity: 1;
  transform: scale(1.1);
}

/* Typing indicator */
.agent-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
}

.agent-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6366f1;
  animation: agentTypingBounce 1.4s ease-in-out infinite;
}

.agent-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.agent-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes agentTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================================
   Input Area
   ============================================================ */
.agent-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.agent-chat-input-area textarea {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 14px;
  color: #f1f5f9;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s;
}

.agent-chat-input-area textarea::placeholder {
  color: #64748b;
}

.agent-chat-input-area textarea:focus {
  border-color: rgba(99, 102, 241, 0.5);
}

.agent-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #6366f1;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

.agent-chat-send:hover {
  background: #5558e6;
}

.agent-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.agent-chat-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* ============================================================
   Disclaimer
   ============================================================ */
.agent-chat-disclaimer {
  padding: 6px 16px 10px;
  text-align: center;
  font-size: 10px;
  color: #475569;
  flex-shrink: 0;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 480px) {
  .agent-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .agent-chat-launcher {
    bottom: 16px;
    right: 16px;
  }
}

/* ============================================================
   Escalation Banner
   ============================================================ */
.agent-escalation-banner {
  padding: 10px 16px;
  background: rgba(251, 191, 36, 0.1);
  border-bottom: 1px solid rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  font-size: 12px;
  text-align: center;
  flex-shrink: 0;
}

/* ============================================================
   Escalation Email Prompt
   ============================================================ */
.agent-email-prompt {
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 12px;
  padding: 14px;
  margin-top: 4px;
}

.agent-email-prompt label {
  display: block;
  font-size: 12px;
  color: #c7d2fe;
  margin-bottom: 8px;
}

.agent-email-row {
  display: flex;
  gap: 8px;
}

.agent-email-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px 12px;
  color: #f1f5f9;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.agent-email-input:focus {
  border-color: rgba(99, 102, 241, 0.5);
}

.agent-email-input::placeholder {
  color: #64748b;
}

.agent-email-send {
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.agent-email-send:hover {
  background: #5558e6;
}

.agent-email-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.agent-email-confirmed {
  font-size: 13px;
  color: #4ade80;
  line-height: 1.5;
}

/* ============================================================
   Conversation History
   ============================================================ */
.agent-history-loading {
  color: #94a3b8;
  text-align: center;
  padding: 32px 16px;
  font-size: 13px;
}

.agent-history-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.agent-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 12px 0;
}

.agent-history-header h4 {
  color: #f1f5f9;
  font-size: 14px;
  margin: 0;
}

.agent-history-back {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.agent-history-back:hover {
  background: rgba(99, 102, 241, 0.2);
}

.agent-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.agent-history-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  width: 100%;
}

.agent-history-item:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
}

.agent-history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.agent-history-preview {
  color: #e2e8f0;
  font-size: 13px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.agent-history-date {
  color: #8893a7;
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}
