/**
 * CMK ELECTRO POWER PRIVATE LIMITED
 * Modern Industrial Conversational Chatbot Styles
 * (An ISO 9001:2015 Certified Company)
 */

/* ==========================================================================
   1. FLOATING STACK & TRIGGER BUTTON OVERRIDES
   ========================================================================== */
.floating-widgets-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 990;
  align-items: flex-end;
}

/* Chatbot Floating Trigger (Placed Below WhatsApp) */
.btn-chatbot {
  background: linear-gradient(135deg, #0066b2 0%, #004c85 100%);
  color: #ffffff;
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 24px rgba(0, 102, 178, 0.35), 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-chatbot:hover {
  transform: scale(1.12) translateY(-2px);
  box-shadow: 0 14px 30px rgba(0, 102, 178, 0.45), 0 4px 10px rgba(0, 0, 0, 0.18);
  border-color: rgba(255, 255, 255, 0.6);
}

.btn-chatbot.is-active {
  background: #0f172a;
  transform: rotate(90deg) scale(0.95);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.4);
}

/* Online Ping Dot on Floating Trigger */
.btn-chatbot .trigger-pulse-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background-color: #22c55e;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

.btn-chatbot .trigger-pulse-ring {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #22c55e;
  opacity: 0.75;
  animation: cmkPing 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes cmkPing {
  75%, 100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

/* ==========================================================================
   2. PROACTIVE TEASER PILL
   ========================================================================== */
.cmk-chatbot-teaser {
  position: fixed;
  bottom: 96px;
  right: 24px;
  max-width: 320px;
  background: #ffffff;
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 102, 178, 0.15);
  z-index: 980;
  animation: cmkSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  cursor: pointer;
}

.cmk-chatbot-teaser .teaser-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0066b2, #0284c7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.cmk-chatbot-teaser .teaser-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.cmk-chatbot-teaser .teaser-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #0066b2;
}

.cmk-chatbot-teaser .teaser-text {
  font-size: 12.5px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.35;
  margin-top: 1px;
}

.cmk-chatbot-teaser .teaser-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.cmk-chatbot-teaser .teaser-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* ==========================================================================
   3. CHATBOT WINDOW DIALOG / PANEL
   ========================================================================== */
.cmk-chatbot-window {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 395px;
  max-width: calc(100vw - 32px);
  height: 610px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 50px -10px rgba(11, 37, 69, 0.3), 0 0 0 1px rgba(0, 102, 178, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999;
  transform-origin: bottom right;
  animation: cmkScaleIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cmkScaleIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes cmkSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   4. CHATBOT HEADER
   ========================================================================== */
.chatbot-header {
  background: linear-gradient(135deg, #0a2540 0%, #0066b2 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  position: relative;
  z-index: 10;
}

.chatbot-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar-wrap {
  position: relative;
}

.chatbot-avatar-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chatbot-online-pulse {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  background: #22c55e;
  border: 2px solid #0a2540;
  border-radius: 50%;
}

.chatbot-header-info {
  display: flex;
  flex-direction: column;
}

.chatbot-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: #ffffff;
}

.chatbot-iso-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #e0f2fe;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.chatbot-subtitle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: #bfdbfe;
  margin-top: 1px;
}

.chatbot-subtitle .status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
}

.chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-header-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.26);
  transform: translateY(-1px);
}

.chat-header-btn.chat-close-btn:hover {
  background: rgba(239, 68, 68, 0.8);
  border-color: rgba(239, 68, 68, 0.9);
}

/* ==========================================================================
   5. QUICK CHANNEL BANNER
   ========================================================================== */
