/* ============================================
   PGB Virtual Consultant Chatbot Styles
   Primary Color: #3db83a
   ============================================ */

#pgb-chat-widget * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Toggle Button --- */
#pgb-chat-widget .pgb-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: #3db83a;
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(61, 184, 58, 0.35);
  z-index: 999999;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  gap: 4px;
}

#pgb-chat-widget .pgb-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(61, 184, 58, 0.5);
}

#pgb-chat-widget .pgb-chat-toggle-text {
  display: none;
  font-size: 14px;
  font-weight: 600;
}

/* --- Chat Panel (hidden by default) --- */
#pgb-chat-widget .pgb-chat-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  max-height: 600px;
  height: calc(100vh - 140px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  z-index: 999998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  animation: pgb-slide-up 0.3s ease;
}

#pgb-chat-widget .pgb-chat-panel.pgb-open {
  display: flex;
}

@keyframes pgb-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Header --- */
#pgb-chat-widget .pgb-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: #3db83a;
  color: #fff;
  flex-shrink: 0;
}

#pgb-chat-widget .pgb-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#pgb-chat-widget .pgb-chat-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pgb-chat-widget .pgb-chat-avatar svg {
  width: 20px;
  height: 20px;
}

#pgb-chat-widget .pgb-chat-status {
  font-size: 11px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

#pgb-chat-widget .pgb-status-dot {
  width: 7px;
  height: 7px;
  background: #8bc34a;
  border-radius: 50%;
  display: inline-block;
  animation: pgb-pulse 1.5s infinite;
}

@keyframes pgb-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#pgb-chat-widget .pgb-chat-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 0.8;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: opacity 0.2s, background 0.2s;
}

#pgb-chat-widget .pgb-chat-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

#pgb-chat-widget .pgb-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#pgb-chat-widget .pgb-chat-end {
  margin-top: -5px !important;
  padding: 0 !important;
  border: none;
  color: #fff;
  cursor: pointer;
  background:none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: opacity 0.2s, background 0.2s;
}

#pgb-chat-widget .pgb-chat-end:hover {
  background: #0000001f;
}

/* --- Pre-chat Form --- */
#pgb-chat-widget .pgb-prechat-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  background: #fff;
}

#pgb-chat-widget .pgb-prechat-title {
  font-size: 18px;
  font-weight: 700;
  color: #1b5e20;
  margin-bottom: 8px;
}

#pgb-chat-widget .pgb-prechat-desc {
  font-size: 14px;
  color: #555;
  margin-bottom: 20px;
}

#pgb-chat-widget .pgb-prechat-field {
  margin-bottom: 16px;
}

#pgb-chat-widget .pgb-prechat-field input[type="text"],
#pgb-chat-widget .pgb-prechat-field input[type="email"],
#pgb-chat-widget .pgb-prechat-field input[type="tel"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

#pgb-chat-widget .pgb-prechat-field input:focus {
  border-color: #3db83a;
  outline: none;
}

#pgb-chat-widget .pgb-prechat-terms {
  font-size: 13px;
  color: #666;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

#pgb-chat-widget .pgb-prechat-terms input[type="checkbox"] {
  margin-top: 3px;
}

#pgb-chat-widget .pgb-prechat-terms a {
  color: #3db83a;
  text-decoration: none;
}

#pgb-chat-widget .pgb-chat-start-btn {
  width: 100%;
  background: #3db83a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.2s;
}

#pgb-chat-widget .pgb-chat-start-btn:hover {
  background: #2e9e2c;
}

/* --- Messages Area --- */
#pgb-chat-widget .pgb-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f9fa;
}

#pgb-chat-widget .pgb-chat-messages::-webkit-scrollbar {
  width: 4px;
}

#pgb-chat-widget .pgb-chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

/* --- Individual Messages --- */
#pgb-chat-widget .pgb-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  animation: pgb-fade-in 0.3s ease;
}

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

#pgb-chat-widget .pgb-message-assistant {
  align-self: flex-start;
  background: #e8f5e9;
  color: #1b5e20;
  border-bottom-left-radius: 4px;
}

