/* ==========================================================================
   ARS ADVOCATS I ASSESSORS — ASSISTENT LEGAL (CHATBOT WIDGET)
   Editorial Luxury Styling matching styles.css tokens
   ========================================================================== */

.ars-chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 24px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: 0 20px 0 16px;
  background: linear-gradient(135deg, #1c1314 0%, #3a0b0e 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 9999px;
  font-family: var(--font-sans, "Plus Jakarta Sans", sans-serif);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(28, 19, 20, 0.28);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease,
              background 0.25s ease,
              opacity 0.2s ease;
}

/* Position WhatsApp neatly above the primary Assistent Legal pill */
.whatsapp-float {
  bottom: 90px;
  right: 24px;
}

.ars-chat-launcher:hover {
  transform: translateY(-2px) scale(1.02);
  background: linear-gradient(135deg, #2a1719 0%, #7a070c 100%);
  box-shadow: 0 14px 34px rgba(122, 7, 12, 0.34);
}

.ars-chat-launcher:focus-visible {
  outline: 2px solid var(--accent-primary, #c10c13);
  outline-offset: 3px;
}

.ars-chat-launcher.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.92);
}

.ars-chat-launcher-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.ars-chat-live-dot {
  position: absolute;
  top: -1px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  border: 1.5px solid #1c1314;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  animation: arsLivePulse 3.6s ease-out infinite;
}

@keyframes arsLivePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  }
  55% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.ars-chat-launcher-label-short {
  display: none;
}

/* Chat Panel */
.ars-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1200;
  width: 400px;
  max-width: calc(100vw - 24px);
  height: 590px;
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface, #ffffff);
  border: 1px solid rgba(40, 20, 20, 0.14);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(28, 19, 20, 0.22), 0 4px 16px rgba(28, 19, 20, 0.08);
  overflow: hidden;
  font-family: var(--font-sans, "Plus Jakarta Sans", sans-serif);
  opacity: 0;
  transform: translateY(18px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.ars-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.ars-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #1c1314 0%, #540307 100%);
  color: #ffffff;
  flex-shrink: 0;
}

.ars-chat-header-info {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.ars-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  flex-shrink: 0;
}

.ars-chat-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.ars-chat-title-wrap {
  min-width: 0;
}

.ars-chat-title {
  margin: 0;
  font-family: var(--font-sans, "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: #ffffff;
}

.ars-chat-subtitle {
  margin: 2px 0 0;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.78);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ars-chat-subtitle::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}

.ars-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ars-chat-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.ars-chat-icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

/* Disclaimer strip */
.ars-chat-disclaimer {
  padding: 8px 16px;
  background: var(--bg-darker, #f5eeed);
  border-bottom: 1px solid var(--border-subtle, rgba(40, 20, 20, 0.08));
  font-size: 0.71rem;
  line-height: 1.35;
  color: var(--text-muted, #6e6061);
  flex-shrink: 0;
}

/* Messages area */
.ars-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-cream, #fbf7f6);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.ars-chat-msg {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.52;
  word-wrap: break-word;
  animation: arsChatFadeIn 0.22s ease;
}

@keyframes arsChatFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ars-chat-msg--assistant {
  align-self: flex-start;
  background: #ffffff;
  color: var(--text-main, #1c1314);
  border: 1px solid rgba(40, 20, 20, 0.09);
  border-left: 3px solid var(--accent-primary, #c10c13);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(40, 10, 15, 0.04);
}

.ars-chat-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #7a070c 0%, #540307 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 10px rgba(84, 3, 7, 0.18);
}

.ars-chat-msg--error {
  align-self: flex-start;
  background: #fff5f5;
  color: #7a070c;
  border: 1px solid rgba(193, 12, 19, 0.25);
  font-size: 0.82rem;
}

.ars-chat-msg strong {
  font-weight: 600;
}

/* Typing dots */
.ars-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
}

.ars-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary, #c10c13);
  opacity: 0.4;
  animation: arsChatBounce 1.2s infinite ease-in-out;
}

