/* ==========================================================================
   SR Chemical Industries — AI Chatbot ("SR Chemical Assistant")
   Style definitions for floating trigger widget & chatbot conversation window
   ========================================================================== */

:root {
  --chem-primary: #254823;
  --chem-primary-hover: #1e3d1c;
  --chem-accent: #357a38;
  --chem-accent-hover: #29602b;
  --chem-bubble-text: #347535;
  --chem-bg-light: #f8faf8;
  --chem-bg-card: #ffffff;
  --chem-border: #e4ebe4;
  --chem-border-focus: #357a38;
  --chem-text-main: #1f2937;
  --chem-text-muted: #6b7280;
  --chem-online: #4ade80;
  --chem-shadow: 0 16px 40px rgba(0, 0, 0, 0.16), 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* ══════════════════════════════════════════
   1. FLOATING TRIGGER WIDGET
   ══════════════════════════════════════════ */
.chem-trigger-wrap {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, visibility 0.3s;
}

.chem-trigger-wrap.is-chat-open {
  transform: scale(0.85);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Floating Speech Bubble */
.chem-speech-bubble {
  position: relative;
  background: #ffffff;
  color: var(--chem-bubble-text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14.5px;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: 22px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.07);
  white-space: nowrap;
  animation: chemBubbleFloat 3.5s ease-in-out infinite;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-bottom: -15px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chem-speech-bubble i {
  color: var(--chem-accent);
  font-size: 14px;
}

.chem-speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid #ffffff;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.05));
}

.chem-speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 9px solid rgba(0, 0, 0, 0.07);
  z-index: -1;
}

/* Avatar button */
.chem-avatar-btn {
  position: relative;
  width: 82px;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), filter 0.25s ease;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.12));
}

.chem-avatar-btn img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

/* Hover effects */
.chem-trigger-wrap:hover .chem-avatar-btn {
  transform: translateY(-4px) scale(1.04);
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.18));
}

.chem-trigger-wrap:hover .chem-speech-bubble {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.11);
  transform: translateY(-2px);
}

.chem-trigger-wrap:active .chem-avatar-btn {
  transform: scale(0.96);
}

@keyframes chemBubbleFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

/* ══════════════════════════════════════════
   2. CHATBOT WINDOW
   ══════════════════════════════════════════ */
.chem-chat-window {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 395px;
  max-width: calc(100vw - 32px);
  height: 610px;
  max-height: calc(100vh - 48px);
  background: var(--chem-bg-light);
  border-radius: 22px;
  box-shadow: var(--chem-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 10000;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  opacity: 0;
  transform: translateY(24px) scale(0.94);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.3s;
}

.chem-chat-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  pointer-events: auto;
}

/* ══════════════════════════════════════════
   3. HEADER
   ══════════════════════════════════════════ */
.chem-chat-header {
  background: var(--chem-primary);
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

.chem-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  background: #1e3a1c;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.chem-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chem-header-details {
  display: flex;
  flex-direction: column;
}

.chem-header-title {
  font-size: 15.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chem-header-title i {
  color: #8ce48c;
  font-size: 14px;
}

.chem-header-status {
  font-size: 12.5px;
  color: #9ecc9b;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-weight: 400;
}

.chem-status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--chem-online);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px var(--chem-online);
  animation: chemPulseDot 2s infinite ease-in-out;
}

@keyframes chemPulseDot {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.25);
    opacity: 0.8;
  }
}

.chem-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  font-size: 15px;
}

.chem-close-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: rotate(90deg);
}

/* ══════════════════════════════════════════
   4. CHAT BODY & MESSAGES
   ══════════════════════════════════════════ */
.chem-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: var(--chem-bg-light);
}

/* Custom Scrollbar */
.chem-chat-body::-webkit-scrollbar {
  width: 5px;
}
.chem-chat-body::-webkit-scrollbar-track {
  background: transparent;
}
.chem-chat-body::-webkit-scrollbar-thumb {
  background: #d4ded4;
  border-radius: 10px;
}
.chem-chat-body::-webkit-scrollbar-thumb:hover {
  background: #bacaba;
}

/* Message Wrapper */
.chem-msg {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  animation: chemMsgFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.chem-msg.bot {
  align-self: flex-start;
}

.chem-msg.user {
  align-self: flex-end;
}

/* Bot Message Bubble / Card */
.chem-bot-card {
  background: var(--chem-bg-card);
  border: 1px solid var(--chem-border);
  border-radius: 18px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--chem-text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.chem-bot-card p {
  margin: 0 0 8px;
}
.chem-bot-card p:last-child {
  margin-bottom: 0;
}

/* User Message Bubble */
.chem-user-bubble {
  background: var(--chem-primary);
  color: #ffffff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 2px 8px rgba(37, 72, 35, 0.18);
  word-break: break-word;
}

.chem-msg-time {
  font-size: 11px;
  color: var(--chem-text-muted);
  margin-top: 4px;
  padding: 0 4px;
}
.chem-msg.user .chem-msg-time {
  text-align: right;
}

/* ══════════════════════════════════════════
   5. QUICK OPTIONS (FontAwesome Icons)
   ══════════════════════════════════════════ */
.chem-quick-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.chem-option-btn {
  background: #ffffff;
  border: 1px solid var(--chem-border);
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: #1a3c19;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  text-align: left;
  user-select: none;
  width: 100%;
}

.chem-option-icon {
  font-size: 14px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--chem-accent);
  background: #edf5ed;
  border-radius: 9px;
  transition: all 0.2s ease;
}

.chem-option-btn:hover {
  background: #f3f8f3;
  border-color: var(--chem-accent);
  color: #133013;
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(53, 122, 56, 0.12);
}

.chem-option-btn:hover .chem-option-icon {
  background: var(--chem-accent);
  color: #ffffff;
}

.chem-option-btn:active {
  transform: scale(0.98);
}

/* Action Chips & Link Buttons */
.chem-action-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.chem-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #edf5ed;
  color: #205322;
  padding: 7px 13px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid #d4e5d4;
  transition: all 0.2s ease;
  cursor: pointer;
  user-select: none;
}

