/* ================================================
   FOOTER (Suggestions + Input)
   ================================================ */

#antimanual-chatbox-footer {
  justify-self: end;
}

#suggested-questions {
  padding: 10px 16px;
  border-top: 1px solid var(--black_75);

  > p {
    color: var(--black_400);
    font-size: 13px;
    margin-bottom: 8px;
  }

  > button {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    background-color: transparent;
    border: 1px solid var(--black_100);
    border-radius: 20px;
    width: auto;
    display: inline-block;
    margin: 0 4px 6px 0;
    color: var(--antimanual_primary_color);
    cursor: pointer;
    transition: all 0.2s ease;

    &:hover {
      background-color: rgba(0, 102, 204, 0.06);
      border-color: var(--antimanual_primary_color);
    }
  }
}

#antimanual-live-chat-cta {
  padding: 0 16px 12px;
  display: none;
}

#antimanual-live-chat-button {
  position: relative;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--antimanual_primary_color) 8%, #fff) 0%, color-mix(in srgb, var(--antimanual_primary_color) 4%, #fff) 100%);
  color: var(--antimanual_primary_color);
  border: 1px solid color-mix(in srgb, var(--antimanual_primary_color) 22%, transparent);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);

  .antimanual-live-chat-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--antimanual_primary_color);
  }

  .antimanual-live-chat-pulse {
    position: absolute;
    top: -2px;
    right: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 2px #fff;
  }

  .antimanual-live-chat-pulse::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #10b981;
    opacity: 0.6;
    animation: antimanual-live-chat-pulse 1.8s ease-out infinite;
  }

  &:hover:not(:disabled):not(.is-busy) {
    background: linear-gradient(180deg, color-mix(in srgb, var(--antimanual_primary_color) 14%, #fff) 0%, color-mix(in srgb, var(--antimanual_primary_color) 8%, #fff) 100%);
    border-color: color-mix(in srgb, var(--antimanual_primary_color) 38%, transparent);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px color-mix(in srgb, var(--antimanual_primary_color) 14%, transparent);
  }

  &:active:not(:disabled):not(.is-busy) {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  }

  &:disabled,
  &.is-busy {
    opacity: 0.7;
    cursor: wait;
  }
}

@keyframes antimanual-live-chat-pulse {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

#antimanual-input-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding:6px 6px 6px 16px;
  margin: 0 16px 16px;
  border: 1px solid var(--black_100, #d1d5db);
  border-radius: 28px;
  transition: border-color 0.2s ease;
}

#antimanual-input-container:focus-within {
  border-color:var(--antimanual_primary_color);
}

.antimanual-input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#antimanual-live-chat-attach {
  display: none;
  padding: 0 !important;
  width: 24px;
  min-width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--black_200);
  cursor: pointer;
  box-shadow: none;
  transition: color 0.2s ease;

  &:hover {
    color: var(--black_600, #4b5563);
  }

  svg {
    width: 20px;
    height: 20px;
  }
  &:disabled {
    display: none !important;
    visibility: hidden;
    opacity: 0;
  }
}

#antimanual-live-chat-attachment-preview {
  display: none;
  padding: 0 14px 10px;
}

.antimanual-live-chat-attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--black_100, #e5e7eb);
  background: #fff;
  border-radius: 8px;

  img {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
  }
}

