/* ==========================================================================
   Lex Matondo Portfolio · AI Chatbot Widget Styles
   Clean, Unobtrusive Monochrome Obsidian Glassmorphism System
   ========================================================================== */

.lex-chat-widget {
  position: fixed;
  bottom: 75px;
  right: 24px;
  z-index: 99999;
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #f2f2f0;
  -webkit-font-smoothing: antialiased;
  pointer-events: auto;
}

/* Subtle Screen Backdrop for Mobile / Focused Reading */
.lex-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  pointer-events: none;
}

.lex-chat-backdrop.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ==========================================================================
   Floating Launcher Trigger
   ========================================================================== */
.lex-chat-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(18, 18, 18, 0.9);
  color: #f2f2f0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.1px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  user-select: none;
}

.lex-chat-trigger:hover {
  transform: translateY(-2px);
  background: rgba(28, 28, 28, 0.95);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.lex-chat-trigger:active {
  transform: translateY(0);
}

.lex-trigger-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border: none;
  flex-shrink: 0;
  padding: 0;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.lex-trigger-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.25));
}

.lex-chat-trigger:hover .lex-trigger-icon {
  transform: scale(1.12);
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
}

.lex-trigger-label {
  font-size: 12.5px;
  color: #e5e5e3;
  white-space: nowrap;
}

.lex-trigger-badge {
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.8);
  animation: lex-pulse 2.2s infinite ease-in-out;
  flex-shrink: 0;
}

@keyframes lex-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* ==========================================================================
   Chat Window Panel (Desktop Default)
   ========================================================================== */
.lex-chat-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 100px);
  background: rgba(14, 14, 14, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.7), 0 0 1px 1px rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.24s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.24s ease;
}

.lex-chat-widget.is-open .lex-chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Mobile Drag / Sheet Handle */
.lex-sheet-handle {
  display: none;
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  margin: 8px auto 0 auto;
}

/* Header */
.lex-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(20, 20, 20, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lex-chat-title-group {
  display: flex;
  align-items: center;
  gap: 9px;
}

.lex-chat-avatar {
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}

.lex-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.25));
}

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

.lex-chat-name {
  font-size: 13px;
  font-weight: 600;
  color: #f2f2f0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lex-status-dot {
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(74, 222, 128, 0.7);
}

.lex-chat-sub {
  font-size: 10.5px;
  color: #888888;
  font-family: "JetBrains Mono", monospace;
}

.lex-chat-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.lex-icon-btn {
  background: transparent;
  border: none;
  color: #888888;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lex-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f2f2f0;
}

/* Messages Area */
.lex-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.lex-chat-body::-webkit-scrollbar {
  width: 4px;
}

.lex-chat-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 4px;
}

/* Message Bubble */
.lex-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  font-size: 13px;
  line-height: 1.48;
  word-break: break-word;
}

.lex-msg.user {
  align-self: flex-end;
  background: #ffffff;
  color: #050505;
  padding: 8px 12px;
  border-radius: 14px 14px 2px 14px;
  font-weight: 450;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.lex-msg.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  color: #ecece9;
  padding: 9px 12px;
  border-radius: 14px 14px 14px 2px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  min-width: 200px;
}

.lex-msg.assistant p {
  margin: 0 0 5px 0;
}

.lex-msg.assistant p:last-child {
  margin-bottom: 0;
}

.lex-msg.assistant ul {
  margin: 5px 0;
  padding-left: 16px;
}

.lex-msg.assistant li {
  margin-bottom: 3px;
}

.lex-msg.assistant a {
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.lex-msg.assistant code {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 4px;
  border-radius: 4px;
}

/* Quick Suggestion Chips */
.lex-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 2px 14px 10px 14px;
}

.lex-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cccccc;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.lex-chip:hover {
  background: #ffffff;
  color: #050505;
  border-color: #ffffff;
}

/* Typing Indicator */
.lex-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px 14px 14px 2px;
  align-self: flex-start;
}

.lex-typing-dot {
  width: 4px;
  height: 4px;
  background: #999999;
  border-radius: 50%;
  animation: lex-bounce 1.4s infinite ease-in-out both;
}

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

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

/* Input Area */
.lex-chat-footer {
  padding: 10px 14px;
  background: rgba(16, 16, 16, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.lex-chat-form {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 3px 4px 3px 10px;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.lex-chat-form:focus-within {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
}

.lex-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #f2f2f0;
  font-size: 13px;
  font-family: inherit;
  padding: 5px 0;
}

.lex-chat-input::placeholder {
  color: #666666;
  font-size: 12.5px;
}

.lex-send-btn {
  background: #ffffff;
  color: #050505;
  border: none;
  border-radius: 7px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.lex-send-btn:hover {
  opacity: 0.9;
  transform: scale(1.04);
}

.lex-send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   Mobile & Tablet Responsiveness (Non-distracting Bottom Sheet Drawer)
   ========================================================================== */
@media (max-width: 640px) {
  .lex-chat-widget {
    bottom: 75px;
    right: 18px;
  }

  /* Compact round floating trigger button on mobile */
  .lex-chat-trigger {
    padding: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    justify-content: center;
  }

  .lex-trigger-label {
    display: none;
  }

  .lex-trigger-badge {
    position: absolute;
    top: 3px;
    right: 3px;
  }

  .lex-trigger-icon {
    width: 22px;
    height: 22px;
  }

  /* Full-width ergonomic bottom sheet on mobile */
  .lex-chat-panel {
    position: fixed;
    inset: auto 0 0 0;
    width: 100vw;
    height: 72vh;
    max-width: 100vw;
    max-height: 82dvh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
    transform: translateY(100%);
    transform-origin: bottom center;
  }

  .lex-sheet-handle {
    display: block;
  }

  .lex-chat-widget.is-open .lex-chat-panel {
    transform: translateY(0);
  }

  .lex-chat-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
}
