/* Apostille Funnel Widget - extracted from apostille-funnel.js to eliminate CLS
   (styles must be available BEFORE widget DOM is injected) */

#esg-funnel-widget {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99998;
}

/* Floating Button - reserved corner slot (60x60 + 20px margin) so the button's
   late insertion doesn't shift content. Always present even before widget JS runs. */
.esg-funnel-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a3a5c 0%, #2d5a87 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(26, 58, 92, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}
.esg-funnel-btn:hover { transform: scale(1.08); }
.esg-funnel-btn svg { width: 28px; height: 28px; fill: white; }
.esg-funnel-btn.open svg.chat-icon { display: none; }
.esg-funnel-btn svg.close-icon { display: none; }
.esg-funnel-btn.open svg.close-icon { display: block; }

/* Chat Container */
.esg-funnel-container {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 140px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.esg-funnel-container.open {
  display: flex;
  animation: funnelSlideIn 0.3s ease;
}
@keyframes funnelSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.esg-funnel-header {
  background: linear-gradient(135deg, #1a3a5c 0%, #2d5a87 100%);
  color: white;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.esg-funnel-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.esg-funnel-avatar svg { width: 24px; height: 24px; fill: white; }
.esg-funnel-title { flex: 1; }
.esg-funnel-title h3 { margin: 0; font-size: 15px; font-weight: 600; }
.esg-funnel-title span { font-size: 12px; opacity: 0.9; }
.esg-funnel-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.esg-funnel-close:hover { background: rgba(255,255,255,0.3); }
.esg-funnel-close svg { width: 18px; height: 18px; fill: white; }

/* Messages */
.esg-funnel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fa;
  min-height: 200px;
  max-height: 400px;
}
.esg-funnel-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  animation: msgFade 0.3s ease;
}
@keyframes msgFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.esg-funnel-message.bot {
  background: white;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.esg-funnel-message.user {
  background: #1a3a5c;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.esg-funnel-message.bot .msg-content { white-space: pre-wrap; }

/* Typing indicator */
.esg-funnel-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  align-self: flex-start;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.esg-funnel-typing span {
  width: 8px;
  height: 8px;
  background: #ccc;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}
.esg-funnel-typing span:nth-child(2) { animation-delay: 0.2s; }
.esg-funnel-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Options */
.esg-funnel-options {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: white;
  border-top: 1px solid #eee;
}
.esg-funnel-option {
  padding: 12px 16px;
  background: #f5f5f5;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-family: inherit;
}
.esg-funnel-option:hover {
  background: #1a3a5c;
  color: white;
  border-color: #1a3a5c;
}

/* Form */
.esg-funnel-form {
  padding: 16px;
  background: white;
  border-top: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.esg-funnel-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.esg-funnel-field label {
  font-size: 12px;
  font-weight: 500;
  color: #666;
}
.esg-funnel-field input,
.esg-funnel-field textarea {
  padding: 10px 14px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}
.esg-funnel-field input:focus,
.esg-funnel-field textarea:focus {
  outline: none;
  border-color: #1a3a5c;
}
.esg-funnel-field textarea {
  resize: none;
  min-height: 60px;
}
.esg-funnel-submit {
  padding: 12px;
  background: #1a3a5c;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
.esg-funnel-submit:hover { background: #2d5a87; }
.esg-funnel-submit:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Inline triggers - injected after H1/.section-header/.hero-buttons.
   Since the widget JS now waits for first interaction, any layout shift here
   is excluded from CLS (within 500ms of user input). */
.esg-assistant-inline {
  background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  padding: 20px;
  margin: 24px 0;
  display: flex;
  align-items: center;
  gap: 16px;
}
.esg-assistant-inline-icon {
  width: 48px;
  height: 48px;
  background: #1a3a5c;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.esg-assistant-inline-icon svg { width: 24px; height: 24px; fill: white; }
.esg-assistant-inline-content { flex: 1; }
.esg-assistant-inline-content p {
  margin: 0 0 4px 0;
  font-weight: 600;
  color: #333;
}
.esg-assistant-inline-content span {
  font-size: 14px;
  color: #666;
}
.esg-assistant-inline-btn {
  padding: 10px 20px;
  background: #1a3a5c;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.esg-assistant-inline-btn:hover { background: #2d5a87; }

/* Mobile styles */
@media (max-width: 480px) {
  .esg-funnel-container {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .esg-funnel-messages {
    max-height: calc(100vh - 260px);
  }
  .esg-assistant-inline {
    flex-direction: column;
    text-align: center;
  }
}
