/* ==========================================================================
   LICHCHUP STUDIO — AI ASSISTANT WIDGET STYLES (Light & Dark Theme)
   ========================================================================== */

/* 1. Launcher Floating Button (AssistiveTouch Style) */
.sp-ai-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  border: 2px solid #f5b700;
  color: #f5b700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 9998;
  pointer-events: auto !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22), 0 0 16px rgba(245, 183, 0, 0.35);
  transition: left 0.32s cubic-bezier(0.22, 1, 0.36, 1),
              top 0.32s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease,
              border-color 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overflow: visible;
}

.sp-ai-launcher.is-dragging {
  transition: transform 0.12s ease, box-shadow 0.12s ease !important;
  transform: scale(1.08) !important;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.42), 0 0 26px rgba(245, 183, 0, 0.65) !important;
  cursor: grabbing !important;
}

#spAiLauncher {
  cursor: grab !important;
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
}

.sp-ai-launcher-icon,
.sp-ai-launcher-badge {
  pointer-events: none !important;
}

:root[data-theme="dark"] .sp-ai-launcher,
body.dark-theme .sp-ai-launcher {
  background: transparent;
  border-color: #f5b700;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4), 0 0 18px rgba(245, 183, 0, 0.35);
}

.sp-ai-launcher:hover {
  transform: scale(1.08);
  border-color: #ffc720;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3), 0 0 24px rgba(245, 183, 0, 0.5);
}

.sp-ai-launcher:active {
  transform: scale(0.94);
}

.sp-ai-launcher.active {
  background: transparent;
  color: #f5b700;
  border-color: #f5b700;
  box-shadow: 0 0 22px rgba(245, 183, 0, 0.45);
}

.sp-ai-launcher-icon {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.25s ease;
}

.sp-ai-launcher.active .sp-ai-launcher-icon {
  transform: scale(0.96);
}

.sp-ai-launcher-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.sp-ai-launcher-badge {
  position: absolute;
  top: 0px;
  right: 0px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.85);
  z-index: 2;
}

/* 2. Speech Bubble Tooltip ("Hỏi trợ lý LICHCHUP Studio") */
.sp-ai-bubble {
  position: fixed;
  right: 24px;
  bottom: 88px;
  z-index: 9997;
  background: var(--surface, #ffffff);
  color: var(--text, #1b2430);
  border: 1px solid var(--line, #e3e8ec);
  padding: 10px 14px 10px 12px;
  border-radius: 16px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  max-width: 280px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.92);
  transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1), 
              transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.32s ease;
  user-select: none;
}

:root[data-theme="dark"] .sp-ai-bubble,
body.dark-theme .sp-ai-bubble {
  background: #192330;
  color: #f3f7fc;
  border-color: rgba(245, 183, 0, 0.3);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.sp-ai-bubble.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Arrow indicator pointing to launcher */
.sp-ai-bubble::after {
  content: "";
  position: absolute;
  bottom: -7px;
  right: 22px;
  width: 12px;
  height: 12px;
  background: inherit;
  border-right: 1px solid inherit;
  border-bottom: 1px solid inherit;
  transform: rotate(45deg);
  border-color: inherit;
}

.sp-ai-bubble.snap-left::after {
  right: auto;
  left: 18px;
}

.sp-ai-bubble-sparkle {
  color: #f5b700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: sp-sparkle-spin 4s ease-in-out infinite;
}

@keyframes sp-sparkle-spin {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.15) rotate(12deg); }
}

.sp-ai-bubble-text {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text, #1b2430);
  white-space: nowrap;
}

.sp-ai-bubble-close {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted, #667688);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sp-ai-bubble-close:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text, #1b2430);
}

:root[data-theme="dark"] .sp-ai-bubble-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* 3. Popup Chat Window — Luxury Dark Mode Always */
.sp-ai-popup {
  position: fixed;
  right: 24px;
  bottom: 88px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 110px);
  border-radius: 20px;
  background: #111822 !important;
  border: 1px solid #232f3e !important;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.6) !important;
  color: #f1f5f9 !important;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(18px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.28s ease;
}

