/* Premium Glassmorphism SaaS Chatbot */
:root {
  --sharpai-bg: rgba(15, 23, 42, 0.72);
  --sharpai-card: rgba(30, 41, 59, 0.6);
  --sharpai-border: rgba(255, 255, 255, 0.08);
  --sharpai-blue: #2563EB;
  --sharpai-blue-light: #60A5FA;
  --sharpai-blue-gradient: linear-gradient(135deg, #2563EB, #60A5FA);
  --sharpai-text: #F8FAFC;
  --sharpai-muted: #94A3B8;
  --sharpai-green: #10B981;
  --sharpai-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --sharpai-glow: 0 0 16px rgba(37, 99, 235, 0.3);
}

.sharpai-widget,
.sharpai-widget * {
  box-sizing: border-box;
}

.sharpai-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483000;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--sharpai-text);
  line-height: 1.5;
}

/* Floating Actions Area */
.sharpai-floating-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

/* Launcher Button: Perfect Circle (62px desktop, 56px mobile) */
.sharpai-launcher {
  border: 0;
  cursor: pointer;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sharpai-launcher:hover {
  transform: scale(1.08);
  box-shadow: none;
}

.sharpai-launcher-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* WhatsApp Launcher Button */
.sharpai-whatsapp {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #25d366;
  color: #fff;
  border: 0;
  box-shadow: var(--sharpai-shadow);
  transition: transform 0.2s ease;
  text-decoration: none;
}

.sharpai-whatsapp span {
  display: none;
}

.sharpai-whatsapp:hover {
  transform: translateY(-2px);
}

.sharpai-whatsapp svg {
  width: 24px;
  height: 24px;
}

/* Hide launcher when chat is open */
.sharpai-widget.is-chat-open .sharpai-launcher,
.sharpai-widget.is-chat-open .sharpai-whatsapp {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

/* Chat Window Sizing (Width: 360px [max 370px], Height: 560px) */
.sharpai-window {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 370px;
  height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--sharpai-border);
  background: var(--sharpai-bg);
  box-shadow: var(--sharpai-shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transform: scale(0.94) translateY(24px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.sharpai-window.is-minimized {
  height: 60px !important;
}

.sharpai-window.is-minimized .sharpai-body,
.sharpai-window.is-minimized .sharpai-composer,
.sharpai-window.is-minimized .sharpai-lead-form {
  display: none;
}

/* Header (Height: 60px, Glass background) */
.sharpai-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 60px;
  background: rgba(15, 23, 42, 0.4);
  border-bottom: 1px solid var(--sharpai-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sharpai-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sharpai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.sharpai-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sharpai-title-wrap {
  display: flex;
  flex-direction: column;
}

.sharpai-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}

.sharpai-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  color: var(--sharpai-muted);
}

.sharpai-status-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--sharpai-green);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

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

.sharpai-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--sharpai-border);
  background: transparent;
  color: var(--sharpai-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sharpai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.sharpai-icon-btn svg {
  width: 14px;
  height: 14px;
}

/* Scrollable Messages */
.sharpai-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
}

/* 9. Custom scrollbar */
.sharpai-body::-webkit-scrollbar,
.sharpai-textarea::-webkit-scrollbar,
.sharpai-input::-webkit-scrollbar {
  width: 5px;
}

.sharpai-body::-webkit-scrollbar-track,
.sharpai-textarea::-webkit-scrollbar-track,
.sharpai-input::-webkit-scrollbar-track {
  background: transparent;
}

.sharpai-body::-webkit-scrollbar-thumb,
.sharpai-textarea::-webkit-scrollbar-thumb,
.sharpai-input::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.6);
}

/* Messages & Bubbles (Max-width: 75%, Radius: 18px) */
.sharpai-message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  max-width: 100%;
}

.sharpai-message.is-user {
  justify-content: flex-end;
}

.sharpai-mini-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sharpai-mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sharpai-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid var(--sharpai-border);
  word-break: break-word;
}

/* Assistant Chat Bubble: Dark glass */
.sharpai-message.is-bot .sharpai-bubble {
  background: var(--sharpai-card);
  color: #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* User Chat Bubble: Blue Gradient */
.sharpai-message.is-user .sharpai-bubble {
  background: var(--sharpai-blue-gradient);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.sharpai-bubble p {
  margin: 0 0 6px 0;
}

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

.sharpai-bubble strong {
  color: #fff;
}

.sharpai-message.is-user .sharpai-bubble strong {
  color: #fff;
}

.sharpai-bubble ul {
  margin: 4px 0 6px 14px;
  padding: 0;
}

.sharpai-bubble li {
  margin-bottom: 2px;
}

.sharpai-time {
  display: block;
  font-size: 9px;
  color: var(--sharpai-muted);
  margin-top: 4px;
}

.sharpai-message.is-user .sharpai-time {
  color: rgba(255, 255, 255, 0.6);
  text-align: right;
}

/* Suggestion Chips */
.sharpai-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 10px 36px;
}

.sharpai-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--sharpai-border);
  color: var(--sharpai-text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sharpai-chip:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--sharpai-blue-light);
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.2);
}

/* Compact Glass Pills (Website, Software, AI, Pricing, Portfolio, Contact, Book Call) */
.sharpai-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 4px 0 10px 36px;
}

.sharpai-action-card {
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--sharpai-border);
  color: var(--sharpai-text);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 12px;
  font-weight: 500;
}