.antimanual-live-chat-attachment-chip-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;

  strong,
  span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  strong {
    font-size: 12px;
    font-weight: 500;
    color: var(--black_800, #1f2937);
  }

  span {
    font-size: 10px;
    color: var(--black_500, #6b7280);
  }
}

.antimanual-live-chat-attachment-remove {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--black_500, #6b7280);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.05);

  &:hover {
    background: rgba(15, 23, 42, 0.08);
    color: var(--black_800, #1f2937);
  }
}

#antimanualinput {
  width: 100%;
  padding: 0;
  font-size: 15px;
  color: var(--black_700);
  background-color: transparent;
  border: none;
  border-radius: 0;
  outline: none;
  resize: none;
  overflow-y: auto;
  line-height: auto;
  font-family: inherit;
  scrollbar-width: none;
  box-shadow: none !important;
  
  &::-webkit-scrollbar {
    display: none;
  }

  &::placeholder {
    color: var(--black_400, #9ca3af);
  }
}

#antimanualsend {
  width: 35px;
  min-width: 35px;
  height: 35px;
  padding: 10px;
  border-radius: 50%;
  background-color: var(--antimanual_primary_color);
  display: flex;
  justify-content: center;
  align-items: center;
  border: none;
  color: var(--antimanual_white_color);
  cursor: pointer;
  transition: color 0.2s ease;
  flex-shrink: 0;

  &:hover:not(:disabled) {
    transform: none;
    opacity: 1;
  }

  &:active:not(:disabled) {
    transform: scale(0.95);
  }

  &:disabled {
    opacity: 0.5;
    cursor: default;
    color: #cbd5e1;
  }
  
  svg {
    width: 20px;
    height: 20px;
  }
}

/* Character Counter */
.antimanual-char-counter {
  position: absolute;
  right: 70px;
  bottom: 20px;
  font-size: 12px;
  color: var(--black_500, #6b7280);
  pointer-events: none;
  transition: color 0.2s ease;

  &.warning {
    color: #f59e0b;
  }

  &.limit {
    color: #ef4444;
  }
}

/* ================================================
   HELP BUTTON
   ================================================ */

button#antimanual-help-button {
  position: fixed;
  right: 25px;
  bottom: 25px;
  background-color: var(--antimanual_primary_color);
  color: var(--antimanual_white_color);
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  box-shadow: rgba(9, 14, 21, 0.16) 0 5px 40px 0;
  z-index: 9999;
  border: 0;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;

  div {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
  }

  #help-icon .antimanual-icon {
    width: 18px;
  }

  #close-icon {
    display: none;

    .antimanual-icon {
      width: 16px;
    }
  }

  /* Hide text label by default for icon-only style */
  .antimanual-help-btn-label {
    display: none !important;
  }

  &:hover {
    transform: scale(1.08);
    box-shadow: rgba(9, 14, 21, 0.22) 0 8px 50px 0;
  }

  &:active {
    transform: scale(0.95);
  }

  &.pulse {
    animation: antimanual-pulse 2s infinite;
  }
}

button#antimanual-help-button-sm {
  display: flex;
  background: var(--black_700);
  position: fixed;
  top: -30px;
  right: 4px;
  border: none;
  outline: none;
  border-radius: 50px;
  padding: 4px 8px;
  color: var(--black_150);
  align-items: center;
  gap: 4px;
  font-size: 12px;
  transition: top 0.3s ease;
  z-index: 999;
  line-height: 0;

  .antimanual_arrow_down_icon {
    width: 12px;
  }
}

/* ================================================
   TYPING INDICATOR
   ================================================ */