.chatbot-quick-channels {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.chatbot-quick-channels::-webkit-scrollbar {
  display: none;
}

.channel-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.channel-pill.channel-wa {
  background: #e7f9ee;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.channel-pill.channel-wa:hover {
  background: #25d366;
  color: #ffffff;
  border-color: #25d366;
}

.channel-pill.channel-phone {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.channel-pill.channel-phone:hover {
  background: #0066b2;
  color: #ffffff;
  border-color: #0066b2;
}

.channel-pill.channel-dispatch {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

/* ==========================================================================
   6. MESSAGES CONTAINER
   ========================================================================== */
.chatbot-messages {
  flex: 1;
  padding: 16px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
  width: 5px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Message Rows */
.cmk-chat-row {
  display: flex;
  gap: 9px;
  max-width: 88%;
  animation: cmkMessageFade 0.22s ease-out;
}

@keyframes cmkMessageFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cmk-chat-row.bot {
  align-self: flex-start;
}

.cmk-chat-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* Avatars */
.cmk-bot-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #0066b2;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
}

/* Bubbles */
.cmk-chat-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.cmk-chat-row.bot .cmk-chat-bubble {
  background: #ffffff;
  color: #1e293b;
  border-top-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
}

.cmk-chat-row.user .cmk-chat-bubble {
  background: linear-gradient(135deg, #0066b2 0%, #0284c7 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 102, 178, 0.25);
}

.cmk-chat-bubble p {
  margin: 0 0 8px 0;
}

.cmk-chat-bubble p:last-child {
  margin-bottom: 0;
}

.cmk-chat-bubble strong {
  color: #0f172a;
  font-weight: 700;
}

.cmk-chat-row.user .cmk-chat-bubble strong {
  color: #ffffff;
}

.cmk-chat-bubble ul {
  margin: 6px 0;
  padding-left: 18px;
}

.cmk-chat-bubble li {
  margin-bottom: 4px;
}

.cmk-chat-bubble a {
  color: #0066b2;
  font-weight: 600;
  text-decoration: underline;
}

.cmk-chat-row.user .cmk-chat-bubble a {
  color: #bae6fd;
}

.cmk-msg-time {
  display: block;
  font-size: 10px;
  color: #94a3b8;
  margin-top: 5px;
  text-align: right;
}

.cmk-chat-row.user .cmk-msg-time {
  color: rgba(255, 255, 255, 0.75);
}

/* ==========================================================================
   7. INTERACTIVE PRODUCT CARDS CAROUSEL
   ========================================================================== */
.chatbot-products-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.chatbot-product-card {
  display: flex;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
  align-items: center;
}

.chatbot-product-card:hover {
  border-color: #0066b2;
  box-shadow: 0 4px 12px rgba(0, 102, 178, 0.12);
  transform: translateY(-1px);
}

.chatbot-product-img {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  background: #f1f5f9;
  flex-shrink: 0;
  border: 1px solid #e2e8f0;
}

.chatbot-product-info {
  flex: 1;
  min-width: 0;
}

.chatbot-product-cat {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #0066b2;
  letter-spacing: 0.3px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatbot-product-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
  margin: 2px 0 3px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chatbot-product-sku {
  font-size: 11px;
  color: #64748b;
  display: block;
}

.chatbot-product-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.chatbot-product-price {
  font-size: 13px;
  font-weight: 800;
  color: #0066b2;
}

.chatbot-product-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  background: #0066b2;
  color: #ffffff;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.chatbot-product-btn:hover {
  background: #004c85;
}

/* ==========================================================================
   8. ORDER TRACKING CARD
   ========================================================================== */
.chatbot-order-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 14px;
  margin-top: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  width: 100%;
}

.chatbot-order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.chatbot-order-ref {
  font-size: 13.5px;
  font-weight: 800;
  color: #0f172a;
}

.chatbot-order-badge {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}

.badge-in_transit, .badge-dispatched {
  background: #dbeafe;
  color: #1e40af;
}

.badge-delivered {
  background: #dcfce7;
  color: #166534;
}

.badge-order_confirmed, .badge-processing {
  background: #fef3c7;
  color: #92400e;
}

.chatbot-order-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 11.5px;
  margin-bottom: 10px;
}

.chatbot-order-grid .label {
  color: #64748b;
  display: block;
}

.chatbot-order-grid .val {
  font-weight: 700;
  color: #1e293b;
}

.chatbot-order-action {
  display: block;
  text-align: center;
  padding: 8px 12px;
  border-radius: 8px;
  background: #0066b2;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.15s ease;
}

.chatbot-order-action:hover {
  background: #004c85;
}

/* ==========================================================================
   9. INTERACTIVE LEAD / QUOTATION FORM IN CHAT
   ========================================================================== */
.chatbot-lead-form {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 12px;
  margin-top: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.chatbot-lead-form .lead-form-title {
  font-size: 12.5px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-lead-field {
  margin-bottom: 8px;
}

.chatbot-lead-field input,
.chatbot-lead-field textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 12.5px;
  font-family: inherit;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s ease;
}

.chatbot-lead-field input:focus,
.chatbot-lead-field textarea:focus {
  border-color: #0066b2;
  box-shadow: 0 0 0 3px rgba(0, 102, 178, 0.12);
}

.chatbot-lead-field textarea {
  resize: none;
  height: 52px;
}

.chatbot-lead-submit-btn {
  width: 100%;
  padding: 9px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e05a1e 0%, #c2410c 100%);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(224, 90, 30, 0.3);
  transition: all 0.18s ease;
}

.chatbot-lead-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(224, 90, 30, 0.4);
}

/* ==========================================================================
   10. TYPING INDICATOR
   ========================================================================== */
.chatbot-typing {
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
}

.typing-bubble {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0066b2;
  animation: cmkTypingDot 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes cmkTypingDot {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

.typing-label {
  font-size: 11px;
  color: #64748b;
  font-style: italic;
}

/* ==========================================================================
   11. QUICK SUGGESTION CHIPS
   ========================================================================== */
.chatbot-quick-replies {
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  scrollbar-width: none;
}

.chatbot-quick-replies::-webkit-scrollbar {
  display: none;
}

.quick-reply-chip {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #0066b2;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.quick-reply-chip:hover {
  background: #0066b2;
  color: #ffffff;
  border-color: #0066b2;
  transform: translateY(-1px);
}

/* ==========================================================================
   12. INPUT BAR & FOOTER
   ========================================================================== */
.chatbot-input-bar {
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  padding: 10px 14px 10px 14px;
}

.input-container {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 4px 6px 4px 12px;
  transition: all 0.15s ease;
}

.input-container:focus-within {
  background: #ffffff;
  border-color: #0066b2;
  box-shadow: 0 0 0 3px rgba(0, 102, 178, 0.12);
}

.input-container textarea {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  padding: 5px 0;
}

.input-container textarea::placeholder {
  color: #94a3b8;
}

.chat-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #0066b2;
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s ease;
}

.chat-send-btn:hover {
  background: #004c85;
  transform: scale(1.05);
}

.chatbot-input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: #94a3b8;
}

.chatbot-input-footer .footer-note {
  font-weight: 500;
}

.chatbot-input-footer .footer-link {
  color: #0066b2;
  text-decoration: none;
  font-weight: 600;
}

.chatbot-input-footer .footer-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   13. MOBILE RESPONSIVENESS
   ========================================================================== */
@media (max-width: 640px) {
  .floating-widgets-stack {
    bottom: 18px;
    right: 18px;
    gap: 10px;
  }

  .floating-widget-btn {
    width: 46px;
    height: 46px;
  }

  .cmk-chatbot-teaser {
    bottom: 80px;
    right: 16px;
    left: 16px;
    max-width: none;
  }

  .cmk-chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    top: auto;
    width: 100vw;
    max-width: 100vw;
    height: 86vh;
    max-height: 86vh;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 35px rgba(0, 0, 0, 0.25);
  }
}
