/* ==========================================================================
   NRAT AI Chat Widget
   ========================================================================== */

.nrat-ai-chat {
  position: fixed;
  left: 20px;
  bottom: 0;
  z-index: 899;
  font-family: var(--scc-font-main, inherit);
}

/* ==========================================================================
   Overlay
   ========================================================================== */

.nrat-ai-chat__overlay {
  position: fixed;
  inset: 0;
  z-index: 898;
  visibility: hidden;
  opacity: 0;
  background-color: rgba(0, 0, 0, 0.45);
  transition:
    opacity var(--scc-transition-fast, 0.2s ease),
    visibility var(--scc-transition-fast, 0.2s ease);
}

.nrat-ai-chat[data-open='true'] .nrat-ai-chat__overlay {
  visibility: visible;
  opacity: 1;
}

/* ==========================================================================
   Toggle button
   ========================================================================== */

.nrat-ai-chat__toggle {
  display: inline-flex;
  position: relative;
  z-index: 900;
  align-items: center;
  min-height: 58px;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: #000;
  background: transparent;
  box-shadow: none;
  font-size: var(--scc-font-size-sm, 0.875rem);
  line-height: var(--scc-line-height-sm, 1.25);
  cursor: pointer;
}

.nrat-ai-chat__toggle:hover,
.nrat-ai-chat__toggle:focus,
.nrat-ai-chat__toggle:active,
.nrat-ai-chat__toggle:focus-visible {
  color: #000;
  background: transparent;
  outline: none;
  box-shadow: none;
}

.nrat-ai-chat__toggle:focus-visible {
  outline: 3px solid var(--scc-color-primary-dark, #369);
  outline-offset: 4px;
  border-radius: 999px;
}

.nrat-ai-chat .nrat-ai-chat__toggle,
.nrat-ai-chat .nrat-ai-chat__toggle:hover,
.nrat-ai-chat .nrat-ai-chat__toggle:focus,
.nrat-ai-chat .nrat-ai-chat__toggle:active,
.nrat-ai-chat .nrat-ai-chat__toggle:focus-visible {
  border-radius: 999px;
}

.nrat-ai-chat__toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
}

.nrat-ai-chat__toggle-icon img {
  display: block;
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.nrat-ai-chat__toggle-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 22px;
  border-radius: 999px;
  color: #000;
  background-color: #f5b800;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  box-shadow: var(--scc-shadow-base, 0 0 10px 1px rgba(0, 0, 0, 0.2));
  transition:
    color var(--scc-transition-fast, 0.2s ease),
    background-color var(--scc-transition-fast, 0.2s ease);
}

.nrat-ai-chat__toggle:hover .nrat-ai-chat__toggle-text,
.nrat-ai-chat__toggle:focus-visible .nrat-ai-chat__toggle-text {
  color: #000;
  background-color: #e6ab00;
}

/* ==========================================================================
   Window
   ========================================================================== */

