/**
 * Public Stylesheet for WhatsApp Prochat
 * Renders a premium, floating chat widget with smooth animations and glassmorphism.
 */

:root {
  --wpp-green: #25d366;
  --wpp-green-dark: #121b22;
  --wpp-light-gray: #f0f2f5;
  --wpp-border-color: rgba(0, 0, 0, 0.08);
  --wpp-white: #ffffff;
  --wpp-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.12);
  --wpp-radius: 16px;
  --wpp-transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Widget Container */
.wpp-widget {
  position: fixed;
  bottom: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  pointer-events: none; /* Let clicks pass through empty spaces of widget wrapper */
}

/* Positioning */
.wpp-widget.wpp-pos-right {
  right: 24px;
  align-items: flex-end;
}

.wpp-widget.wpp-pos-left {
  left: 24px;
  align-items: flex-start;
}

/* Trigger Button */
.wpp-float-trigger {
  pointer-events: auto; /* Re-enable pointer events */
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  background-color: var(--wpp-green);
  color: var(--wpp-white);
  padding: 8px 8px 8px 16px;
  border-radius: 30px;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.3);
  cursor: pointer;
  transition: var(--wpp-transition);
  outline: none;
  height: 52px;
  margin-top: 15px;
}

.wpp-widget.wpp-pos-left .wpp-float-trigger {
  padding: 8px 16px 8px 8px;
  flex-direction: row-reverse;
}

.wpp-float-trigger:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.45);
}

.wpp-float-trigger:active {
  transform: translateY(-1px) scale(0.98);
}

/* Trigger elements */
.wpp-trigger-text {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.wpp-trigger-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wpp-svg-bubble {
  width: 22px;
  height: 22px;
}

/* Pulse animation for the trigger button */
.wpp-float-trigger {
  animation: wppPulse 2.5s infinite;
}

@keyframes wppPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.6);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(37, 211, 102, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
  }
}

/* Centered Dialog Styles */
.wpp-chat-popup {
  pointer-events: auto; /* Re-enable pointer events */
  width: 440px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 40px);
  border-radius: 24px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
  background: #ffffff;
  margin: 0;
  padding: 0;
  display: none;
  flex-direction: column;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  overflow: hidden;
  outline: none;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
              display 0.3s allow-discrete;
}

/* Dialog Open State */
.wpp-chat-popup[open] {
  display: flex;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

@starting-style {
  .wpp-chat-popup[open] {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
}

/* Dialog Backdrop */
.wpp-chat-popup::backdrop {
  background: rgba(18, 27, 34, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease, display 0.3s allow-discrete;
}

.wpp-chat-popup[open]::backdrop {
  opacity: 1;
}

@starting-style {
  .wpp-chat-popup[open]::backdrop {
    opacity: 0;
  }
}

/* Panels (Form Panel / QR Panel) */
.wpp-panel {
  display: none;
  width: 100%;
  flex-direction: column;
  box-sizing: border-box;
}

.wpp-active-panel {
  display: flex;
  animation: wppPanelFade 0.3s ease-in-out;
}

@keyframes wppPanelFade {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* Header */
.wpp-popup-header {
  padding: 24px 24px 16px 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
  border-bottom: 1px solid var(--wpp-border-color);
  box-sizing: border-box;
}

.wpp-popup-avatar-container {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wpp-popup-avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wpp-popup-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.wpp-svg-avatar {
  width: 24px;
  height: 24px;
}

.wpp-popup-header-meta {
  flex-grow: 1;
  padding-right: 12px;
}

.wpp-popup-pretitle {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  display: block;
}

.wpp-popup-title {
  font-size: 20px;
  font-weight: 700;
  margin: 4px 0 0 0;
  padding: 0;
  line-height: 1.25;
  color: var(--wpp-green-dark);
}

.wpp-popup-desc {
  font-size: 13px;
  color: #667781;
  margin: 6px 0 0 0;
  line-height: 1.45;
}

.wpp-close-btn {
  background: #f0f2f5;
  border: none;
  font-size: 16px;
  color: #54656f;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
  position: absolute;
  top: 20px;
  right: 20px;
}

.wpp-close-btn:hover {
  background-color: #e1e4e7;
}

/* Chat Body (Form controls) */
.wpp-popup-body {
  padding: 20px 24px;
  background: #ffffff;
  overflow-y: auto;
  flex-grow: 1;
  box-sizing: border-box;
}

.wpp-chat-form {
  display: block;
  margin: 0;
}

.wpp-form-group {
  margin-bottom: 16px;
}

.wpp-form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--wpp-green-dark);
  display: block;
  margin-bottom: 6px;
}

.wpp-required {
  color: #ea0038;
  margin-left: 2px;
}

.wpp-optional-lbl {
  font-size: 10px;
  color: #8696a0;
  font-weight: normal;
  margin-left: 4px;
}

.wpp-form-input,
.wpp-form-select,
.wpp-form-textarea {
  width: 100%;
  height: 46px;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  font-size: 14px;
  background: #ffffff;
  transition: all 0.2s ease;
  outline: none;
  color: var(--wpp-green-dark);
  font-family: inherit;
}

.wpp-form-input {
  padding: 0 16px;
}

.wpp-form-select {
  padding: 0 32px 0 16px;
}

.wpp-form-textarea {
  padding: 12px 16px;
  resize: none;
  overflow: hidden;
}

.wpp-form-input:focus,
.wpp-form-select:focus,
.wpp-form-textarea:focus {
  border-color: var(--wpp-green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.12);
}

/* Custom Dropdown arrow */
.wpp-form-select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2354656f' d='M2 4h8L6 9z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  cursor: pointer;
}

/* Message Preview Box inside Form */
.wpp-preview-message-box {
  background-color: rgba(37, 211, 102, 0.04);
  border: 1px solid rgba(37, 211, 102, 0.15);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 20px;
  box-sizing: border-box;
}

.wpp-preview-lbl {
  font-size: 9px;
  font-weight: 700;
  color: #20ba5a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 6px;
}

.wpp-preview-text {
  font-size: 13px;
  color: #54656f;
  margin: 0;
  line-height: 1.45;
  word-break: break-word;
}

/* Footer / Submit Buttons */
.wpp-popup-footer {
  padding: 16px 24px 20px 24px;
  background: #ffffff;
  border-top: 1px solid var(--wpp-border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
}

.wpp-btn-submit,
.wpp-btn-qr {
  width: 100%;
  height: 44px;
  border-radius: 30px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  box-sizing: border-box;
}

.wpp-btn-submit {
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.2);
}

.wpp-btn-submit:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.35);
}

