/**
 * Dipon AI Chat — Frontend Styles
 * Versi: 1.0.0
 *
 * Berisi styling untuk:
 * - Floating chat bubble (widget)
 * - Embedded chat (shortcode)
 * - Animasi dan transisi
 * - Tema dark mode
 */

/* ═══════════════════════════════════════════════
   CSS VARIABLES & RESET
═══════════════════════════════════════════════ */
:root {
  --dipon-primary: #6c63ff;
  --dipon-primary-dark: #5a52d5;
  --dipon-primary-light: #e8e6ff;
  --dipon-bg: #ffffff;
  --dipon-bg-secondary: #f8f9fa;
  --dipon-text: #1a1a2e;
  --dipon-text-muted: #6b7280;
  --dipon-border: #e5e7eb;
  --dipon-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  --dipon-shadow-fab: 0 8px 25px rgba(108, 99, 255, 0.4);
  --dipon-radius: 20px;
  --dipon-radius-sm: 12px;
  --dipon-radius-msg: 18px;
  --dipon-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  --dipon-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --dipon-chat-width: 380px;
  --dipon-chat-height: 560px;
}

/* ═══════════════════════════════════════════════
   FLOATING WIDGET CONTAINER
═══════════════════════════════════════════════ */
#dipon-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: var(--dipon-font);
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════
   CHAT WINDOW (Floating)
═══════════════════════════════════════════════ */
.dipon-chat-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: var(--dipon-chat-width);
  height: var(--dipon-chat-height);
  background: var(--dipon-bg);
  border-radius: var(--dipon-radius);
  box-shadow: var(--dipon-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--dipon-border);

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: var(--dipon-transition);
}

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

/* ═══════════════════════════════════════════════
   CHAT HEADER
═══════════════════════════════════════════════ */
.dipon-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--dipon-primary) 0%, var(--dipon-primary-dark) 100%);
  flex-shrink: 0;
}

.dipon-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dipon-avatar {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.dipon-avatar-sm {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.dipon-chat-header .dipon-bot-name {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.dipon-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}

.dipon-status-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  animation: dipon-pulse 2s infinite;
}

@keyframes dipon-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

.dipon-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dipon-close-btn,
.dipon-action-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: var(--dipon-transition);
  flex-shrink: 0;
}

.dipon-close-btn:hover,
.dipon-action-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* ═══════════════════════════════════════════════
   MESSAGES AREA
═══════════════════════════════════════════════ */
.dipon-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--dipon-bg-secondary);

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--dipon-border) transparent;
}

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

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

.dipon-messages-area::-webkit-scrollbar-thumb {
  background-color: var(--dipon-border);
  border-radius: 20px;
}

/* ═══════════════════════════════════════════════
   CHAT MESSAGES
═══════════════════════════════════════════════ */
.dipon-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: dipon-msg-appear 0.3s ease-out forwards;
}

/* Wrapper bubble + copy btn */
.dipon-msg-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  gap: 4px;
}

.dipon-message-user .dipon-msg-wrapper {
  align-items: flex-end;
}

/* Per-message copy button */
.dipon-copy-msg-btn {
  border: none;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 0 4px;
  line-height: 1;
  color: var(--dipon-text-muted);
}

.dipon-message:hover .dipon-copy-msg-btn {
  opacity: 1;
}

@keyframes dipon-msg-appear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dipon-message-user {
  flex-direction: row-reverse;
}

.dipon-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: var(--dipon-primary-light);
  border: 2px solid rgba(108, 99, 255, 0.15);
  flex-shrink: 0;
}

.dipon-message-user .dipon-msg-avatar {
  background: var(--dipon-primary);
  color: #fff;
  font-size: 13px;
}

.dipon-msg-bubble {
  padding: 12px 16px;
  border-radius: var(--dipon-radius-msg);
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.dipon-message-bot .dipon-msg-bubble {
  background: var(--dipon-bg);
  color: var(--dipon-text);
  border: 1px solid var(--dipon-border);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.dipon-message-user .dipon-msg-bubble {
  background: linear-gradient(135deg, var(--dipon-primary) 0%, var(--dipon-primary-dark) 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

/* Typing indicator */
.dipon-typing-indicator {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.dipon-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
  background: var(--dipon-bg);
  border: 1px solid var(--dipon-border);
  border-radius: var(--dipon-radius-msg);
  border-top-left-radius: 4px;
}

.dipon-typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--dipon-primary);
  border-radius: 50%;
  animation: dipon-typing 1.2s infinite;
  opacity: 0.4;
}

.dipon-typing-dots span:nth-child(1) { animation-delay: 0s; }
.dipon-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.dipon-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dipon-typing {
  0%, 100% { opacity: 0.4; transform: translateY(0); }
  50%       { opacity: 1;   transform: translateY(-4px); }
}

/* Error message */
.dipon-msg-error {
  background: #fef2f2 !important;
  color: #dc2626 !important;
  border-color: #fecaca !important;
}

/* ═══════════════════════════════════════════════
   INPUT AREA
═══════════════════════════════════════════════ */
.dipon-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px;
  background: var(--dipon-bg);
  border-top: 1px solid var(--dipon-border);
  flex-shrink: 0;
}

.dipon-chat-input {
  flex: 1;
  border: 1.5px solid var(--dipon-border);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--dipon-font);
  color: var(--dipon-text);
  background: var(--dipon-bg-secondary);
  outline: none;
  resize: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.2s ease;
}

