:root {
  --chat-surface: #ffffff;
  --chat-surface-alt: #f5f8fb;
  --chat-border: rgba(8, 26, 57, 0.12);
  --chat-shadow: 0 22px 55px rgba(6, 19, 40, 0.18);
  --chat-primary: var(--color-primary, #0c2340);
  --chat-accent: var(--color-secondary, #008e6e);
  --chat-muted: #5a6472;
}

.ai-chat-widget {
  position: fixed;
  inset: auto 1.5rem 1.5rem auto;
  z-index: 1400;
  isolation: isolate;
  font-family: 'Lato', sans-serif;
}

.ai-chat-widget[data-open="true"] .ai-chat-launcher {
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
}

.ai-chat-launcher {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 12px 25px rgba(5, 16, 32, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-chat-launcher:focus-visible {
  outline: 3px solid rgba(0, 95, 163, 0.35);
  outline-offset: 4px;
}

.ai-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(5, 16, 32, 0.3);
}

.ai-chat-launcher-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 6px 20px rgba(5, 16, 32, 0.2);
}


.ai-chat-launcher-label {
  position: absolute;
  top: 50%;
  right: calc(100% + 0.75rem);
  transform: translateY(-50%) translateX(-6px);
  background: var(--chat-surface);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--chat-border);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
  font-size: 0.85rem;
  color: var(--chat-muted);
  text-align: right;
  opacity: 0;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-chat-widget[data-show-label="true"] .ai-chat-launcher-label {
  opacity: 1;
  transform: translateY(-50%);
}

.ai-chat-panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: min(340px, calc(100vw - 2rem));
  background: var(--chat-surface);
  border-radius: 22px;
  border: 1px solid var(--chat-border);
  box-shadow: var(--chat-shadow);
  transform-origin: 100% 100%;
  transform: translateY(12px) scale(0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-chat-panel[data-open="true"] {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.ai-chat-header {
  background: linear-gradient(140deg, rgba(12, 35, 64, 0.98), rgba(0, 142, 110, 0.95));
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: #fff;
}

.ai-chat-header img {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.45);
}

.ai-chat-header-info h4 {
  font-size: 1rem;
  margin-bottom: 0.15rem;
  color: #fff;
}

.ai-chat-header-info span {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
}

.ai-chat-close {
  margin-left: auto;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.ai-chat-close span {
  font-size: 1.1rem;
  line-height: 1;
}

.ai-chat-close:hover,
.ai-chat-close:focus-visible {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.ai-chat-messages {
  background: var(--chat-surface-alt);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 320px;
  overflow-y: auto;
}

.ai-chat-message {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  animation: chat-message-in 0.35s ease forwards;
}

.ai-chat-message .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.ai-chat-bubble {
  background: #fff;
  border-radius: 16px;
  padding: 0.65rem 0.9rem;
  font-size: 0.93rem;
  line-height: 1.4;
  color: var(--chat-muted);
  box-shadow: 0 12px 25px rgba(15, 30, 45, 0.08);
}

.ai-chat-bubble p {
  margin: 0;
}

.ai-chat-message.agent .ai-chat-bubble {
  background: #fff;
  border-bottom-left-radius: 6px;
  color: var(--chat-primary);
}

.ai-chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.ai-chat-actions button {
  border: 1px solid var(--chat-border);
  background: #fff;
  color: var(--chat-primary);
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.ai-chat-actions button:hover:not(:disabled) {
  background: var(--chat-surface-alt);
}

.ai-chat-actions button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.ai-chat-message.user {
  justify-content: flex-end;
}

.ai-chat-message.user .ai-chat-bubble {
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
  color: #fff;
  border-bottom-right-radius: 6px;
}

.ai-chat-message.user .avatar {
  display: none;
}

.ai-chat-message.user .ai-chat-meta {
  color: rgba(255, 255, 255, 0.8);
}

.ai-chat-meta {
  font-size: 0.75rem;
  margin-top: 0.3rem;
  color: var(--chat-muted);
}

.ai-chat-composer {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-chat-input {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--chat-border);
  border-radius: 18px;
  padding: 0.3rem 0.3rem 0.3rem 0.65rem;
  background: #fff;
}

.ai-chat-input textarea {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--chat-primary);
  line-height: 1.4;
  min-height: 1.4rem;
  padding: 0.2rem 0 0.2rem 0;
  max-height: 200px;
  overflow-y: hidden;
}

.ai-chat-input textarea.is-scrollable {
  overflow-y: auto;
}

.ai-chat-input textarea:disabled {
  color: var(--chat-muted);
}

.ai-chat-send {
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.ai-chat-send svg {
  width: 20px;
  height: 20px;
}

.ai-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-chat-send:not(:disabled):hover {
  transform: translateY(-1px);
}

.ai-chat-unavailable {
  margin-top: 0.5rem;
  text-align: center;
}

.ai-chat-ticket-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 20px rgba(12, 35, 64, 0.2);
}

.ai-chat-ticket-link:hover {
  opacity: 0.9;
}

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

.ai-chat-hint {
  font-size: 0.78rem;
  color: var(--chat-muted);
  text-align: center;
}

@keyframes chat-message-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .ai-chat-widget {
    inset: auto 1rem 1rem auto;
  }
  .ai-chat-panel {
    width: min(320px, calc(100vw - 1.25rem));
    border-radius: 18px;
  }

  .ai-chat-launcher-label {
    top: auto;
    bottom: 80px;
    right: 0;
    transform: translateY(6px);
    max-width: 180px;
    text-align: left;
  }

  .ai-chat-widget[data-show-label="true"] .ai-chat-launcher-label {
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-chat-launcher,
  .ai-chat-panel,
  .ai-chat-message {
    transition: none;
    animation: none;
  }
}