.sharpai-action-card:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--sharpai-blue-light);
  transform: translateY(-1.5px);
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.15);
}

.sharpai-action-icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: rgba(37, 99, 235, 0.12);
  display: grid;
  place-items: center;
  color: var(--sharpai-blue-light);
  flex-shrink: 0;
}

.sharpai-action-icon svg {
  width: 12px;
  height: 12px;
}

/* Secondary Panels */
.sharpai-action-panel,
.sharpai-recovery {
  margin: 0 0 10px 36px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--sharpai-border);
  background: var(--sharpai-card);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sharpai-action-panel-title {
  width: 100%;
  color: var(--sharpai-muted);
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 4px;
}

.sharpai-option,
.sharpai-recovery button,
.sharpai-recovery a {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--sharpai-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--sharpai-text);
  font-size: 11px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.sharpai-option:hover,
.sharpai-recovery button:hover,
.sharpai-recovery a:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--sharpai-blue-light);
}

/* Typing Indicator */
.sharpai-message.is-typing-indicator .sharpai-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sharpai-typing-text {
  font-size: 11.5px;
  color: var(--sharpai-muted);
}

.sharpai-typing {
  display: inline-flex;
  gap: 3px;
}

.sharpai-typing span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--sharpai-blue-light);
  animation: sharpaiTyping 1.4s infinite both;
}

.sharpai-typing span:nth-child(2) { animation-delay: 0.2s; }
.sharpai-typing span:nth-child(3) { animation-delay: 0.4s; }

/* Composer Input Area: Glass rounded pill */
.sharpai-composer {
  padding: 0 16px;
  height: 56px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--sharpai-border);
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sharpai-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
}

.sharpai-input {
  width: 100%;
  height: 36px;
  resize: none;
  border-radius: 18px;
  border: 1px solid var(--sharpai-border);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  padding: 8px 14px;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
  transition: all 0.2s ease;
}

.sharpai-input:focus {
  border-color: rgba(96, 165, 250, 0.68);
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.25);
  background: rgba(255, 255, 255, 0.09);
}

/* Send Button: Circular Blue Gradient */
.sharpai-send {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 0;
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;
  background: var(--sharpai-blue);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sharpai-send:hover {
  background: var(--sharpai-blue-light);
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
}

.sharpai-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.sharpai-send svg {
  width: 14px;
  height: 14px;
}

/* Lead Form Styling */
.sharpai-lead-form {
  display: none;
  padding: 12px 16px;
  border-top: 1px solid var(--sharpai-border);
  background: var(--sharpai-card);
}

.sharpai-lead-form.is-visible {
  display: block;
}

.sharpai-form-heading {
  margin-bottom: 8px;
}

.sharpai-form-heading strong {
  font-size: 13px;
  color: #fff;
  display: block;
}

.sharpai-form-heading span {
  font-size: 11px;
  color: var(--sharpai-muted);
}

.sharpai-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.sharpai-field,
.sharpai-textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--sharpai-border);
  background: var(--sharpai-bg);
  color: #fff;
  padding: 7px 9px;
  font-size: 12px;
  outline: none;
}

.sharpai-field:focus,
.sharpai-textarea:focus {
  border-color: var(--sharpai-blue-light);
}

.sharpai-textarea {
  grid-column: 1 / -1;
  min-height: 54px;
  resize: none;
}

.sharpai-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.sharpai-form-actions button {
  flex: 1;
  height: 30px;
  border-radius: 8px;
  border: 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sharpai-submit-lead {
  background: var(--sharpai-blue-gradient);
  color: #fff;
}

.sharpai-cancel-lead {
  background: rgba(255, 255, 255, 0.05);
  color: var(--sharpai-text);
  border: 1px solid var(--sharpai-border) !important;
}

.sharpai-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Animations */
@keyframes sharpaiTyping {
  0% { transform: translateY(0px); opacity: 0.3; }
  28% { transform: translateY(-4px); opacity: 1; }
  70% { transform: translateY(0px); opacity: 0.3; }
}

/* Responsive / Mobile styles (Width: 92vw, Height: 82vh) */
@media (max-width: 768px) {
  /* Widget container: anchor to bottom-right only, no left stretch */
  .sharpai-widget {
    right: 16px;
    bottom: 16px;
    left: auto;
    width: auto;
    /* Allow children to receive pointer events, but not the container itself
       when closed so it doesn't block touch on the rest of the page */
    pointer-events: none;
  }

  /* Re-enable pointer events on all interactive children */
  .sharpai-widget > *,
  .sharpai-floating-actions,
  .sharpai-launcher,
  .sharpai-whatsapp,
  .sharpai-window.is-open {
    pointer-events: auto;
  }

  .sharpai-launcher {
    width: 56px;
    height: 56px;
  }

  /* Chat window: use fixed positioning so it doesn't inherit widget offset */
  .sharpai-window {
    position: fixed;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: 100%;
    height: 82vh;
    max-height: 82vh;
    bottom: 16px;
    border-radius: 20px 20px 20px 20px;
    transform-origin: bottom center;
  }

  .sharpai-actions {
    grid-template-columns: repeat(2, 1fr);
    margin-left: 0;
  }

  .sharpai-chips-container {
    margin-left: 0;
  }

  .sharpai-action-panel,
  .sharpai-recovery {
    margin-left: 0;
  }
}