.dipon-chat-input:focus {
  border-color: var(--dipon-primary);
  background: var(--dipon-bg);
}

.dipon-chat-input::placeholder {
  color: var(--dipon-text-muted);
}

.dipon-send-btn {
  width: 42px;
  height: 42px;
  border: none;
  background: linear-gradient(135deg, var(--dipon-primary) 0%, var(--dipon-primary-dark) 100%);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--dipon-transition);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.35);
}

.dipon-send-btn svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

.dipon-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.5);
}

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

.dipon-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ═══════════════════════════════════════════════
   POWERED BY
═══════════════════════════════════════════════ */
.dipon-powered-by {
  text-align: center;
  font-size: 11px;
  color: var(--dipon-text-muted);
  padding: 6px 0 8px;
  background: var(--dipon-bg);
  border-top: 1px solid var(--dipon-border);
}

.dipon-powered-by strong {
  color: var(--dipon-primary);
}

/* ═══════════════════════════════════════════════
   FLOATING ACTION BUTTON (FAB)
═══════════════════════════════════════════════ */
.dipon-fab {
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--dipon-primary) 0%, var(--dipon-primary-dark) 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--dipon-shadow-fab);
  transition: var(--dipon-transition);
  position: relative;
  z-index: 1;
}

.dipon-fab:hover {
  transform: scale(1.08) rotate(5deg);
  box-shadow: 0 12px 35px rgba(108, 99, 255, 0.55);
}

.dipon-fab:active {
  transform: scale(0.95);
}

.dipon-fab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  transition: var(--dipon-transition);
}

.dipon-fab-icon svg {
  width: 26px;
  height: 26px;
}

/* Notification badge */
.dipon-notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 20px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: dipon-badge-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 2;
}

@keyframes dipon-badge-pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* ═══════════════════════════════════════════════
   EMBEDDED CHAT (Shortcode)
═══════════════════════════════════════════════ */
.dipon-chat-embedded {
  display: flex;
  flex-direction: column;
  border: 1.5px solid var(--dipon-border);
  border-radius: var(--dipon-radius);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  font-family: var(--dipon-font);
  background: var(--dipon-bg-secondary);
  -webkit-font-smoothing: antialiased;
}

.dipon-embedded-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--dipon-primary) 0%, var(--dipon-primary-dark) 100%);
  flex-shrink: 0;
}

.dipon-embedded-header .dipon-bot-name {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}

/* ═══════════════════════════════════════════════
   DARK MODE
═══════════════════════════════════════════════ */
.dipon-dark {
  --dipon-bg: #1e1e2e;
  --dipon-bg-secondary: #181825;
  --dipon-text: #cdd6f4;
  --dipon-text-muted: #6c7086;
  --dipon-border: #313244;
}

.dipon-dark .dipon-message-bot .dipon-msg-bubble {
  background: #2a2a3e;
  color: #cdd6f4;
  border-color: #313244;
}

.dipon-dark .dipon-chat-input {
  color: #cdd6f4;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 480px) {
  #dipon-chat-widget {
    bottom: 16px;
    right: 16px;
  }

  .dipon-chat-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    right: -8px;
    bottom: 72px;
    border-radius: 16px;
  }
}

/* ═══════════════════════════════════════════════
   UTILITY
═══════════════════════════════════════════════ */
.dipon-chat-input::-webkit-scrollbar {
  width: 3px;
}

.dipon-chat-input::-webkit-scrollbar-thumb {
  background: var(--dipon-border);
  border-radius: 10px;
}

/* ═══════════════════════════════════════════════
   TOAST NOTIFICATION
═══════════════════════════════════════════════ */
.dipon-toast {
  position: fixed;
  bottom: 100px;
  right: 24px;
  background: #1f2937;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-family: var(--dipon-font);
  z-index: 9999999;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.dipon-toast.dipon-toast-show {
  opacity: 1;
  transform: translateY(0);
}
