/* ============================================
   Live Support Dashboard — v3 (Premium Step Flow)
   Color: Material Green #4CAF50
   Style: Luxury minimal, step-by-step intake
   ============================================ */

#lsd-root, #lsd-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Floating Open Button with Heartbeat ===== */
#lsd-open-btn {
  position: fixed; bottom: 24px; right: 24px; z-index: 999998;
  display: flex; align-items: center; gap: 8px;
  background: #4CAF50; color: #fff; border: none;
  padding: 14px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 8px 24px rgba(76, 175, 80, 0.35);
  transition: background 0.2s;
  animation: lsd-heartbeat 1.6s ease-out infinite;
  isolation: isolate;
}
#lsd-open-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 999px;
  animation: lsd-heartglow 1.6s ease-out infinite;
  pointer-events: none;
  z-index: -1;
}
#lsd-open-btn:hover {
  background: #388E3C;
  animation-play-state: paused;
}
#lsd-open-btn:hover::before { animation-play-state: paused; }
#lsd-open-btn.lsd-hidden { display: none; }

@keyframes lsd-heartbeat {
  0%, 50%, 100% { transform: scale(1); }
  15% { transform: scale(1.08); }
  30% { transform: scale(1); }
  45% { transform: scale(1.08); }
}
@keyframes lsd-heartglow {
  0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.55); }
  50% { box-shadow: 0 0 0 18px rgba(76, 175, 80, 0); }
  100% { box-shadow: 0 0 0 18px rgba(76, 175, 80, 0); }
}

/* ===== Popup Container ===== */
#lsd-popup {
  position: fixed; bottom: 24px; right: 24px; z-index: 999999;
  width: 400px; max-width: calc(100vw - 32px);
  height: 640px; max-height: calc(100vh - 48px);
  background: #fff; border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  display: none; flex-direction: column; overflow: hidden;
}
#lsd-popup.lsd-open { display: flex; }

/* ===== Header (premium white, brand-green accent) ===== */
.lsd-header {
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  padding: 18px 20px;
  padding-top: max(18px, env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.lsd-header-left {
  display: flex; align-items: center; gap: 12px;
}
.lsd-logo-box {
  width: 42px;
  height: 42px;
  background: #4CAF50;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}
.lsd-header-title {
  font-size: 17px;
  font-weight: 700;
  color: #4CAF50;
  line-height: 1.2;
}
.lsd-header-sub {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
  font-weight: 500;
}
.lsd-status-dot { display: none; }

#lsd-close-btn {
  background: #f3f4f6 !important;
  border: none !important;
  color: #6b7280 !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  font-size: 18px !important;
  font-weight: 400 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  transition: all 0.2s !important;
  flex-shrink: 0;
}
#lsd-close-btn:hover {
  background: #e5e7eb !important;
  color: #111827 !important;
}

/* ===== Progress Indicator (dashes) ===== */
.lsd-progress {
  padding: 22px 26px 0;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.lsd-progress-dash {
  flex: 1;
  height: 3px;
  background: #e5e7eb;
  border-radius: 999px;
  transition: background-color 0.3s ease;
}
.lsd-progress-dash.lsd-active {
  background: #4CAF50;
}

/* ===== Step Content Area ===== */
.lsd-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 26px 20px;
  overflow-y: auto;
}
.lsd-step-label {
  font-size: 11px;
  font-weight: 700;
  color: #9ca3af;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.lsd-step-question {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  line-height: 1.25;
  margin-bottom: 10px;
  letter-spacing: -0.3px;
}
.lsd-step-helper {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
  margin-bottom: 26px;
}

.lsd-step-input {
  width: 100%;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: #111827;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lsd-step-input::placeholder { color: #9ca3af; }
.lsd-step-input:focus {
  border-color: #4CAF50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.12);
}

/* Connecting screen */
.lsd-connecting {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  text-align: center;
}
.lsd-connecting-pulse {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #4CAF50;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 32px;
  margin-bottom: 22px;
  position: relative;
}
.lsd-connecting-pulse::before,
.lsd-connecting-pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #4CAF50;
  animation: lsd-pulse-out 2s ease-out infinite;
}
.lsd-connecting-pulse::after { animation-delay: 1s; }
@keyframes lsd-pulse-out {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(2.2); opacity: 0; }
}
.lsd-connecting-title {
  font-size: 19px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
  line-height: 1.3;
}
.lsd-connecting-sub {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
}
.lsd-connecting-sub strong {
  color: #4CAF50;
  font-weight: 700;
}

