/* Cresteo Chat Widget Styles */

.cresteo-chat-widget {
  --cresteo-primary: #FD5001;
  --cresteo-primary-dark: #CB3703;
  --cresteo-gradient: linear-gradient(272.75deg, #F5FF40 -111.43%, #FD5001 84.32%);
  --cresteo-bg: #FAF5EE;
  --cresteo-text: #181715;
  --cresteo-text-secondary: #726E69;
  --cresteo-border: #EAE4DA;
  --cresteo-bubble-user: var(--cresteo-primary);
  --cresteo-bubble-assistant: #FFFFFF;
  --cresteo-radius: 12px;
  --cresteo-shadow: 0 8px 32px rgba(24, 23, 21, 0.15);

  font-family: "Bai Jamjuree", "Inter", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cresteo-text);
}

/* Floating button */
.cresteo-fab {
  position: fixed;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--cresteo-gradient);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(24, 23, 21, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cresteo-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.cresteo-fab.bottom-right {
  bottom: 24px;
  right: 24px;
}

.cresteo-fab.bottom-left {
  bottom: 24px;
  left: 24px;
}

.cresteo-fab svg {
  width: 24px;
  height: 24px;
  transition: transform 0.2s ease;
}

.cresteo-fab[data-open="true"] svg {
  transform: rotate(90deg);
}

/* Chat panel */
.cresteo-panel {
  position: fixed;
  z-index: 9999;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--cresteo-bg);
  border-radius: var(--cresteo-radius);
  box-shadow: var(--cresteo-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cresteo-panel[data-open="true"] {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.cresteo-panel.bottom-right {
  bottom: 92px;
  right: 24px;
}

.cresteo-panel.bottom-left {
  bottom: 92px;
  left: 24px;
}

/* Header */
.cresteo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--cresteo-gradient);
  color: #fff;
  flex-shrink: 0;
}

.cresteo-header-title {
  font-family: "Bai Jamjuree", sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.cresteo-header-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  opacity: 0.8;
  transition: opacity 0.15s ease;
}

.cresteo-header-close:hover {
  opacity: 1;
}

/* Messages area */
.cresteo-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

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

.cresteo-messages::-webkit-scrollbar-thumb {
  background: var(--cresteo-border);
  border-radius: 2px;
}

/* Welcome message */
.cresteo-welcome {
  text-align: center;
  padding: 24px 16px;
  color: var(--cresteo-text-secondary);
  font-size: 14px;
}

.cresteo-welcome-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--cresteo-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 24px;
}

/* Message bubbles */
.cresteo-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.cresteo-message-user {
  align-self: flex-end;
  background: var(--cresteo-bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cresteo-message-assistant {
  align-self: flex-start;
  background: var(--cresteo-bubble-assistant);
  border: 1px solid var(--cresteo-border);
  color: var(--cresteo-text);
  border-bottom-left-radius: 4px;
}

/* Markdown content in assistant messages */
.cresteo-message-assistant p {
  margin: 0 0 8px;
}

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

.cresteo-message-assistant a {
  color: var(--cresteo-primary);
  text-decoration: underline;
}

.cresteo-message-assistant ul,
.cresteo-message-assistant ol {
  margin: 4px 0;
  padding-left: 20px;
}

.cresteo-message-assistant code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

.cresteo-message-assistant pre {
  background: rgba(0, 0, 0, 0.06);
  padding: 8px 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 4px 0;
}

.cresteo-message-assistant pre code {
  background: none;
  padding: 0;
}

.cresteo-message-assistant strong {
  font-weight: 600;
}

/* Typing indicator */
.cresteo-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.cresteo-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cresteo-text-secondary);
  animation: cresteo-bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes cresteo-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Composer */
.cresteo-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--cresteo-border);
  background: var(--cresteo-bg);
  flex-shrink: 0;
}

.cresteo-composer textarea {
  flex: 1;
  border: 1px solid var(--cresteo-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 40px;
  background: var(--cresteo-bg);
  color: var(--cresteo-text);
  transition: border-color 0.15s ease;
}

.cresteo-composer textarea:focus {
  border-color: var(--cresteo-primary);
}

.cresteo-composer textarea::placeholder {
  color: var(--cresteo-text-secondary);
}

.cresteo-composer-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--cresteo-gradient);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}

.cresteo-composer-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cresteo-composer-send svg {
  width: 16px;
  height: 16px;
}

/* Error state */
.cresteo-error {
  padding: 8px 12px;
  margin: 8px 16px;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .cresteo-panel {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 0;
  }

  .cresteo-fab {
    bottom: 16px;
  }

  .cresteo-fab.bottom-right {
    right: 16px;
  }

  .cresteo-fab.bottom-left {
    left: 16px;
  }
}