.chem-chip i {
  font-size: 12px;
  color: var(--chem-accent);
  transition: color 0.2s ease;
}

.chem-chip:hover {
  background: var(--chem-primary);
  color: #ffffff;
  border-color: var(--chem-primary);
  transform: translateY(-1px);
}

.chem-chip:hover i {
  color: #ffffff;
}

.chem-chip.primary-action {
  background: var(--chem-accent);
  color: #ffffff;
  border-color: var(--chem-accent);
}
.chem-chip.primary-action i {
  color: #ffffff;
}
.chem-chip.primary-action:hover {
  background: var(--chem-accent-hover);
}

/* ══════════════════════════════════════════
   6. STRUCTURED SUMMARY CARD (Quotation Review)
   ══════════════════════════════════════════ */
.chem-summary-card {
  background: #ffffff;
  border: 1px solid #dce8dc;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 10px 0 6px;
  font-size: 13px;
  line-height: 1.6;
}

.chem-summary-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed #e8efe8;
  padding: 5px 0;
}
.chem-summary-row:last-child {
  border-bottom: none;
}
.chem-summary-label {
  color: #6b7280;
  font-weight: 500;
}
.chem-summary-value {
  color: #1f2937;
  font-weight: 600;
  text-align: right;
  max-width: 60%;
}

/* Stock Badges & Table */
.chem-stock-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  margin: 6px 0 10px;
}
.chem-stock-badge.in-stock {
  background: #eaf6ea;
  color: #1e7025;
  border: 1px solid #cce8cc;
}
.chem-stock-badge.out-of-stock {
  background: #fde8e8;
  color: #c52222;
  border: 1px solid #f8c2c2;
}

.chem-stock-table {
  background: #ffffff;
  border: 1px solid #e1ebe1;
  border-radius: 14px;
  overflow: hidden;
  margin: 10px 0;
  font-size: 13px;
}
.chem-stock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #f0f4f0;
}
.chem-stock-item:last-child {
  border-bottom: none;
}
.chem-stock-item.is-out {
  background: #fff8f8;
}
.chem-stock-name {
  font-weight: 600;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chem-stock-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  min-width: 78px;
}
.chem-stock-pill.avail {
  background: #e8f5e9;
  color: #2e7d32;
}
.chem-stock-pill.unavail {
  background: #ffebee;
  color: #c62828;
}

/* ══════════════════════════════════════════
   7. TYPING INDICATOR
   ══════════════════════════════════════════ */
.chem-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ffffff;
  border: 1px solid var(--chem-border);
  padding: 12px 18px;
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  align-self: flex-start;
}

.chem-typing-dot {
  width: 7px;
  height: 7px;
  background-color: var(--chem-accent);
  border-radius: 50%;
  animation: chemDotBounce 1.4s infinite ease-in-out both;
}

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

@keyframes chemDotBounce {
  0%, 80%, 100% {
    transform: scale(0.4);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

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

/* ══════════════════════════════════════════
   8. FOOTER INPUT BAR
   ══════════════════════════════════════════ */
.chem-chat-footer {
  background: #ffffff;
  border-top: 1px solid #ebf1eb;
  padding: 12px 16px 14px;
  flex-shrink: 0;
}

.chem-input-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chem-input-wrap {
  flex: 1;
  background: #f2f5f2;
  border-radius: 25px;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.chem-input-wrap:focus-within {
  background: #ffffff;
  border-color: var(--chem-accent);
  box-shadow: 0 0 0 3px rgba(53, 122, 56, 0.12);
}

.chem-input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--chem-text-main);
  font-family: inherit;
  padding: 6px 0;
}

.chem-input::placeholder {
  color: #8b998b;
  font-weight: 400;
}

.chem-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--chem-accent);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(53, 122, 56, 0.28);
  font-size: 16px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chem-send-btn i {
  transform: translate(1px, -1px);
  transition: transform 0.2s ease;
}

.chem-send-btn:hover {
  background: var(--chem-accent-hover);
  transform: scale(1.06);
  box-shadow: 0 5px 14px rgba(53, 122, 56, 0.35);
}

.chem-send-btn:hover i {
  transform: translate(2px, -2px) scale(1.08);
}

.chem-send-btn:active {
  transform: scale(0.95);
}

/* ══════════════════════════════════════════
   9. RESPONSIVE DESIGN (Mobile)
   ══════════════════════════════════════════ */
@media (max-width: 480px) {
  .chem-trigger-wrap {
    right: 16px;
    bottom: 16px;
  }

  .chem-avatar-btn {
    width: 72px;
  }

  .chem-speech-bubble {
    font-size: 13.5px;
    padding: 8px 14px;
  }

  .chem-chat-window {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
    max-width: 100vw;
    height: calc(100vh - 24px);
    max-height: 590px;
    border-radius: 20px;
  }

  .chem-header-title {
    font-size: 14.5px;
  }

  .chem-header-avatar {
    width: 38px;
    height: 38px;
  }

  .chem-bot-card {
    font-size: 13.5px;
    padding: 13px 15px;
  }

  .chem-option-btn {
    padding: 9px 12px;
    font-size: 13px;
  }
}

