/* ============================================================
   JukungSync — Chat Widget Styles (PT Utama Madani Raya Theme)
   ============================================================ */

:root {
  --jks-primary: #1a1a1a;
  --jks-primary-light: #2d2d2d;
  --jks-maroon: #7f1d1d;
  --jks-gold: #fbbf24;
  --jks-white: #ffffff;
  --jks-gray-50: #f9fafb;
  --jks-gray-200: #e5e7eb;
  --jks-gray-400: #9ca3af;
  --jks-gray-700: #374151;
  --jks-gray-800: #1f2937;
  --jks-z-widget: 99990;
  --jks-z-window: 99999;
}

/* Global SVG Safety Containment */
.jks-chat-trigger svg,
.jks-welcome__icon svg,
.jks-chat-header__avatar svg,
.jks-msg-avatar svg,
.jks-suggestion-card__icon svg {
  max-width: 100% !important;
  max-height: 100% !important;
  box-sizing: border-box !important;
}

.jks-welcome__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #1a1a1a;
  padding: 10px;
}
.jks-welcome__icon svg {
  width: 28px;
  height: 28px;
  fill: var(--jks-gold);
}

/* FAB Trigger Button */
.jks-chat-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--jks-z-widget);
  width: 60px;
  height: 60px;
  border-radius: 9999px;
  border: 2px solid var(--jks-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a1a 0%, #7f1d1d 100%);
  box-shadow: 0 8px 24px rgba(127, 29, 29, 0.45);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s ease;
}
.jks-chat-trigger:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 32px rgba(127, 29, 29, 0.6);
}
.jks-chat-trigger:active {
  transform: scale(0.95);
}
.jks-chat-trigger svg {
  width: 28px;
  height: 28px;
  fill: var(--jks-gold);
}
.jks-chat-trigger.is-open svg.icon-chat { display: none; }
.jks-chat-trigger.is-open svg.icon-close { display: block; }
.jks-chat-trigger:not(.is-open) svg.icon-close { display: none; }

/* Pulse Ring */
.jks-chat-trigger .ripple-ring {
  position: absolute;
  inset: -6px;
  border-radius: 9999px;
  border: 2px solid rgba(251, 191, 36, 0.5);
  animation: jksPulse 2s ease-in-out infinite;
}
@keyframes jksPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(0.95); opacity: 0; }
}

/* Chat Window */
.jks-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: var(--jks-z-window);
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 130px);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--jks-white);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--jks-gray-200);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.jks-chat-window.is-hidden {
  opacity: 0;
  transform: scale(0.85) translateY(20px);
  pointer-events: none;
}
.jks-chat-window.is-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* Header */
.jks-chat-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  color: var(--jks-white);
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 2px solid var(--jks-gold);
}
.jks-chat-header__avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.jks-chat-header__avatar svg { width: 22px; height: 22px; fill: var(--jks-gold); }
.jks-chat-header__avatar .status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #1a1a1a;
}
.jks-chat-header__info { flex: 1; }
.jks-chat-header__title { font-weight: 800; font-size: 15px; color: var(--jks-gold); }
.jks-chat-header__subtitle { font-size: 11px; opacity: 0.8; }

.jks-chat-header__actions { display: flex; gap: 4px; }
.jks-chat-header__action-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.jks-chat-header__action-btn:hover { background: rgba(255,255,255,0.2); }
.jks-chat-header__action-btn svg { width: 16px; height: 16px; fill: currentColor; }

/* Messages */
.jks-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--jks-gray-50);
}

.jks-msg-row { display: flex; gap: 8px; max-width: 88%; }
.jks-msg-row--bot { align-self: flex-start; }
.jks-msg-row--user { align-self: flex-end; flex-direction: row-reverse; }

.jks-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.jks-msg-avatar svg { width: 15px; height: 15px; fill: var(--jks-gold); }
.jks-msg-row--user .jks-msg-avatar { background: #7f1d1d; }
.jks-msg-row--user .jks-msg-avatar svg { fill: #fff; }

.jks-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}
.jks-msg-row--bot .jks-msg-bubble {
  background: #fff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}
.jks-msg-row--user .jks-msg-bubble {
  background: linear-gradient(135deg, #7f1d1d 0%, #450a0a 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.jks-msg-time { font-size: 10px; color: #9ca3af; margin-top: 3px; display: block; }
.jks-msg-row--user .jks-msg-time { text-align: right; }

/* Typing Indicator */
.jks-typing { display: flex; gap: 8px; align-self: flex-start; }
.jks-typing__bubble {
  padding: 10px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  display: flex;
  gap: 4px;
}
.jks-typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: jksDot 1.4s ease-in-out infinite;
}
.jks-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.jks-typing__dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes jksDot {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Quick Replies */
.jks-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 8px;
}
.jks-quick-reply {
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid #7f1d1d;
  background: transparent;
  color: #7f1d1d;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.jks-quick-reply:hover {
  background: #7f1d1d;
  color: #fff;
}

/* Input Area */
.jks-chat-input {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
}
.jks-chat-input__wrapper {
  flex: 1;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 6px 12px;
}
.jks-chat-input__textarea {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  resize: none;
  color: #1f2937;
}
.jks-chat-input__send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #fbbf24;
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.jks-chat-input__send svg { width: 16px; height: 16px; fill: #000; }

/* Welcome Screen */
.jks-welcome {
  text-align: center;
  padding: 20px 10px;
}
.jks-welcome__icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1a1a1a 0%, #7f1d1d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}
.jks-welcome__icon svg { width: 30px; height: 30px; fill: #fbbf24; }
.jks-welcome__title { font-size: 16px; font-weight: 800; color: #111827; }
.jks-welcome__desc { font-size: 12px; color: #6b7280; margin: 6px 0 16px; }

.jks-suggestion-card {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  transition: all 0.2s ease;
}
.jks-suggestion-card:hover {
  border-color: #7f1d1d;
  background: #fdf2f2;
}
.jks-suggestion-card__icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #fee2e2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.jks-suggestion-card__icon svg { width: 14px; height: 14px; fill: #7f1d1d; }

.jks-powered {
  padding: 6px;
  text-align: center;
  font-size: 10px;
  color: #9ca3af;
  border-top: 1px solid #f3f4f6;
}

@media (max-width: 480px) {
  .jks-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
}
