/* =========================================
   Dime Widget — widget.css
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --dime-primary: #6C63FF;
  --dime-primary-dark: #5A52D5;
  --dime-primary-light: #EEF0FF;
  --dime-surface: #FFFFFF;
  --dime-bg: #F7F7FB;
  --dime-text: #1A1A2E;
  --dime-text-muted: #6B7280;
  --dime-border: #E5E7EB;
  --dime-shadow: 0 8px 32px rgba(108, 99, 255, 0.18);
  --dime-radius: 20px;
  --dime-bubble-size: 60px;
}

/* === Bubble Toggle Button === */
#dime-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: var(--dime-bubble-size);
  height: var(--dime-bubble-size);
  background: linear-gradient(135deg, var(--dime-primary), var(--dime-primary-dark));
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--dime-shadow);
  z-index: 9998;
  border: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  animation: dime-pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#dime-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 40px rgba(108, 99, 255, 0.35);
}

#dime-bubble svg {
  width: 28px;
  height: 28px;
  fill: white;
  transition: opacity 0.2s ease, transform 0.3s ease;
}

#dime-bubble .dime-close-icon {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

#dime-bubble.open .dime-chat-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

#dime-bubble.open .dime-close-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Notification dot */
#dime-notif-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #FF4E6A;
  border-radius: 50%;
  border: 2px solid white;
  animation: dime-pulse 2s infinite;
}

/* === Chat Window === */
#dime-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  max-height: 560px;
  background: var(--dime-surface);
  border-radius: var(--dime-radius);
  box-shadow: var(--dime-shadow);
  z-index: 9997;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  transform: scale(0.8) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  transform-origin: bottom right;
}

#dime-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* === Header === */
#dime-header {
  background: linear-gradient(135deg, var(--dime-primary), var(--dime-primary-dark));
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#dime-header-info {
  flex: 1;
}

#dime-bot-name {
  color: white;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
}

#dime-status {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

#dime-status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #4ADE80;
  border-radius: 50%;
  animation: dime-pulse 2s infinite;
}

/* === Messages === */
#dime-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--dime-bg);
  scroll-behavior: smooth;
  min-height: 200px;
}

#dime-messages::-webkit-scrollbar { width: 4px; }
#dime-messages::-webkit-scrollbar-track { background: transparent; }
#dime-messages::-webkit-scrollbar-thumb { background: var(--dime-border); border-radius: 2px; }

.dime-message {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  animation: dime-message-in 0.3s ease forwards;
}

.dime-message.bot {
  align-self: flex-start;
}

.dime-message.user {
  align-self: flex-end;
}

.dime-bubble-msg {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.dime-message.bot .dime-bubble-msg {
  background: var(--dime-surface);
  color: var(--dime-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.dime-bubble-msg strong { font-weight: 600; }
.dime-bubble-msg em { font-style: italic; }
.dime-bubble-msg code {
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 13px;
}

.dime-message.user .dime-bubble-msg {
  background: linear-gradient(135deg, var(--dime-primary), var(--dime-primary-dark));
  color: white;
  border-bottom-right-radius: 4px;
}

.dime-timestamp {
  font-size: 10px;
  color: var(--dime-text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

.dime-message.user .dime-timestamp {
  text-align: right;
}

/* Typing indicator */
#dime-typing {
  display: none;
  align-self: flex-start;
  background: var(--dime-surface);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  margin: 0 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

#dime-typing.visible { display: flex; gap: 5px; }

#dime-typing span {
  width: 7px;
  height: 7px;
  background: var(--dime-primary);
  border-radius: 50%;
  animation: dime-typing-dot 1.2s infinite;
}

#dime-typing span:nth-child(2) { animation-delay: 0.2s; }
#dime-typing span:nth-child(3) { animation-delay: 0.4s; }

/* Quick reply chips */
#dime-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px 0;
  background: var(--dime-bg);
}

.dime-chip {
  background: var(--dime-surface);
  border: 1.5px solid var(--dime-primary);
  color: var(--dime-primary);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.dime-chip:hover {
  background: var(--dime-primary);
  color: white;
}

/* === Lead Capture Form === */
.dime-lead-banner {
  background: var(--dime-surface);
  border: 1.5px solid var(--dime-primary);
  border-radius: 16px;
  padding: 16px;
  margin: 4px 0;
  animation: dime-message-in 0.3s ease forwards;
  align-self: flex-start;
  max-width: 90%;
}

.dime-lead-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--dime-text);
  margin-bottom: 4px;
}

.dime-lead-subtitle {
  font-size: 12px;
  color: var(--dime-text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.dime-lead-input {
  display: block;
  width: 100%;
  border: 1.5px solid var(--dime-border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--dime-text);
  background: var(--dime-bg);
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.dime-lead-input:focus {
  border-color: var(--dime-primary);
  background: white;
}

.dime-lead-input::placeholder {
  color: var(--dime-text-muted);
}

.dime-lead-btn {
  width: 100%;
  padding: 9px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--dime-primary), var(--dime-primary-dark));
  color: white;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dime-lead-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.35);
}

.dime-lead-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.dime-lead-dismiss {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 4px;
  border: none;
  background: transparent;
  color: var(--dime-text-muted);
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: color 0.2s ease;
}

.dime-lead-dismiss:hover {
  color: var(--dime-text);
}

/* === Input Area === */
#dime-input-area {
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--dime-border);
  background: var(--dime-surface);
  flex-shrink: 0;
}

#dime-input {
  flex: 1;
  border: 1.5px solid var(--dime-border);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--dime-text);
  outline: none;
  background: var(--dime-bg);
  transition: border-color 0.2s ease;
}

#dime-input:focus {
  border-color: var(--dime-primary);
  background: white;
}

#dime-input::placeholder { color: var(--dime-text-muted); }

#dime-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#dime-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--dime-primary), var(--dime-primary-dark));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#dime-send:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.4);
}

#dime-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

#dime-send svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* === Powered by === */
#dime-footer {
  text-align: center;
  font-size: 10px;
  color: var(--dime-text-muted);
  padding: 6px;
  background: var(--dime-surface);
  border-top: 1px solid var(--dime-border);
}

#dime-footer a {
  color: var(--dime-primary);
  text-decoration: none;
  font-weight: 600;
}

#dime-footer a:hover {
  text-decoration: underline;
}

/* === Animations === */
@keyframes dime-pop-in {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

@keyframes dime-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.7; transform: scale(1.15); }
}

@keyframes dime-message-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes dime-typing-dot {
  0%, 80%, 100% { transform: scale(1); opacity: 0.5; }
  40%           { transform: scale(1.3); opacity: 1; }
}

/* === Position: Bottom Left === */
.dime-position-left #dime-bubble {
  right: auto;
  left: 28px;
}

.dime-position-left #dime-window {
  right: auto;
  left: 28px;
  transform-origin: bottom left;
}

/* === Mobile === */
@media (max-width: 420px) {
  #dime-window {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 80px;
    max-height: 70vh;
  }

  #dime-bubble {
    right: 16px;
    bottom: 16px;
  }

  .dime-position-left #dime-window {
    left: 12px;
    right: auto;
  }

  .dime-position-left #dime-bubble {
    left: 16px;
    right: auto;
  }
}
