/* Define default CSS variables */
:root {
  --chatty-primary-color: #007BFF;
  --chatty-agent-bubble-color: #e9e9eb;
  --chatty-user-bubble-color: var(--chatty-primary-color);
  --chatty-agent-text-color: #333;
  --chatty-user-text-color: #fff;
  --chatty-shadow-color: rgba(0, 0, 0, 0.15);
}

/* Base widget styles */
.chatty-widget {
  position: fixed;
  font-family: sans-serif;
  z-index: 9999;
  bottom: 20px;
  right: 20px;
}

/* Chat button - DaisyUI btn style */
.chatty-button {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 9999px;
  background-color: var(--chatty-primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  box-shadow: 0 4px 12px var(--chatty-shadow-color);
  z-index: 99999;
  transition: all 200ms;
}

.chatty-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px var(--chatty-shadow-color);
  filter: brightness(1.1);
}

/* Chat popup - DaisyUI card style */
.chatty-popup {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 320px;
  height: 450px;
  border-radius: 1rem;
  background-color: white;
  box-shadow: 0 5px 25px var(--chatty-shadow-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99998;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: all 200ms;
}

/* Chat header - DaisyUI navbar style */
.chatty-header {
  background-color: var(--chatty-primary-color);
  color: white;
  padding: 1rem;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 3rem;
  box-shadow: 0 2px 4px var(--chatty-shadow-color);
}

.chatty-close {
  cursor: pointer;
  font-size: 1.5rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  transition: background-color 200ms;
}

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

/* Messages container */
.chatty-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  background-color: #f8f9fa;
  scroll-behavior: smooth;
}

/* Input area - DaisyUI form-control style */
.chatty-input-area {
  padding: 0.75rem;
  border-top: 1px solid #eee;
  display: flex;
  align-items: center;
  background-color: white;
  gap: 0.5rem;
}

.chatty-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 9999px;
  outline: none;
  font-size: 0.875rem;
  line-height: 1.25rem;
  transition: border-color 200ms;
  background-color: #f8f9fa;
}

.chatty-input:focus {
  border-color: var(--chatty-primary-color);
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

/* Send button - DaisyUI btn-circle style */
.chatty-send {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  background-color: var(--chatty-primary-color);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 200ms;
  flex-shrink: 0;
}

.chatty-send:hover {
  filter: brightness(1.1);
  transform: scale(1.05);
}

.chatty-send:active {
  transform: scale(0.95);
}

/* Messages - DaisyUI chat-bubble style */
.chatty-message {
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  max-width: 80%;
  border-radius: 1rem;
  position: relative;
  word-wrap: break-word;
  line-height: 1.4;
  animation: message-pop 0.2s ease-out;
}

.chatty-message-client {
  margin-left: auto;
  background-color: var(--chatty-user-bubble-color);
  color: var(--chatty-user-text-color);
  border-bottom-right-radius: 0.25rem;
}

.chatty-message-agent {
  margin-right: auto;
  background-color: var(--chatty-agent-bubble-color);
  color: var(--chatty-agent-text-color);
  border-bottom-left-radius: 0.25rem;
}

.chatty-message-time {
  font-size: 0.625rem;
  margin-top: 0.375rem;
  opacity: 0.7;
  text-align: right;
}

/* Typing indicator */
.chatty-typing-indicator {
  margin-bottom: 0.75rem;
  margin-right: auto;
  padding: 0.75rem 1rem;
  background-color: var(--chatty-agent-bubble-color);
  border-radius: 1rem;
  color: var(--chatty-agent-text-color);
  border-bottom-left-radius: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 4rem;
}

.chatty-typing-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background-color: #999;
  animation: chatty-typing 1.4s infinite ease-in-out both;
}

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

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

/* Animations */
@keyframes chatty-typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

@keyframes message-pop {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scrollbar styling */
.chatty-messages::-webkit-scrollbar {
  width: 0.5rem;
}

.chatty-messages::-webkit-scrollbar-track {
  background: #f8f9fa;
}

.chatty-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 9999px;
}

.chatty-messages::-webkit-scrollbar-thumb:hover {
  background: #ccc;
}

/* Focus and active states */
.chatty-button:focus,
.chatty-input:focus,
.chatty-send:focus {
  outline: none;
  box-shadow: 0 0 0 2px white, 0 0 0 4px var(--chatty-primary-color);
}