#pgb-chat-widget .pgb-message-user {
  align-self: flex-end;
  background: #3db83a;
  color: #fff;
  border-bottom-right-radius: 4px;
}

#pgb-chat-widget .pgb-message-content {
  font-size: 14px;
  line-height: 1.5;
}

/* --- Product Tile --- */
#pgb-chat-widget .pgb-product-tile {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 14px;
  max-width: 85%;
  animation: pgb-slide-in 0.4s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

@keyframes pgb-slide-in {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

#pgb-chat-widget .pgb-product-tile-image {
  width: 100%;
  height: auto;
  max-height: 160px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 10px;
}

#pgb-chat-widget .pgb-product-tile-name {
  font-size: 16px;
  font-weight: 700;
  color: #1b5e20;
  margin-bottom: 4px;
}

#pgb-chat-widget .pgb-product-tile-price {
  font-size: 15px;
  font-weight: 600;
  color: #3db83a;
  margin-bottom: 6px;
}

#pgb-chat-widget .pgb-product-tile-link {
  display: inline-block;
  background: #3db83a;
  color: #fff;
  padding: 7px 18px;
  border-radius: 20px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s;
}

#pgb-chat-widget .pgb-product-tile-link:hover {
  background: #2e9e2c;
  color: #fff;
}

/* --- Typing Indicator --- */
#pgb-chat-widget .pgb-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  margin: 0 16px;
  background: #e8f5e9;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

#pgb-chat-widget .pgb-typing-dot {
  width: 8px;
  height: 8px;
  background: #3db83a;
  border-radius: 50%;
  display: inline-block;
  animation: pgb-bounce 1.2s infinite;
}

#pgb-chat-widget .pgb-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

#pgb-chat-widget .pgb-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

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

#pgb-chat-widget .pgb-typing-label {
  font-size: 11px;
  color: #666;
  margin-left: 6px;
}

/* --- Input Area --- */
#pgb-chat-widget .pgb-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e8e8e8;
  background: #fff;
  flex-shrink: 0;
}

#pgb-chat-widget .pgb-chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  background: #f5f5f5;
  transition: border-color 0.2s, background 0.2s;
}

#pgb-chat-widget .pgb-chat-input:focus {
  border-color: #3db83a;
  background: #fff;
}

#pgb-chat-widget .pgb-chat-input::placeholder {
  color: #999;
}

#pgb-chat-widget .pgb-chat-send {
  width: 40px;
  height: 40px;
  background: #3db83a;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

#pgb-chat-widget .pgb-chat-send:hover {
  background: #2e9e2c;
}

#pgb-chat-widget .pgb-chat-send:active {
  transform: scale(0.92);
}

#pgb-chat-widget .pgb-chat-send:disabled {
  background: #b8e6b6;
  cursor: not-allowed;
}

/* --- Error States --- */
#pgb-chat-widget .pgb-message-error {
  align-self: center;
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffe0b2;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  text-align: center;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  #pgb-chat-widget .pgb-chat-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  #pgb-chat-widget .pgb-chat-toggle {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }
}

/* --- Markdown Formatting --- */
#pgb-chat-widget .pgb-chat-paragraph {
  margin-bottom: 12px;
  margin-top: 0;
  line-height: 1.5;
}

#pgb-chat-widget .pgb-chat-paragraph:last-child {
  margin-bottom: 0;
}

#pgb-chat-widget .pgb-chat-list-item {
  margin-bottom: 12px;
  margin-top: 4px;
  padding-left: 14px;
  text-indent: -14px;
}

#pgb-chat-widget .pgb-chat-list-item:last-child {
  margin-bottom: 0;
}

/* --- Restart Conversation Button --- */
#pgb-chat-widget .pgb-chat-restart-btn {
  width: 100%;
  padding: 12px 20px;
  background: #3db83a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  text-align: center;
}

#pgb-chat-widget .pgb-chat-restart-btn:hover {
  background: #34a832;
  transform: translateY(-1px);
}

#pgb-chat-widget .pgb-chat-restart-btn:active {
  transform: translateY(0);
}