/* Quick replies on final step */
.lsd-quick-group {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 18px;
}
.lsd-quick-btn {
  background: #fff !important;
  border: 1.5px solid #e5e7eb !important;
  color: #111827 !important;
  padding: 13px 16px !important;
  border-radius: 11px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  text-align: left !important;
  transition: all 0.15s !important;
  font-family: inherit !important;
  line-height: 1.3 !important;
}
.lsd-quick-btn:hover {
  border-color: #4CAF50 !important;
  background: #f0fdf4 !important;
}
.lsd-quick-btn.lsd-selected {
  background: #f0fdf4 !important;
  border-color: #4CAF50 !important;
  color: #2E7D32 !important;
}
.lsd-or-divider {
  text-align: center;
  margin: 6px 0 12px;
  font-size: 12px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.lsd-step-textarea {
  width: 100%;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: #111827;
  outline: none;
  resize: vertical;
  min-height: 70px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lsd-step-textarea:focus {
  border-color: #4CAF50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.12);
}

/* ===== Footer Actions (Back + Continue) ===== */
.lsd-step-actions {
  display: flex;
  gap: 10px;
  padding: 16px 26px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  border-top: 1px solid #f0f0f0;
  background: #fff;
  flex-shrink: 0;
}
.lsd-back-btn {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  color: #6b7280;
  padding: 12px 18px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.lsd-back-btn:hover {
  border-color: #9ca3af;
  color: #111827;
}
.lsd-continue-btn {
  flex: 1;
  background: #4CAF50;
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
}
.lsd-continue-btn:hover { background: #388E3C; }
.lsd-continue-btn:active { transform: scale(0.98); }
.lsd-continue-btn:disabled {
  background: #e5e7eb !important;
  color: #9ca3af !important;
  cursor: not-allowed;
}

.lsd-error-msg {
  font-size: 13px;
  color: #dc2626;
  margin-top: 10px;
  min-height: 18px;
}

/* ===== Chat View (after form complete) ===== */
.lsd-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.lsd-messages { flex: 1; overflow-y: auto; padding: 18px; background: #f9fafb; }
.lsd-msg { max-width: 80%; margin-bottom: 12px; display: flex; flex-direction: column; }
.lsd-msg.lsd-customer { margin-left: auto; align-items: flex-end; }
.lsd-msg.lsd-rep { margin-right: auto; align-items: flex-start; }
.lsd-msg-bubble {
  padding: 10px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.45;
  white-space: pre-wrap; word-wrap: break-word;
}
.lsd-msg.lsd-customer .lsd-msg-bubble {
  background: #4CAF50; color: #fff; border-bottom-right-radius: 4px;
}
.lsd-msg.lsd-rep .lsd-msg-bubble {
  background: #fff; color: #111827;
  border: 1px solid #e5e7eb; border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.lsd-msg-meta { font-size: 11px; color: #9ca3af; margin-top: 4px; padding: 0 4px; }

.lsd-input-row {
  background: #fff; border-top: 1px solid #e5e7eb;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: flex-end;
  flex-shrink: 0;
}
#lsd-reply-input {
  flex: 1; border: 1.5px solid #d1d5db; border-radius: 20px;
  padding: 10px 14px; font-size: 14px; resize: none; font-family: inherit;
  max-height: 100px; min-height: 42px; line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#lsd-reply-input:focus {
  outline: none; border-color: #4CAF50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

#lsd-reply-btn {
  background: #4CAF50 !important;
  border: none !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  padding: 0 !important;
  color: #ffffff !important;
  transition: background 0.15s, transform 0.1s !important;
}
#lsd-reply-btn:hover { background: #388E3C !important; }
#lsd-reply-btn:active { transform: scale(0.94) !important; }
#lsd-reply-btn:disabled { background: #A5D6A7 !important; cursor: not-allowed !important; }
#lsd-reply-btn::after {
  content: "➤";
  color: #ffffff;
  font-size: 16px;
  font-weight: bold;
}
#lsd-reply-btn svg { display: none !important; }

/* ===== Mobile (full screen with notch support) ===== */
@media (max-width: 480px) {
  #lsd-popup {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    bottom: 0; right: 0;
    border-radius: 0;
  }
  #lsd-open-btn {
    bottom: 16px; right: 16px;
    padding: 13px 18px; font-size: 14px;
  }
  #lsd-close-btn {
    width: 38px !important;
    height: 38px !important;
    font-size: 20px !important;
  }
  .lsd-step-question { font-size: 22px; }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
  #lsd-open-btn,
  #lsd-open-btn::before,
  .lsd-connecting-pulse::before,
  .lsd-connecting-pulse::after {
    animation: none !important;
  }
}