/* ============================================
   CINNAMON CHALET - AI Assistant Styles
   ============================================ */

:root {
  --chat-primary: var(--color-primary, #c4742f);
  --chat-secondary: var(--color-secondary, #2d4a3e);
  --chat-bg: var(--color-white, #ffffff);
  --chat-text: var(--color-gray-700, #404040);
  --chat-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  --chat-border-radius: 20px;
}

/* Chat Floating Button */
#ai-chat-launcher {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background-color: var(--chat-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(196, 116, 47, 0.4);
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#ai-chat-launcher:hover {
  transform: scale(1.1);
}

#ai-chat-launcher.pulse::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: var(--chat-primary);
  border-radius: 50%;
  z-index: -1;
  animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

#ai-chat-launcher svg {
  width: 30px;
  height: 30px;
  fill: currentColor;
}

/* Chat Window */
#ai-chat-window {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 380px;
  max-width: calc(100vw - 60px);
  height: 550px;
  max-height: calc(100vh - 150px);
  background-color: var(--chat-bg);
  border-radius: var(--chat-border-radius);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1001;
  transform: translateY(20px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

#ai-chat-window.open {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

/* Chat Header */
.ai-chat-header {
  background-color: var(--chat-secondary);
  padding: 20px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-chat-avatar {
  width: 40px;
  height: 40px;
  background-color: var(--chat-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.ai-chat-header-text h3 {
  margin: 0;
  font-size: 1.1rem;
  color: white;
  font-family: var(--font-heading);
}

.ai-chat-header-text p {
  margin: 0;
  font-size: 0.8rem;
  opacity: 0.8;
}

.ai-chat-close {
  cursor: pointer;
  padding: 5px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

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

/* Chat Messages */
.ai-chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  background-color: #f9f9f9;
}

.ai-message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  position: relative;
}

.ai-message.assistant {
  align-self: flex-start;
  background-color: white;
  color: var(--chat-text);
  border-bottom-left-radius: 2px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.ai-message.user {
  align-self: flex-end;
  background-color: var(--chat-primary);
  color: white;
  border-bottom-right-radius: 2px;
}

.ai-message p {
    margin: 0 0 10px 0;
}

.ai-message p:last-child {
    margin-bottom: 0;
}

.ai-message strong {
    font-weight: 600;
    color: inherit;
}

.ai-message ul {
    margin: 8px 0;
    padding-left: 20px;
    list-style-type: disc;
}

.ai-message li {
    margin-bottom: 4px;
}

.ai-message li:last-child {
    margin-bottom: 0;
}

.chat-link {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.chat-link:hover {
    opacity: 0.8;
}


/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 15px;
  background: white;
  border-radius: 10px;
  width: fit-content;
  align-self: flex-start;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #ccc;
  border-radius: 50%;
  animation: typing 1s infinite alternate;
}

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

@keyframes typing {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-5px);
  }
}

/* Chat Input */
.ai-chat-input-area {
  padding: 15px 20px;
  background: white;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
  align-items: center;
}

.ai-chat-input {
  flex: 1;
  border: 1px solid #ddd;
  padding: 10px 15px;
  border-radius: 25px;
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.ai-chat-input:focus {
  border-color: var(--chat-primary);
}

.ai-chat-send {
  background: var(--chat-primary);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.ai-chat-send:hover {
  transform: scale(1.1);
}

.ai-chat-send svg {
  width: 20px;
  height: 20px;
  fill: white;
}

/* Scrollbar Style */
.ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: #eee;
  border-radius: 10px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #ddd;
}

@media (max-width: 580px) {
  #ai-chat-window {
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 80vh !important; /* Standard height for mobile chatbots */
    max-height: 80vh !important;
    border-radius: 24px 24px 0 0 !important;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
    transform: translateY(100%);
  }

  #ai-chat-window.open {
    transform: translateY(0) !important;
  }

  .ai-chat-header {
    padding: 15px 20px;
    background: var(--chat-secondary);
    border-radius: 24px 24px 0 0;
  }

  .ai-chat-avatar {
    width: 35px;
    height: 35px;
  }

  .ai-chat-header-text h3 {
    font-size: 1rem;
  }

  .ai-chat-messages {
    padding: 15px;
    background-color: #fcfcfc;
  }

  .ai-message {
    max-width: 90%;
    font-size: 0.92rem;
    padding: 11px 15px;
  }

  .ai-chat-input-area {
    padding: 15px !important;
    border-top: 1px solid #f0f0f0;
    background: white;
    /* Ensure it works with virtual keyboards */
    position: relative;
    z-index: 10;
  }

  .ai-chat-input {
    font-size: 16px !important; /* Critical to prevent iOS auto-zoom */
    padding: 12px 18px;
    height: 48px;
  }

  .ai-chat-send {
    width: 48px;
    height: 48px;
  }

  #ai-chat-launcher {
    bottom: 20px;
    right: 20px;
    width: 55px;
    height: 55px;
  }
}
