/* Enhanced Amrita Chat Widget Styles - Fixed Height & Better Spacing */
#amrita-chat-widget {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: #004d92; /* Primary blue */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  z-index: 9999;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Chat icon styling */
#amrita-chat-widget:before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H5.2L4 17.2V4h16v12z"/></svg>');
  background-repeat: no-repeat;
  background-position: center;
  transition: opacity 0.3s ease;
}

/* Open state for the chat widget */
#amrita-chat-widget.open {
  width: 350px;
  height: 450px;
  border-radius: 12px;
  background-color: #fff;
  transform: translateY(0) !important;
}

/* Hide the chat icon when open */
#amrita-chat-widget.open:before {
  opacity: 0;
}

/* Remove or hide default h3 title that takes up space */
#amrita-chat-widget h3 {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Header styling - COMPACT */
.amrita-chat-header {
  background: linear-gradient(135deg, #004d92 0%, #0076e0 100%); /* Blue gradient */
  color: white;
  padding: 12px 15px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  height: 40px; /* REDUCED height for header */
}

.amrita-chat-header:hover {
  background: linear-gradient(135deg, #005aa9 0%, #0088ff 100%);
}

/* Chat log container - FIXED HEIGHT CALCULATION */
.amrita-chat-log {
  flex: 1;
  padding: 10px 15px;
  overflow-y: auto;
  background-color: #f8f9fa;
  display: block !important;
  height: calc(100% - 100px); /* Adjusted to account for header and input */
  max-height: calc(100% - 100px);
}

/* Chat input container - FIXED HEIGHT */
.amrita-chat-input {
  display: flex !important;
  padding: 8px 10px;
  border-top: 1px solid #e9ecef;
  background-color: #fff;
  height: 56px; /* REDUCED height for input area */
  box-sizing: border-box;
}

/* Input field styling - FIXED HEIGHT */
#amrita-user-input {
  flex-grow: 1;
  padding: 8px 12px;
  border: 1px solid #ced4da;
  border-radius: 20px;
  font-size: 14px;
  margin-right: 8px;
  outline: none;
  height: 38px; /* REDUCED height for input field */
  max-height: 38px;
  min-height: 38px;
  resize: none; /* Prevent resizing */
  overflow-y: auto; /* Allow scrolling if text exceeds height */
}

#amrita-user-input:focus {
  border-color: #80bdff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Send button styling */
#amrita-send-button {
  padding: 8px 16px;
  background-color: #004d92; /* Primary blue */
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
  height: 38px; /* REDUCED height for button */
}

#amrita-send-button:hover {
  background-color: #0069d9;
}

/* Message styling - COMPACT */
.message {
  position: relative;
  word-wrap: break-word;
  margin-bottom: 8px; /* REDUCED margin */
  clear: both;
  padding: 8px 10px; /* REDUCED padding */
  border-radius: 16px;
  max-width: 80%;
  animation: fadeIn 0.3s ease-in-out;
}

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

/* User message styling */
.user-message {
  background-color: #e9f5ff; /* Light blue */
  color: #004d92; /* Dark blue */
  border-bottom-right-radius: 4px;
  float: right;
}

/* AI message styling */
.ai-message {
  background-color: #ffffff;
  color: #212529;
  border-bottom-left-radius: 4px;
  float: left;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  display: flex;
}

/* System message styling (errors) */
.system-message {
  background-color: #f8d7da;
  color: #721c24;
  text-align: center;
  font-size: 12px;
  padding: 4px 8px; /* REDUCED padding */
  margin: 6px auto; /* REDUCED margin */
  clear: both;
  display: inline-block;
  width: auto;
  max-width: 90%;
  border-radius: 10px;
}

/* Close button */
.amrita-chat-close {
  position: absolute;
  top: 8px; /* ADJUSTED position */
  right: 10px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  z-index: 10000;
  color: white;
  font-size: 22px; /* REDUCED size */
  line-height: 20px;
  text-align: center;
}

.amrita-chat-close:hover {
  opacity: 1;
}

/* Avatar styling - MORE COMPACT */
.avatar {
  width: 24px; /* REDUCED size */
  height: 24px; /* REDUCED size */
  min-width: 24px; /* REDUCED size */
  border-radius: 50%;
  margin-right: 6px; /* REDUCED margin */
  overflow: hidden;
  background-color: #004d92;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

/* Message content */
.message-content {
  padding: 0;
  line-height: 1.4;
  font-size: 14px; /* REDUCED font size */
}

.ai-message .message-content {
  padding-right: 8px; /* REDUCED padding */
}

/* Timestamp */
.timestamp {
  font-size: 9px; /* REDUCED font size */
  color: #adb5bd;
  margin-top: 2px; /* REDUCED margin */
  text-align: right;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  background-color: #ffffff;
  padding: 8px; /* REDUCED padding */
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  margin-bottom: 4px; /* REDUCED margin */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  float: left;
  clear: both;
}

.typing-dot {
  width: 6px; /* REDUCED size */
  height: 6px; /* REDUCED size */
  background-color: #004d92;
  border-radius: 50%;
  margin: 0 2px;
  animation: typing-animation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

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

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

@keyframes typing-animation {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); } /* REDUCED animation */
}

/* Force display properties for chat widget */
#amrita-chat-widget.force-display {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Responsiveness for mobile */
@media (max-width: 480px) {
  #amrita-chat-widget.open {
    width: calc(100% - 40px);
    height: 400px;
    bottom: 10px;
    right: 10px;
  }
}