.ars-chat-typing span:nth-child(2) {
  animation-delay: 0.18s;
}

.ars-chat-typing span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes arsChatBounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* Quick suggestion chips */
.ars-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}

.ars-chat-chip {
  background: #ffffff;
  color: var(--text-main, #1c1314);
  border: 1px solid rgba(193, 12, 19, 0.24);
  border-radius: 9999px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 0.77rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.ars-chat-chip:hover {
  background: var(--accent-primary, #c10c13);
  color: #ffffff;
  border-color: var(--accent-primary, #c10c13);
}

/* Conversion handoff bar */
.ars-chat-handoff {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: #ffffff;
  border-top: 1px solid var(--border-subtle, rgba(40, 20, 20, 0.08));
  flex-shrink: 0;
}

.ars-chat-handoff-btn {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 8px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ars-chat-handoff-btn--form {
  background: var(--bg-darker, #f5eeed);
  color: var(--text-main, #1c1314);
  border: 1px solid rgba(40, 20, 20, 0.12);
}

.ars-chat-handoff-btn--form:hover {
  background: var(--accent-primary, #c10c13);
  color: #ffffff;
  border-color: var(--accent-primary, #c10c13);
}

.ars-chat-handoff-btn--wa {
  background: var(--accent-primary, #c10c13);
  color: #ffffff;
  border: 1px solid var(--accent-primary, #c10c13);
}

.ars-chat-handoff-btn--wa:hover {
  background: var(--accent-hover, #9e0a10);
  border-color: var(--accent-hover, #9e0a10);
  color: #ffffff;
}

/* Composer */
.ars-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 11px 12px;
  background: #ffffff;
  border-top: 1px solid var(--border-subtle, rgba(40, 20, 20, 0.1));
  flex-shrink: 0;
}

.ars-chat-input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  resize: none;
  border: 1px solid var(--input-border, rgba(40, 20, 20, 0.16));
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text-main, #1c1314);
  background: var(--bg-cream, #fbf7f6);
  max-height: 96px;
  min-height: 40px;
  overflow-y: hidden;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.ars-chat-input::placeholder {
  color: var(--text-muted, #6e6061);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ars-chat-input:focus {
  background: #ffffff;
  border-color: var(--accent-primary, #c10c13);
  box-shadow: 0 0 0 3px rgba(193, 12, 19, 0.12);
}

.ars-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--accent-primary, #c10c13);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
}

.ars-chat-send:hover:not(:disabled) {
  background: var(--accent-hover, #9e0a10);
  transform: translateY(-1px);
}

.ars-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Mobile adjustments */
@media (max-width: 540px) {
  .ars-chat-launcher {
    width: auto;
    height: 46px;
    padding: 0 16px 0 13px;
    gap: 8px;
    font-size: 0.84rem;
    justify-content: center;
    bottom: 20px;
    right: 16px;
    border-color: rgba(255, 255, 255, 0.34);
    box-shadow: 0 10px 26px rgba(28, 19, 20, 0.34);
  }

  .whatsapp-float {
    bottom: 78px;
    right: 16px;
  }

  .ars-chat-launcher-label-full {
    display: none;
  }

  .ars-chat-launcher-label-short {
    display: inline;
  }

  .ars-chat-panel {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    height: 78dvh;
    max-height: calc(100dvh - 24px);
  }

  .ars-chat-input {
    font-size: 16px;
    line-height: 1.35;
    padding: 9px 12px;
    min-height: 42px;
  }

  .ars-chat-input::placeholder {
    font-size: 0.9rem;
  }

  .ars-chat-send {
    width: 42px;
    height: 42px;
  }

  .ars-chat-handoff {
    gap: 6px;
    padding: 8px 10px;
  }

  .ars-chat-handoff-btn {
    font-size: clamp(0.66rem, 3.1vw, 0.74rem);
    padding: 8px 6px;
  }
}
