/**
 * eNest Chatbot Widget Styles
 * Modern, clean UI matching Streamlit design
 */

/* ==================== MAIN CHAT WIDGET ==================== */
#enest-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ==================== CHAT ICON BUTTON ==================== */
.enest-chat-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #2240C6;
  border: none;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: white;
  transition: all 0.3s ease;
  animation: pulse 2s ease-in-out infinite;
}

.enest-chat-icon:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

.enest-chat-icon:active {
  transform: scale(0.95);
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  }
  50% {
    box-shadow: 0 4px 30px rgba(102, 126, 234, 0.6);
  }
}

.enest-chat {
  width: 370px;
  max-width: 90vw;
  height: 600px;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: white;
  animation: slideUp 0.3s ease-out;
  position: relative; /* For absolute positioning of feedback modal */
}

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

/* ==================== HEADER ==================== */
.enest-header {
  background: #2240C6;
  color: white;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.enest-header span:first-child {
  font-size: 20px;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.enest-end {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
  height: 28px;
  display: flex;
  align-items: center;
}

.enest-end:hover {
  background: rgba(255, 255, 255, 0.3);
}

.enest-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.enest-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ==================== CHAT BODY ==================== */
.enest-body {
  flex: 1;
  overflow-y: auto;
  background: #f5f6fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.enest-body::-webkit-scrollbar {
  width: 6px;
}

.enest-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.enest-body::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 10px;
}

.enest-body::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* ==================== MESSAGES ==================== */
.message {
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 85%;
  word-wrap: break-word;
  line-height: 1.5;
  animation: fadeIn 0.3s ease-out;
}

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

.message.user {
  background: #2240C6;
  color: white;
  border-radius: 12px 12px 0 12px;
  margin-left: auto;
  /* text-align: right; */
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.message.bot {
  background: white;
  color: #333;
  border-radius: 12px 12px 12px 0;
  margin-right: auto;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border-left: 3px solid #ffc700;
}

.message.bot p {
  margin: 0;
  padding: 0;
}

.message.bot p + p {
  margin-top: 8px;
}

.welcome-message {
  background: #2240C615;
  border-left: 3px solid #667eea;
}

.message.error {
  background: #fee;
  color: #c33;
  border-left-color: #c33;
}

/* ==================== CLICKABLE LINKS IN MESSAGES ==================== */
.message.bot .chat-link {
  color: #2240C6;
  text-decoration: underline;
  font-weight: 500;
  transition: all 0.2s;
  word-break: break-all;
}

.message.bot .chat-link:hover {
  color: #2240C6;
  text-decoration: underline;
  opacity: 0.8;
}

.message.bot .chat-link:visited {
  color: #2240C6;
}

/* ==================== LOADING ==================== */
.loading {
  background: white;
  padding: 12px 16px;
}

.loading-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2240C6;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* ==================== MEDIA CONTAINERS ==================== */
.media-container {
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
}

.media-container video,
.media-container audio {
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
}

/* ==================== SOURCE DETAILS ==================== */
.source-details {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e0e0e0;
}

.source-details summary {
  cursor: pointer;
  font-size: 12px;
  color: #666;
  font-weight: 500;
  user-select: none;
}

.source-details summary:hover {
  color: #2240C6;
}

.source-content {
  margin-top: 8px;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 6px;
  font-size: 11px;
  color: #666;
  line-height: 1.6;
}

.source-content small {
  display: block;
  margin-bottom: 4px;
}

/* ==================== INPUT AREA ==================== */
.enest-input {
  display: flex;
  border-top: 1px solid #e0e0e0;
  background: white;
  padding: 0;
}

.enest-input input {
  flex: 1;
  border: none;
  padding: 14px 16px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.enest-input input::placeholder {
  color: #999;
}

.enest-input input:disabled {
  background: #f5f5f5;
  color: #999999;
  cursor: not-allowed;
  opacity: 0.7;
}

.enest-input button {
  background: #2240C6;
  color: white;
  border: none;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.enest-input button:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.enest-input button:active {
  transform: scale(0.98);
}

.enest-input button:disabled {
  background: #b0b0b0;
  color: #ffffff;
  cursor: not-allowed;
  opacity: 0.7;
  filter: grayscale(100%);
  transform: none;
  pointer-events: none;
}

.enest-input button:disabled:hover {
  opacity: 0.7;
  transform: none;
  box-shadow: none;
}

/* ==================== PROFILE FORM (Inside Chat Widget) ==================== */
.enest-profile-form {
  /* padding: 20px; */
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-form-content {
  width: 100%;
  max-width: 100%;
}

.profile-form-content h3 {
  margin: 0 0 8px 0;
  font-size: 24px;
  color: #333;
  font-weight: 600;
  text-align: center;
}

.profile-form-content .profile-subtitle {
  margin: 0 0 20px 0;
  color: #666;
  font-size: 14px;
  text-align: center;
}

.profile-form-content input,
.profile-form-content select {
  width: 100%;
  padding: 12px;
  margin-bottom: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.profile-form-content input:focus,
.profile-form-content select:focus {
  outline: none;
  border-color: #2240C6;
}

.profile-form-content select {
  cursor: pointer;
  background: white;
}

.profile-form-content .profile-btn {
  width: 100%;
  padding: 14px;
  background: #FFC700;
  color: #111;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  outline: none;
}

.profile-form-content .profile-btn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px #FFC700;
}

.profile-form-content .profile-btn:active {
  transform: translateY(0);
  outline: none;
}

.profile-form-content .profile-note {
  margin: 12px 0 0 0;
  font-size: 12px;
  color: #999;
  text-align: center;
}

/* ==================== PROFILE MODAL (Legacy - kept for compatibility) ==================== */
.enest-profile {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease-out;
  backdrop-filter: blur(4px);
}

.profile-box {
  background: white;
  padding: 28px;
  width: 90%;
  max-width: 400px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease-out;
}

.profile-box h3 {
  margin: 0 0 8px 0;
  font-size: 24px;
  color: #333;
  font-weight: 600;
}

.profile-subtitle {
  margin: 0 0 20px 0;
  color: #666;
  font-size: 14px;
}

.profile-box input,
.profile-box select {
  width: 100%;
  padding: 12px;
  margin-bottom: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.profile-box input:focus,
.profile-box select:focus {
  outline: none;
  border-color: #2240C6;
}

.profile-box select {
  cursor: pointer;
  background: white;
}

.profile-btn {
  width: 100%;
  padding: 14px;
  background: #FFC700;
  color: #111;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.profile-btn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px #ffc700;
}

.profile-btn:active {
  transform: translateY(0);
}

.profile-note {
  margin: 12px 0 0 0;
  font-size: 12px;
  color: #999;
  text-align: center;
}
.error-message{
  color: rgb(180, 0, 0);
  font-size: 14px;
  text-align: center;
  font-weight: 600;
  margin-bottom: 5px;
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 480px) {
  #enest-chat-widget {
    bottom: 0;
    right: 0;
    left: 0;
  }

  .enest-chat {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .profile-box {
    width: 95%;
    padding: 24px;
  }
}

/* ==================== ACCESSIBILITY ==================== */
/* .enest-chat *:focus {
  outline: 2px solid #ffc700;
  outline-offset: 2px;
} */

/* ==================== PRINT STYLES ==================== */
@media print {
  #enest-chat-widget {
    display: none;
  }
}

/* ==================== FEEDBACK MODAL ==================== */
.enest-feedback-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /* background: rgba(255, 255, 255, 0.98); */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 12px;
  backdrop-filter: blur(2px);
}

.feedback-modal-content {
  background: white;
  border-radius: 12px;
  width: calc(100% - 32px);
  max-width: 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  animation: modalSlideIn 0.3s ease-out;
  max-height: calc(100% - 40px);
  display: flex;
  flex-direction: column;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.feedback-header {
  background: #2240C6;
  color: white;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.feedback-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.feedback-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.feedback-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.feedback-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.feedback-instruction {
  text-align: center;
  color: #555;
  margin-bottom: 24px;
  font-size: 14px;
}

.rating-emojis {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  background:none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.rating-btn:hover {
  transform: translateY(-2px);
}

.rating-btn.selected {
  background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.rating-btn .emoji {
  font-size: 30px;
  line-height: 1;
}

.rating-btn .rating-label {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.rating-btn.selected .rating-label {
  color: #667eea;
  font-weight: 600;
}

.feedback-text-container {
  margin-bottom: 20px;
}

.feedback-text-container textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.feedback-text-container textarea:focus {
  outline: none;
  border-color: #667eea;
}

.feedback-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.feedback-submit-btn,
.feedback-skip-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.feedback-submit-btn {
  background: #2240C6;
  color: white;
}

.feedback-submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.feedback-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.feedback-skip-btn {
  background: #f5f6fa;
  color: #666;
}

.feedback-skip-btn:hover {
  background: #e8eaf6;
}

/* ==================== CONTINUE CHAT BUTTON /NEW CHAT BUTTON==================== */
.continue-chat-btn, .enest-start-new-chat-btn {
  background: #2240C6;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.continue-chat-btn:hover, .enest-start-new-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.continue-chat-btn:active, .enest-start-new-chat-btn:active {
  transform: translateY(0);
}

@media (max-width: 480px) {
  .feedback-modal-content {
    width: calc(100% - 20px);
    margin: 10px;
  }

  .feedback-body {
    padding: 16px;
  }

  .rating-emojis {
    gap: 12px;
  }

  .rating-btn {
    min-width: 80px;
    padding: 12px 16px;
  }

  .rating-btn .emoji {
    font-size: 36px;
  }

  .feedback-actions {
    flex-direction: column;
  }

  .feedback-submit-btn,
  .feedback-skip-btn {
    width: 100%;
  }
}
.purpose-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  justify-content: flex-start;
}

.purpose-btn {
  background: #2240C6;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  box-shadow: 0 2px 6px rgba(102,126,234,0.13);
  margin: 0 2px 2px 0;
  outline: none;
  font-family: inherit;
}
.purpose-btn:hover {
  background: linear-gradient(90deg, #5a67d8 0%, #667eea 100%);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.16);
}
.purpose-btn:active {
  background: linear-gradient(90deg, #434190 0%, #667eea 100%);
  transform: none;
}
@media (max-width: 480px) {
  .purpose-buttons {
    gap: 8px;
    flex-direction: column;
  }
  .purpose-btn {
    width: 100%;
    padding: 14px 0;
    font-size: 16px;
  }
}