#spAiPopup.open,
.sp-ai-popup.open {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0) scale(1) !important;
}

/* Popup Header */
.sp-ai-header {
  padding: 14px 16px;
  background: #141d28 !important;
  border-bottom: 1px solid #212c3b !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sp-ai-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sp-ai-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid rgba(245, 183, 0, 0.55);
  box-shadow: 0 0 10px rgba(245, 183, 0, 0.25);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.sp-ai-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.sp-ai-avatar svg {
  width: 22px;
  height: 22px;
}

.sp-ai-header-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sp-ai-header-title {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff !important;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-ai-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #10b981;
  font-weight: 600;
  margin-top: 2px;
}

.sp-ai-header-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.8);
}

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

.sp-ai-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #8e9eaf !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sp-ai-icon-btn:hover {
  background: #1b2533 !important;
  color: #f5b700 !important;
}

/* Chat Messages Container */
.sp-ai-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background: #0d131a !important;
}

.sp-ai-messages::-webkit-scrollbar {
  width: 5px;
}
.sp-ai-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15) !important;
  border-radius: 4px;
}

/* Message Rows */
.sp-ai-msg-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.sp-ai-msg-row.ai {
  align-self: flex-start;
  max-width: 88%;
}

.sp-ai-msg-row.user {
  align-self: flex-end;
  max-width: 85%;
  justify-content: flex-end;
}

.sp-ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(245, 183, 0, 0.45);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.sp-ai-msg-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.sp-ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.48;
  word-break: break-word;
}

