/* ==========================================================================
   YPJ Chatbot Widget Styles
   ========================================================================== */

/* ── Floating Button ─────────────────────────────────────────────────────── */

#ypj-chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9990;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d2b6e 0%, #1a56db 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(13, 43, 110, 0.45);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  outline: none;
}

#ypj-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(13, 43, 110, 0.55);
}

#ypj-chat-toggle:focus-visible {
  outline: 3px solid #c8992a;
  outline-offset: 3px;
}

#ypj-chat-toggle .chat-icon,
#ypj-chat-toggle .close-icon {
  position: absolute;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#ypj-chat-toggle .sarahj-toggle-img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
}

#ypj-chat-toggle .close-icon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
}

#ypj-chat-toggle.open .chat-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}

#ypj-chat-toggle.open .close-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Notif badge */
#ypj-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #c0392b;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  font-family: 'Inter', sans-serif;
}

#ypj-chat-badge.visible {
  display: flex;
}

/* ── Chat Window ─────────────────────────────────────────────────────────── */

#ypj-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9991;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(13, 43, 110, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.88) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.2s ease;
}

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

/* Header */
.ypj-chat-header {
  background: linear-gradient(135deg, #0d2b6e 0%, #1a3a8f 100%);
  padding: 16px 18px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.ypj-chat-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.ypj-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  border-radius: 50%;
}

.ypj-chat-header-info {
  flex: 1;
  min-width: 0;
}

.ypj-chat-header-name {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}

.ypj-chat-header-status {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.ypj-chat-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.ypj-chat-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.ypj-chat-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.12);
}

/* Messages area */
.ypj-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f7f9ff;
  scroll-behavior: smooth;
}

.ypj-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.ypj-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.ypj-chat-messages::-webkit-scrollbar-thumb {
  background: #d0d8f0;
  border-radius: 3px;
}

/* Bubble */
.ypj-bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  animation: bubblePop 0.2s ease;
}

@keyframes bubblePop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.ypj-bubble.bot {
  background: #fff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(13, 43, 110, 0.08);
}

.ypj-bubble.user {
  background: linear-gradient(135deg, #0d2b6e 0%, #1a56db 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* Typing indicator */
.ypj-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(13, 43, 110, 0.08);
}

.ypj-typing span {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typingDot 1.2s infinite ease-in-out;
}

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

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Quick replies */
.ypj-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 0 4px;
}

.ypj-quick-btn {
  background: #fff;
  border: 1.5px solid #d0d8f0;
  color: #0d2b6e;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.3;
}

.ypj-quick-btn:hover {
  background: #0d2b6e;
  border-color: #0d2b6e;
  color: #fff;
}

/* Input area */
.ypj-chat-input-area {
  padding: 12px 14px 14px;
  background: #fff;
  border-top: 1px solid #e4e9f5;
  flex-shrink: 0;
}

.ypj-chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#ypj-chat-input {
  flex: 1;
  border: 1.5px solid #d0d8f0;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: #1e293b;
  background: #f7f9ff;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.15s;
  overflow-y: auto;
}

#ypj-chat-input:focus {
  border-color: #1a56db;
  background: #fff;
}

#ypj-chat-input::placeholder {
  color: #94a3b8;
}

#ypj-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0d2b6e 0%, #1a56db 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
  color: #fff;
}

#ypj-chat-send:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.05);
}

#ypj-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ypj-chat-footer-note {
  font-family: 'Inter', sans-serif;
  font-size: 10.5px;
  color: #94a3b8;
  text-align: center;
  margin-top: 8px;
}

/* Mobile */
@media (max-width: 480px) {
  #ypj-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100svh;
    max-height: 100svh;
    border-radius: 0;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
  }

  #ypj-chat-toggle {
    bottom: 20px;
    right: 20px;
  }
}