.nrat-ai-chat__window {
  position: absolute;
  z-index: 900;
  left: 0;
  bottom: 100px;
  display: flex;
  flex-direction: column;
  width: 480px;
  max-width: calc(100vw - 32px);
  height: min(600px, calc(100vh - 120px));
  max-height: calc(100vh - 120px);
  overflow: hidden;
  border: 1px solid var(--scc-color-border-light, #e5e7eb);
  border-radius: 16px;
  background-color: var(--scc-color-light, #fff);
  box-shadow: var(--scc-shadow-base, 0 0 10px 1px rgba(0, 0, 0, 0.2));
}

.nrat-ai-chat__window[hidden] {
  display: none;
}

/* ==========================================================================
   Header
   ========================================================================== */

.nrat-ai-chat__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  color: var(--scc-color-light, #fff);
  background-color: var(--scc-color-primary, #367abb);
  border-bottom: 1px solid var(--scc-color-primary, #367abb);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.18);
}

.nrat-ai-chat__title {
  margin: 0 0 4px;
  color: var(--scc-color-light, #fff);
  font-size: var(--scc-font-size-md, 1.125rem);
  font-weight: var(--scc-font-weight-medium, 500);
  line-height: var(--scc-line-height-sm, 1.25);
}

.nrat-ai-chat__subtitle {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--scc-font-size-xs, 0.75rem);
  line-height: var(--scc-line-height-base, 1.5);
}

.nrat-ai-chat__actions {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.nrat-ai-chat__fullscreen,
.nrat-ai-chat__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  color: var(--scc-color-light, #fff);
  background-color: transparent;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition:
    color var(--scc-transition-fast, 0.2s ease),
    background-color var(--scc-transition-fast, 0.2s ease);
}

.nrat-ai-chat__fullscreen:hover,
.nrat-ai-chat__fullscreen:focus-visible,
.nrat-ai-chat__close:hover,
.nrat-ai-chat__close:focus-visible {
  color: var(--scc-color-light, #fff);
  background-color: var(--scc-color-primary-dark, #369);
  outline: none;
}

.nrat-ai-chat__fullscreen i,
.nrat-ai-chat__close i {
  line-height: 1;
}

/* ==========================================================================
   Loader
   ========================================================================== */

.nrat-ai-chat__message_loader {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nrat-ai-chat__loader-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
}

.nrat-ai-chat__loader-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: currentColor;
  opacity: 0.35;
  animation: nrat-ai-loader-dot 1.2s infinite ease-in-out;
}

.nrat-ai-chat__loader-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.nrat-ai-chat__loader-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes nrat-ai-loader-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ==========================================================================
   Messages
   ========================================================================== */

.nrat-ai-chat__messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  height: 260px;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background-color: var(--scc-color-bg-light, #fafafa);
}

.nrat-ai-chat__message {
  max-width: 85%;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: var(--scc-font-size-sm, 0.875rem);
  line-height: var(--scc-line-height-base, 1.5);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  text-align: left;
}

.nrat-ai-chat__message_bot {
  align-self: flex-start;
  color: var(--scc-color-text, #212529);
  background-color: var(--scc-color-light, #fff);
  border: 1px solid var(--scc-color-border-light, #e5e7eb);
}

.nrat-ai-chat__message_user {
  align-self: flex-end;
  color: var(--scc-color-light, #fff);
  background-color: var(--scc-color-primary, #367abb);
}

.nrat-ai-chat__message_error {
  align-self: flex-start;
  color: var(--scc-color-danger, #dc3545);
  background-color: #fff0f0;
  border: 1px solid #f0b8b8;
}

.nrat-ai-chat__message_bot,
.nrat-ai-chat__message_user,
.nrat-ai-chat__message_error {
  text-align: left;
}

/* Typing cursor */

.nrat-ai-chat__message_typing::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -2px;
  background-color: currentColor;
  animation: nrat-ai-chat-cursor 0.8s steps(1) infinite;
}

@keyframes nrat-ai-chat-cursor {
  0%,
  50% {
    opacity: 1;
  }

  51%,
  100% {
    opacity: 0;
  }
}

/* ==========================================================================
   Quick questions
   ========================================================================== */

.nrat-ai-chat__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--scc-color-border-light, #e5e7eb);
  background-color: var(--scc-color-light, #fff);
}

.nrat-ai-chat__quick button {
  border: 1px solid var(--scc-color-primary-soft, #cce5ff);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--scc-color-primary, #367abb);
  background-color: var(--scc-color-primary-light, #f0f7fe);
  font-size: var(--scc-font-size-xs, 0.75rem);
  line-height: var(--scc-line-height-sm, 1.25);
  cursor: pointer;
  transition:
    color var(--scc-transition-fast, 0.2s ease),
    background-color var(--scc-transition-fast, 0.2s ease),
    border-color var(--scc-transition-fast, 0.2s ease);
}

.nrat-ai-chat__quick button:hover,
.nrat-ai-chat__quick button:focus,
.nrat-ai-chat__quick button:active,
.nrat-ai-chat__quick button:focus-visible {
  border-radius: 999px;
  color: var(--scc-color-light, #fff);
  background-color: var(--scc-color-primary-dark, #369);
  border-color: var(--scc-color-primary-dark, #369);
  outline: none;
  box-shadow: none;
}

.nrat-ai-chat__quick button:focus-visible {
  box-shadow: 0 0 0 3px rgba(51, 102, 153, 0.35);
}

/* ==========================================================================
   Form
   ========================================================================== */

.nrat-ai-chat__form {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--scc-color-border-light, #e5e7eb);
  background-color: var(--scc-color-light, #fff);
}

.nrat-ai-chat__input {
  flex: 1 1 auto;
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  border: 1px solid var(--scc-color-border, #ccc);
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--scc-color-text, #212529);
  background-color: var(--scc-color-light, #fff);
  font-family: var(--scc-font-main, inherit);
  font-size: var(--scc-font-size-sm, 0.875rem);
  line-height: var(--scc-line-height-base, 1.5);
}

.nrat-ai-chat__input::placeholder {
  color: var(--scc-color-placeholder, #999);
}

.nrat-ai-chat__input:disabled {
  background-color: var(--scc-color-bg-muted, #eee);
  cursor: not-allowed;
}

.nrat-ai-chat__send {
  flex: 0 0 auto;
  align-self: flex-start;
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  color: var(--scc-color-light, #fff);
  background-color: var(--scc-color-primary, #367abb);
  font-size: var(--scc-font-size-sm, 0.875rem);
  font-weight: var(--scc-font-weight-semibold, 600);
  line-height: var(--scc-line-height-sm, 1.25);
  cursor: pointer;
  transition:
    background-color var(--scc-transition-fast, 0.2s ease),
    color var(--scc-transition-fast, 0.2s ease);
}

.nrat-ai-chat__send:hover {
  background-color: var(--scc-color-primary-dark, #369);
  outline: none;
}

.nrat-ai-chat__send:focus-visible {
  background-color: var(--scc-color-primary-dark, #369);
  outline: 2px solid var(--scc-color-primary-dark, #369);
  outline-offset: 2px;
}

.nrat-ai-chat__send:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

/* ==========================================================================
   Fullscreen mode
   ========================================================================== */

.nrat-ai-chat.nrat-ai-chat_fullscreen {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 899;
}

.nrat-ai-chat.nrat-ai-chat_fullscreen .nrat-ai-chat__toggle {
  display: none;
}

.nrat-ai-chat.nrat-ai-chat_fullscreen .nrat-ai-chat__window {
  position: fixed;
  top: 20px;
  right: 20px;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  border-radius: 16px;
}

.nrat-ai-chat.nrat-ai-chat_fullscreen .nrat-ai-chat__messages {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

/* ==========================================================================
   Focus and radius fixes
   ========================================================================== */

.nrat-ai-chat button,
.nrat-ai-chat button:hover,
.nrat-ai-chat button:focus,
.nrat-ai-chat button:active,
.nrat-ai-chat button:focus-visible {
  outline-offset: 3px;
}

/* Toggle button — pill shape */

.nrat-ai-chat .nrat-ai-chat__toggle,
.nrat-ai-chat .nrat-ai-chat__toggle:hover,
.nrat-ai-chat .nrat-ai-chat__toggle:focus,
.nrat-ai-chat .nrat-ai-chat__toggle:active,
.nrat-ai-chat .nrat-ai-chat__toggle:focus-visible {
  border-radius: 999px;
}

/* Quick question buttons — pill shape */

.nrat-ai-chat .nrat-ai-chat__quick button,
.nrat-ai-chat .nrat-ai-chat__quick button:hover,
.nrat-ai-chat .nrat-ai-chat__quick button:focus,
.nrat-ai-chat .nrat-ai-chat__quick button:active,
.nrat-ai-chat .nrat-ai-chat__quick button:focus-visible {
  border-radius: 999px;
}

/* Send button — pill shape */

.nrat-ai-chat .nrat-ai-chat__send,
.nrat-ai-chat .nrat-ai-chat__send:hover,
.nrat-ai-chat .nrat-ai-chat__send:focus,
.nrat-ai-chat .nrat-ai-chat__send:active,
.nrat-ai-chat .nrat-ai-chat__send:focus-visible {
  border-radius: 999px;
}

/* Header icon buttons — circular shape */

.nrat-ai-chat .nrat-ai-chat__fullscreen,
.nrat-ai-chat .nrat-ai-chat__fullscreen:hover,
.nrat-ai-chat .nrat-ai-chat__fullscreen:focus,
.nrat-ai-chat .nrat-ai-chat__fullscreen:active,
.nrat-ai-chat .nrat-ai-chat__fullscreen:focus-visible,
.nrat-ai-chat .nrat-ai-chat__close,
.nrat-ai-chat .nrat-ai-chat__close:hover,
.nrat-ai-chat .nrat-ai-chat__close:focus,
.nrat-ai-chat .nrat-ai-chat__close:active,
.nrat-ai-chat .nrat-ai-chat__close:focus-visible {
  border-radius: 50%;
}

/* ==========================================================================
   Screen reader
   ========================================================================== */

.screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ==========================================================================
   Mobile
   ========================================================================== */

@media (max-width: 767px) {
  .nrat-ai-chat__toggle-text {
    display: none;
  }

  .nrat-ai-chat__toggle {
    min-height: 80px;
  }

  .nrat-ai-chat__toggle-icon img {
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 480px) {
  .nrat-ai-chat {
    right: 16px;
    bottom: 16px;
    left: 16px;
  }

  .nrat-ai-chat__toggle {
    margin-right: auto;
  }

  .nrat-ai-chat__window {
    right: 0;
    left: 0;
    bottom: 90px;
    width: auto;
    max-width: none;
  }

  .nrat-ai-chat__messages {
    height: 300px;
  }

  .nrat-ai-chat__form {
    flex-direction: column;
  }

  .nrat-ai-chat__send {
    width: 100%;
  }

  .nrat-ai-chat.nrat-ai-chat_fullscreen .nrat-ai-chat__window {
    top: 8px;
    right: 8px;
    bottom: 8px;
    left: 8px;
    border-radius: 12px;
  }
}