.wpp-btn-qr {
  background: #f8f9fa;
  color: #20ba5a;
  border: 1px solid #20ba5a;
}

.wpp-btn-qr:hover {
  background: rgba(37, 211, 102, 0.05);
  transform: translateY(-1.5px);
}

.wpp-btn-submit:active,
.wpp-btn-qr:active {
  transform: translateY(0);
}

.wpp-svg-send,
.wpp-svg-qr {
  width: 16px;
  height: 16px;
}

/* QR Code Panel Styles */
.wpp-qr-header {
  border-bottom: none;
  padding: 16px 20px 0 20px;
}

.wpp-qr-back-btn {
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: #20ba5a;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0;
  transition: color 0.2s ease;
}

.wpp-qr-back-btn:hover {
  color: #159343;
}

.wpp-qr-close-btn {
  top: 14px;
  right: 20px;
}

.wpp-qr-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.wpp-qr-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--wpp-green-dark);
  margin: 0 0 16px 0;
}

.wpp-qr-image-container {
  width: 200px;
  height: 200px;
  border-radius: 16px;
  border: 1px solid #e1e4e7;
  padding: 12px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.wpp-qr-image-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wpp-qr-desc {
  font-size: 12px;
  color: #667781;
  margin: 18px 0 0 0;
  line-height: 1.5;
  max-width: 240px;
}

/* Scrollbars */
.wpp-popup-body::-webkit-scrollbar {
  width: 4px;
}

.wpp-popup-body::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}

/* Responsive Mobile Layout (Full screen modal) */
@media (max-width: 480px) {
  .wpp-widget {
    bottom: 16px;
  }
  .wpp-widget.wpp-pos-right { right: 16px; }
  .wpp-widget.wpp-pos-left { left: 16px; }

  .wpp-chat-popup {
    width: 100%;
    height: 100%;
    max-height: 100%;
    max-width: 100%;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none !important;
    border: none;
    position: fixed;
  }

  .wpp-chat-popup[open] {
    transform: none !important;
  }

  @starting-style {
    .wpp-chat-popup[open] {
      transform: none !important;
    }
  }

  .wpp-popup-header {
    padding: 20px 20px 16px 20px;
  }

  .wpp-popup-body {
    padding: 16px 20px;
  }

  .wpp-popup-footer {
    padding: 16px 20px 24px 20px;
  }
}