.sp-ai-msg-row.ai .sp-ai-msg-bubble {
  background: #141d28 !important;
  border: 1px solid #233041 !important;
  color: #f1f5f9 !important;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.sp-ai-msg-row.ai .sp-ai-msg-bubble b,
.sp-ai-msg-row.ai .sp-ai-msg-bubble strong {
  color: #f5b700 !important;
}

.sp-ai-msg-row.user .sp-ai-msg-bubble {
  background: linear-gradient(135deg, #f5b700 0%, #ebb000 100%) !important;
  color: #121820 !important;
  font-weight: 600 !important;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(245, 183, 0, 0.25);
}

/* Welcome Card / Onboarding */
.sp-ai-welcome-card {
  background: #141d28 !important;
  border: 1px solid #233041 !important;
  border-radius: 16px;
  padding: 14px 14px 12px;
  margin-bottom: 4px;
  box-shadow: none !important;
}

.sp-ai-welcome-card h4 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 800;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sp-ai-welcome-card p {
  margin: 0;
  font-size: 12.5px;
  color: #94a3b8 !important;
  line-height: 1.45;
}

/* Quick prompt suggestions */
.sp-ai-quick-prompts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.sp-ai-quick-btn {
  background: #192433 !important;
  border: 1px solid #263547 !important;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0 !important;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.sp-ai-quick-btn:hover {
  border-color: rgba(245, 183, 0, 0.6) !important;
  background: rgba(245, 183, 0, 0.12) !important;
  color: #f5b700 !important;
  transform: translateX(3px);
}

.sp-ai-quick-btn span {
  flex: 1;
}

.sp-ai-quick-btn svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

/* Typing / Thinking Indicator — LICHCHUP Generating Orb */
.sp-ai-msg-bubble.sp-ai-typing-orb {
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  border-radius: 50% !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.og-frame {
  display: grid;
  place-items: center;
  width: auto;
  height: auto;
  overflow: hidden;
  background: transparent !important;
  --og-highlight: #ffffff;
  --og-halo: #f5b700;
  --og-core: #ff6d00 !important;
  --og-halo-alt: #ffb703 !important;
  --og-core-alt: #9a3412 !important;
  --og-text: #ffffff !important;
}

.og-loader {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--og-size, 96px);
  height: var(--og-size, 96px);
  font-family: var(--font-sans, 'Inter', system-ui, -apple-system, sans-serif);
  font-size: calc(var(--og-text-size, 1.15) * var(--og-unit, 0.53) * 16px);
  font-weight: 500;
  letter-spacing: var(--og-tracking, 0.3px);
  color: var(--og-text, #1b2430);
  border-radius: 50%;
  background-color: transparent;
  user-select: none;
}

.og-word {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.og-orb {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 50%;
  background-color: transparent;
  transform: rotate(90deg);
  box-shadow: 0 calc(10px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(20px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-highlight, #ffffff) inset,
              0 calc(20px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(30px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-halo, #f5b700) inset,
              0 calc(60px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(60px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-core, #e65100) inset;
  animation: og-rotate var(--og-duration, 2200ms) linear infinite;
}

.og-letter {
  display: inline-block;
  opacity: var(--og-rest, 0.45);
  transform: translateY(0);
  animation: og-letter var(--og-duration, 2200ms) infinite;
  animation-delay: calc(var(--i) * var(--og-stagger, 95ms));
}

.og-loader[data-playback='pause'] .og-orb,
.og-loader[data-playback='pause'] .og-letter {
  animation-play-state: paused;
}

@keyframes og-rotate {
  0% {
    transform: rotate(90deg);
    box-shadow: 0 calc(10px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(20px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-highlight, #ffffff) inset,
                0 calc(20px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(30px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-halo, #f5b700) inset,
                0 calc(60px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(60px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-core, #e65100) inset;
  }
  50% {
    transform: rotate(270deg);
    box-shadow: 0 calc(10px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(20px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-highlight, #ffffff) inset,
                0 calc(20px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(10px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-halo-alt, #ffaa00) inset,
                0 calc(40px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(60px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-core-alt, #7c2d12) inset;
  }
  100% {
    transform: rotate(450deg);
    box-shadow: 0 calc(10px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(20px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-highlight, #ffffff) inset,
                0 calc(20px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(30px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-halo, #f5b700) inset,
                0 calc(60px * var(--og-unit, 0.53) * var(--og-depth, 1)) calc(60px * var(--og-unit, 0.53) * var(--og-depth, 1)) 0 var(--og-core, #e65100) inset;
  }
}

@keyframes og-letter {
  0%, 100% {
    opacity: var(--og-rest, 0.45);
    transform: translateY(0);
  }
  20% {
    opacity: 1;
    transform: scale(var(--og-pop, 1.18));
    color: var(--og-halo, #f5b700);
  }
  40% {
    opacity: calc(var(--og-rest, 0.45) + (1 - var(--og-rest, 0.45)) * 0.5);
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .og-orb, .og-letter {
    animation: none;
  }
  .og-letter {
    opacity: 1;
  }
}

/* Image Preview Tray */
.sp-ai-img-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--line, #e3e8ec);
  border-radius: 14px;
  animation: sp-ai-slide-up 0.2s ease-out;
}

:root[data-theme="dark"] .sp-ai-img-preview {
  background: #151e2a;
  border-color: #27374b;
}

@keyframes sp-ai-slide-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.sp-ai-img-thumb-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--line, #e3e8ec);
}

.sp-ai-img-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sp-ai-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.sp-ai-thumb-remove:hover {
  background: #ef4444;
}

.sp-ai-img-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.sp-ai-img-info b {
  font-size: 12px;
  color: var(--text, #1b2430);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-ai-img-info small {
  font-size: 10.5px;
  color: #10b981;
  font-weight: 600;
}

/* User Message with Image */
.sp-ai-msg-img-wrap {
  margin-bottom: 6px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 220px;
  max-height: 180px;
}

.sp-ai-msg-img {
  width: 100%;
  height: auto;
  max-height: 180px;
  object-fit: cover;
  display: block;
  border-radius: 10px;
}

/* ==========================================================================
   AI CHAT INPUT (Directly from ai-chat-input.html / Uiverse Cobp)
   ========================================================================== */
.sp-ai-footer {
  padding: 12px 14px 10px;
  background: #141d28 !important;
  border-top: 1px solid #212c3b !important;
  box-sizing: border-box;
  width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.aci-frame {
  width: 100%;
  box-sizing: border-box;
  position: relative;
  background: transparent !important;
  --aci-field-height: 48px;
  --aci-gap: 8px;
  --aci-radius: 24px;
  --aci-font: 14px;
  --aci-surface: #192433;
  --aci-text: #8e9eaf;
  --aci-icon: #94a3b8;
  --aci-accent: #f5b700;
  --aci-focus: #f5b700;
  --aci-transition: 280ms;
}

.aci-shell {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--aci-gap);
  width: 100%;
  max-width: 100%;
  margin: 0;
  box-sizing: border-box;
  font-family: var(--font-sans, 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif);
}

.aci-upload-actions {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 128px;
  flex: 0 0 128px;
  opacity: 1;
  visibility: visible;
  filter: blur(0);
  transition: width var(--aci-transition) cubic-bezier(.16,1,.3,1),
              flex-basis var(--aci-transition) cubic-bezier(.16,1,.3,1),
              opacity var(--aci-transition) ease,
              filter var(--aci-transition) ease,
              visibility 0s linear 0s;
}

.aci-action,
.aci-voice {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  color: var(--aci-icon);
  cursor: pointer !important;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
  transition: background var(--aci-transition) cubic-bezier(.16,1,.3,1),
              color var(--aci-transition) cubic-bezier(.16,1,.3,1),
              transform var(--aci-transition) cubic-bezier(.16,1,.3,1),
              box-shadow var(--aci-transition) cubic-bezier(.16,1,.3,1),
              opacity var(--aci-transition) ease,
              filter var(--aci-transition) ease;
}

.aci-action {
  position: relative !important;
  cursor: pointer !important;
  overflow: hidden !important;
  border-radius: 12px;
  background: transparent !important;
}

.aci-action input[type="file"],
.aci-files input[type="file"] {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  opacity: 0 !important;
  cursor: pointer !important;
  font-size: 0 !important;
  z-index: 10 !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

.aci-action svg,
.aci-files svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none !important;
  position: relative !important;
  z-index: 1 !important;
}

.aci-action:hover {
  background: var(--aci-surface) !important;
  color: var(--aci-accent);
  transform: translateY(-2px);
}

.aci-action:active {
  transform: translateY(0) scale(0.95);
}

/* The '+' button: MUST BE position: absolute to take ZERO flex space in .aci-shell */
.aci-files {
  position: absolute !important;
  left: 0 !important;
  top: 50% !important;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--aci-surface) !important;
  color: var(--aci-icon);
  cursor: pointer !important;
  overflow: hidden !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  filter: blur(5px);
  transform: translateY(-50%) translateX(-16px) scale(0.9);
  z-index: 5;
  transition: background var(--aci-transition) cubic-bezier(.16,1,.3,1),
              color var(--aci-transition) cubic-bezier(.16,1,.3,1),
              transform var(--aci-transition) cubic-bezier(.16,1,.3,1),
              opacity var(--aci-transition) ease,
              filter var(--aci-transition) ease;
}

.aci-files:hover {
  color: var(--aci-accent);
  transform: translateY(-50%) translateX(0) scale(1.05);
}

.aci-files:active {
  transform: translateY(-50%) translateX(0) scale(0.95);
}

.aci-field {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  height: var(--aci-field-height);
  padding: 4px 5px 4px 14px;
  border: 1px solid #233140;
  border-radius: var(--aci-radius);
  background: var(--aci-surface);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transform: translateY(0);
  transition: border-color var(--aci-transition) cubic-bezier(.16,1,.3,1),
              box-shadow var(--aci-transition) cubic-bezier(.16,1,.3,1),
              transform var(--aci-transition) cubic-bezier(.16,1,.3,1);
}

.aci-input {
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 100% !important;
  border: 0 !important;
  padding: 0 8px 0 0 !important;
  outline: 0 !important;
  background: transparent !important;
  color: #f1f5f9 !important;
  font-family: inherit !important;
  font-size: var(--aci-font) !important;
  letter-spacing: -0.01em !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}

.aci-input::placeholder {
  color: var(--aci-text);
  opacity: 1;
  filter: blur(0px);
  transform: translateX(0);
  transition: opacity 0.22s ease, filter 0.22s ease, transform 0.22s ease;
}

.aci-shell:focus-within .aci-input::placeholder,
.aci-shell[data-state='focus'] .aci-input::placeholder,
.aci-input:focus::placeholder {
  opacity: 0 !important;
  filter: blur(6px) !important;
  transform: translateX(8px) !important;
}

.aci-voice {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #f5b700 0%, #e09f00 100%) !important;
  color: #121820 !important;
  box-shadow: 0 4px 12px rgba(245, 183, 0, 0.35) !important;
  position: relative;
  z-index: 2;
}

.aci-voice:hover {
  transform: scale(1.08) !important;
  box-shadow: 0 6px 16px rgba(245, 183, 0, 0.5) !important;
}

.aci-voice:active {
  transform: scale(0.95) !important;
}

.aci-wave {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 2.2px !important;
  width: 22px !important;
  height: 24px !important;
  pointer-events: none;
}

.aci-wave i {
  display: block !important;
  width: 2.2px !important;
  height: var(--h) !important;
  border-radius: 999px !important;
  background: currentColor !important;
  transform-origin: center !important;
  animation: aci-wave 720ms ease-in-out infinite alternate !important;
  animation-play-state: paused !important; /* MẶC ĐỊNH TĨNH */
}

.aci-wave i:nth-child(1) { animation-delay: 0ms !important; }
.aci-wave i:nth-child(2) { animation-delay: -180ms !important; }
.aci-wave i:nth-child(3) { animation-delay: -360ms !important; }
.aci-wave i:nth-child(4) { animation-delay: -540ms !important; }
.aci-wave i:nth-child(5) { animation-delay: -90ms !important; }

@keyframes aci-wave {
  from { transform: scaleY(0.42); opacity: 0.65; }
  to { transform: scaleY(1); opacity: 1; }
}

/* CHỈ KHI NÀO ẤN VOICE (data-voice-active='true') THÌ MỚI ĐỘNG */
.aci-shell[data-voice-active='true'] .aci-wave i {
  animation-play-state: running !important;
}

.aci-shell[data-voice-active='true'] .aci-voice {
  box-shadow: 0 0 0 4px rgba(245, 183, 0, 0.4), 0 6px 18px rgba(245, 183, 0, 0.5) !important;
}

.aci-send-icon {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.aci-send-icon svg {
  width: 17px;
  height: 17px;
  stroke: #121820;
  stroke-width: 2.3;
  transform: translate(-1px, 1px);
}

.aci-shell[data-has-value='true'] .aci-wave {
  display: none !important;
}

.aci-shell[data-has-value='true'] .aci-send-icon {
  display: flex !important;
}

.aci-shell:focus-within .aci-upload-actions,
.aci-shell[data-state='focus'] .aci-upload-actions,
.aci-shell[data-has-value='true'] .aci-upload-actions {
  width: 40px;
  flex: 0 0 40px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  filter: blur(5px);
  transition-delay: 0s, 0s, 0s, 0s, var(--aci-transition);
}

.aci-shell:focus-within .aci-files,
.aci-shell[data-state='focus'] .aci-files,
.aci-shell[data-has-value='true'] .aci-files {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  filter: blur(0);
  transform: translateY(-50%) translateX(0) scale(1) !important;
}

.aci-shell:focus-within .aci-field,
.aci-shell[data-state='focus'] .aci-field,
.aci-shell[data-has-value='true'] .aci-field {
  border-color: var(--aci-focus);
  box-shadow: 0 0 0 2px rgba(245, 183, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}

.aci-shell[data-voice-active='true'] .aci-voice {
  box-shadow: 0 0 0 4px rgba(245, 183, 0, 0.35), 0 6px 18px rgba(245, 183, 0, 0.5) !important;
}

.aci-action:focus-visible,
.aci-files:focus-visible,
.aci-voice:focus-visible {
  outline: 2.00006px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--aci-focus);
}

.aci-input:focus-visible {
  outline: 0;
}

.sp-ai-footer-note {
  font-size: 11px;
  color: var(--aci-text);
  text-align: center;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
}

/* Responsive on Mobile (below 820px or small screens) */
@media (max-width: 820px) {
  .sp-ai-launcher {
    right: 14px;
    bottom: calc(98px + env(safe-area-inset-bottom, 0px)); /* Strictly above the mobile bottom nav bar + floating + circle */
    width: 50px;
    height: 50px;
  }
  .sp-ai-launcher-icon {
    width: 100%;
    height: 100%;
  }
  .sp-ai-launcher-icon svg {
    width: 24px;
    height: 24px;
  }
  .sp-ai-bubble {
    right: 14px;
    bottom: calc(158px + env(safe-area-inset-bottom, 0px));
    max-width: 260px;
  }
  .sp-ai-popup {
    right: 12px;
    left: 12px;
    bottom: calc(94px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
    height: min(490px, calc(100dvh - 156px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    max-height: calc(100dvh - 156px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    border-radius: 18px;
  }

  /* Prevent mobile bottom toolbar (.mobile-nav / .sp-mobile-nav) from being pushed up when typing in chat input */
  body.lc-ai-input-focused .mobile-nav,
  body.lc-ai-input-focused #mobileAdd,
  body.lc-ai-input-focused .sp-mobile-nav,
  body.lc-ai-kb-open .mobile-nav,
  body.lc-ai-kb-open #mobileAdd,
  body.lc-ai-kb-open .sp-mobile-nav {
    top: var(--lc-nav-top-px, 100vh) !important;
    bottom: auto !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(150%) !important;
    transition: none !important;
  }

  body.lc-ai-input-focused .sp-ai-launcher,
  body.lc-ai-input-focused .sp-ai-bubble,
  body.lc-ai-kb-open .sp-ai-launcher,
  body.lc-ai-kb-open .sp-ai-bubble {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  body.lc-ai-kb-open .sp-ai-popup {
    top: var(--lc-kb-popup-top, max(56px, calc(env(safe-area-inset-top, 0px) + 12px))) !important;
    bottom: auto !important;
    height: var(--lc-kb-popup-height, calc(100dvh - 68px - env(safe-area-inset-top, 0px))) !important;
    max-height: var(--lc-kb-popup-height, calc(100dvh - 68px - env(safe-area-inset-top, 0px))) !important;
  }
}

/* Visibility rules (PC + Mobile):
   1. Show AI ONLY inside logged-in app workspace (body[data-screen="app"]).
   2. Hide AI launcher, bubble, and popup whenever ANY modal/dialog/popup/sheet is open. */
body:not([data-screen="app"]) #spAiLauncher,
body:not([data-screen="app"]) #spAiBubble,
body:not([data-screen="app"]) #spAiPopup,
body.modal-open #spAiLauncher,
body.modal-open #spAiBubble,
body.modal-open #spAiPopup,
body.mobile-day-inspector-open #spAiLauncher,
body.mobile-day-inspector-open #spAiBubble,
body.mobile-day-inspector-open #spAiPopup,
body.jobs-month-open #spAiLauncher,
body.jobs-month-open #spAiBubble,
body.jobs-month-open #spAiPopup,
body.lc-ai-suppressed #spAiLauncher,
body.lc-ai-suppressed #spAiBubble,
body.lc-ai-suppressed #spAiPopup {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