.antimanual-typing-indicator {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #f5f7fb 0%, #eef2ff 100%);
  border-radius: 16px 16px 16px 4px;
  width: fit-content;
  overflow: hidden;
  font-size: 13px;
  color: var(--black_600);
  line-height: 1.2;

  /* Sweeping shimmer band — gives the pill a soft "alive" feel */
  .atml-thinking-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(
      100deg,
      transparent 20%,
      rgba(99, 102, 241, 0.12) 50%,
      transparent 80%
    );
    transform: translateX(-100%);
    animation: atml-thinking-shimmer 2.4s ease-in-out infinite;
    pointer-events: none;
  }

  /* Stacked phrase carousel — each child fades in on its own slice of the
     timeline so the same height stays reserved (no jumping). */
  .atml-thinking-text {
    position: relative;
    display: inline-block;
    height: 1.2em;
    min-width: 9.5em;
    overflow: hidden;
    font-weight: 500;

    > span {
      position: absolute;
      inset: 0;
      opacity: 0;
      transform: translateY(6px);
      animation: atml-thinking-phrase 7.2s infinite;
      background: linear-gradient(90deg, var(--antimanual_primary_color, #2563eb), #818cf8);
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
      white-space: nowrap;

      &:nth-child(1) { animation-delay: 0s; }
      &:nth-child(2) { animation-delay: 1.8s; }
      &:nth-child(3) { animation-delay: 3.6s; }
      &:nth-child(4) { animation-delay: 5.4s; }
    }
  }

  /* Trailing dot trio — small, bouncy, matches the verb */
  .atml-thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 2px;

    i {
      width: 5px;
      height: 5px;
      border-radius: 50%;
      background: var(--antimanual_primary_color, #6366f1);
      animation: atml-thinking-bounce 1.2s ease-in-out infinite;

      &:nth-child(1) { animation-delay: 0s; }
      &:nth-child(2) { animation-delay: 0.15s; }
      &:nth-child(3) { animation-delay: 0.3s; }
    }
  }
}

@keyframes atml-thinking-shimmer {
  0%   { transform: translateX(-100%); }
  60%  { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

@keyframes atml-thinking-phrase {
  0%, 2%     { opacity: 0; transform: translateY(6px); }
  6%, 22%    { opacity: 1; transform: translateY(0); }
  26%, 100%  { opacity: 0; transform: translateY(-6px); }
}

@keyframes atml-thinking-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40%           { transform: translateY(-4px); opacity: 1; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .antimanual-typing-indicator {
    .atml-thinking-shimmer,
    .atml-thinking-text > span,
    .atml-thinking-dots i { animation: none; }
    .atml-thinking-text > span:first-child { opacity: 1; transform: none; }
    .atml-thinking-dots i { opacity: 0.7; }
  }
}

/* Loading Dots (legacy) */
.antimanual-loading-dots {
  display: inline-block;
  margin: 0;
}

.antimanual-dot {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  width: 12px;
  height: 12px;
  background-color: var(--black_400);
  border-radius: 50%;
  opacity: 0;
  animation: antimanual-dot-blink 1s infinite ease-in-out;

  &:nth-child(1) { animation-delay: 0s; }
  &:nth-child(2) { animation-delay: 0.33s; }
  &:nth-child(3) { animation-delay: 0.66s; }
}

/* ================================================
   LEAD COLLECTION FORM
   ================================================ */

.antimanual-lead-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: var(--bs-white);
  border-radius: 12px;
  margin-top: 20px;
  border: 1px solid var(--black_75);

  .lead-prompt {
    font-size: 14px;
    color: var(--black_700);
    margin: 0;
    line-height: 1.5;
    text-align: center;
  }

  .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .form-group--floating {
    position: relative;

    input {
      padding-top: 14px;
      padding-bottom: 14px;
    }

    label {
      position: absolute;
      top: 50%;
      left: 14px;
      transform: translateY(-50%);
      font-size: 14px;
      color: var(--black_700);
      pointer-events: none;
      background: transparent;
      padding: 0 4px;
      transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease, transform 0.15s ease;
    }

    input:focus + label,
    input:not(:placeholder-shown) + label {
      top: 0;
      transform: translateY(-50%) scale(0.85);
      transform-origin: left center;
      background: var(--bs-white);
      color: var(--antimanual_primary_color);
    }
  }

  input {
    padding: 12px 14px;
    border: 1px solid var(--black_100);
    border-radius: 10px;
    font-size: 14px;
    width: 100%;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;

    &:focus {
      border-color: var(--antimanual_primary_color);
    }
  }

  .lead-submit-btn {
    padding: 12px 16px;
    background: var(--antimanual_primary_color);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-top: 8px;

    &:hover {
      opacity: 0.9;
    }

    &:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }
  }
}

/* Footer hidden state — used when lead form is active. */
.antimanual-footer-hidden {
  display: none !important;
}
