
/*
 * Summary:
 * - Reorganized chat widget styles into logical sections with consistent spacing.
 * - Added succinct comments and removed duplicate keyframes while keeping behavior intact.
 * - Normalized two-space indentation to improve readability for junior developers.
 */

/* === Base Typography === */
.BrfAssistAI,
.BrfAssistAI * {
  font-family: "Aptos", Arial, sans-serif;
}

/* === Scoped Default Resets === */
.BrfAssistAI p {
  margin: 1em 0;
  padding: 0;
  color: inherit;
}

.BrfAssistAI .message-content p {
  line-height: 1.5;
}

.BrfAssistAI .message-content mark {
  background: #fff59d;
  color: inherit;
}

.BrfAssistAI ul,
.BrfAssistAI ol {
  margin: 1em 0 1em 1.25em;
  padding: 0;
}

.BrfAssistAI li {
  margin: 0.25em 0;
  padding: 0;
}



/* === Minimized Entry States === */
.BrfAssistAI .chat-icon-minimized {
  position: fixed;
  bottom: 65px;
  right: 30px;
  background: transparent;
  border: none;
  border-radius: 12px;
  padding: 20px 37px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: auto;
  z-index: 1000;
}

.BrfAssistAI .minimized-input {
  /* Keep widget sizing stable even when host app globally forces border-box. */
  box-sizing: content-box;
  border: 2px solid #0e2841;
  background: #fff;
  border-radius: 10px;
  padding: 4px 12px;
  font-size: 0.95em;
  /* Prevent host CSS from shrinking input metrics via inherited line-height. */
  line-height: normal;
  color: #7f7f7f;
  width: 175px;
  font-weight: 500;
  pointer-events: auto;
  margin: 0;
  height: 18px;
  background-image: url("/Common/Images/Assistant.AI/Paper-plane.png");
  background-repeat: no-repeat;
  background-size: 30px 25px;
  background-position: 128px 50%;
}

.BrfAssistAI .minimized-input::placeholder {
  color: #7f7f7f;
}

.BrfAssistAI .minimized-send {
  display: none;
}

.BrfAssistAI .minimized-b-icon-container {
  position: absolute;
  right: -10px;
  bottom: -22px;
  display: block;
  pointer-events: auto;
  z-index: 3;
}

.BrfAssistAI .minimized-b-icon {
  width: 90px;
  height: 95px;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.28));
  pointer-events: none;
}

.BrfAssistAI .minimize-x {
  position: absolute;
  top: -23px;
  right: 13px;
  background: transparent;
  border: none;
  border-radius: 0;
  color: #000;
  cursor: pointer;
  box-shadow: none;
  display: block;
  z-index: 4;
  padding: 0;
  line-height: 1;
  font-size: 30px;
  pointer-events: auto;
}

.BrfAssistAI .chat-icon-further-min {
  position: fixed;
  bottom: 43px;
  right: 28px;
  z-index: 1000;
  cursor: pointer;
}

.BrfAssistAI .chat-icon-further-min img {
  width: 85px;
  height: 85px;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.28));
}

/* === Chat Window Shell === */
.BrfAssistAI .chat-window {
  position: fixed;
  bottom: 65px;
  right: 30px;
  width: 370px;
  max-width: 95vw;
  height: 540px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  z-index: 1001;
  transition: opacity 0.2s;
  overflow: hidden;
  resize: both;
  min-width: 320px;
  min-height: 360px;
  max-height: 90vh;
  max-width: 95vw;
}

.BrfAssistAI .hidden {
  display: none;
}

.BrfAssistAI .reply-anchor {
  height: 1px;
  scroll-margin-top: 12px;
}

/* === Header & Controls === */
.BrfAssistAI .chat-header {
  display: flex;
  align-items: flex-start;
  padding: 12px 16px;
  background: linear-gradient(90deg, #1a2a4a 90%, #2d3e6b 100%);
  color: #fff;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: relative;
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.BrfAssistAI .header-icon {
  width: 40px;
  height: 40px;
  margin-right: 10px;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8))
    drop-shadow(0 0 5px rgba(140, 170, 255, 0.6))
    drop-shadow(0 0 10px rgba(53, 116, 240, 0.5));
  will-change: filter;
}

.BrfAssistAI .header-title {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
  padding-top: 1px;
}

.BrfAssistAI .header-subrow {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 0;
}

.BrfAssistAI .header-chat-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  opacity: 0.96;
}

.BrfAssistAI .briefing-title {
  font-weight: bold;
  font-size: 1.08em;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  line-height: 1.2;
}

.BrfAssistAI .beta-tag {
  background: #fff;
  color: #1a2a4a;
  font-size: 0.7em;
  font-weight: bold;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  margin-top: 2px;
  display: inline-block;
}

.BrfAssistAI .beta-tag-img {
  height: 25px;
  width: auto;
  vertical-align: middle;
  display: inline-block;
}

.BrfAssistAI .subtitle {
  font-size: 1.1em;
  color: #cfd8e3;
  margin-top: 2px;
  line-height: 1.2;
}

.BrfAssistAI .new-chat-btn {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    background: transparent;
    /* Keep New Chat text the same color as the Briefing Booster title. */
    color: #fff;
    border: none;
    border-radius: 0;
    padding: 2px 6px;
    font-size: 1.10em;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
}

.BrfAssistAI .new-chat-btn:hover {
  background: transparent;
  text-decoration: underline;
}

.BrfAssistAI #close-chat {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.6em;
  cursor: pointer;
  margin-left: 8px;
  margin-top: -6px;
}

.BrfAssistAI .header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: -6px;
}

.BrfAssistAI .header-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 0 0 0;
  vertical-align: middle;
}

.BrfAssistAI .header-btn:last-child {
  position: relative;
  top: 2px;
}

.BrfAssistAI .header-btn:hover {
  opacity: 0.9;
}

.BrfAssistAI .header-btn:active {
  opacity: 0.8;
}
/* === Feedback Banner === */
.BrfAssistAI .feedback-banner {
  display: none;
  align-items: center;
  justify-content: center;
  background: #f7f8fa;
  gap: 8px;
  color: #6b7aa6;
  z-index: 5;
  padding: 1px 1px;
}

.BrfAssistAI .feedback-banner .feedback-text {
  font-size: 0.92em;
  user-select: none;
  cursor: pointer;
}

.BrfAssistAI .feedback-banner .showtalktous {
  width: 16px;
  height: 16px;
  opacity: 0.9;
}

/* === Chat Body & Messages === */
.BrfAssistAI .chat-body {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  background: #f7f8fa;
  font-size: 1em;
  scroll-behavior: smooth;
  position: relative;
}

/* === Customer Loading === */
.BrfAssistAI .customer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(247, 248, 250, 0.88);
  color: #1a2a4a;
  z-index: 2;
  pointer-events: none;
}

.BrfAssistAI .customer-loading.hidden {
  display: none;
}

.BrfAssistAI .lds-ellipsis,
.BrfAssistAI .lds-ellipsis div {
  box-sizing: border-box;
}

.BrfAssistAI .lds-ellipsis {
  display: inline-block;
  position: relative;
  width: 80px;
  height: 80px;
}

.BrfAssistAI .lds-ellipsis div {
  position: absolute;
  top: 33.33333px;
  width: 13.33333px;
  height: 13.33333px;
  border-radius: 50%;
  background: currentColor;
  animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.BrfAssistAI .lds-ellipsis div:nth-child(1) {
  left: 8px;
  animation: lds-ellipsis1 0.6s infinite;
}

.BrfAssistAI .lds-ellipsis div:nth-child(2) {
  left: 8px;
  animation: lds-ellipsis2 0.6s infinite;
}

.BrfAssistAI .lds-ellipsis div:nth-child(3) {
  left: 32px;
  animation: lds-ellipsis2 0.6s infinite;
}

.BrfAssistAI .lds-ellipsis div:nth-child(4) {
  left: 56px;
  animation: lds-ellipsis3 0.6s infinite;
}

@keyframes lds-ellipsis1 {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes lds-ellipsis3 {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(0);
  }
}

@keyframes lds-ellipsis2 {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(24px, 0);
  }
}

.BrfAssistAI .message {
  margin: 10px 12px;
}

.BrfAssistAI .bot-message {
  position: relative;
  max-width: 92%;
}

.BrfAssistAI .bot-message::before {
  content: "";
  position: absolute;
  top: -10px;
  left: -10px;
  width: 24px;
  height: 24px;
  background: url("/Common/Images/Assistant.AI/B-icon-with-glow.png") no-repeat center center;
  background-size: contain;
  border-radius: 50%;
  image-rendering: auto;
  box-shadow: 0 0 0 2px #ffffff, 0 2px 4px rgba(0, 0, 0, 0.18);
  z-index: 1010;
  filter: saturate(1.05);
}

.BrfAssistAI .bot-message .message-content {
  background: #ffffff;
  border: 1px solid #e5e8ef;
  border-radius: 12px;
  padding: 12px 40px 12px 14px;
  color: #1a2a4a;
  line-height: 1.35;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow-x: visible;
  overflow-y: visible;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.BrfAssistAI .bot-message.thinking .message-content {
  background: linear-gradient(135deg, #ffffff, #5e5e5e, #ffffff);
  background-clip: text;
  color: transparent;
  background-size: 200% 100%;
  animation: shimmer 5s linear infinite;
}

.BrfAssistAI .user-message {
  display: flex;
  justify-content: flex-end;
}

.BrfAssistAI .user-message .message-content {
  background: #e9f2ff;
  border: 1px solid #c8dcff;
  color: #123;
  border-radius: 12px;
  padding: 10px 12px;
}

/* === Data Tables & Rich Content === */
.BrfAssistAI .bot-message .message-content table {
  width: max-content;
  /* Avoid forcing full bubble width; this creates blank "extra column" space in fullscreen mode. */
  min-width: 0;
  max-width: 100%;
  border-collapse: collapse;
  /* Explicit outer border so table edge remains visible in both Angular and legacy pages. */
  border: 1px solid #848991;
  table-layout: auto;
  margin: 8px 0;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}


.BrfAssistAI .bot-message .message-content th,
.BrfAssistAI .bot-message .message-content td {
  padding: 6px 8px;
  border: 1px solid #d2d9e6;
  vertical-align: top;
  /* Force Booster tables to use left-justified text even when source HTML provides align="right". */
  text-align: left !important;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}

/* Extra safety for legacy table markup that includes explicit align attributes. */
.BrfAssistAI .bot-message .message-content th[align],
.BrfAssistAI .bot-message .message-content td[align] {
  text-align: left !important;
}

.BrfAssistAI .bot-message .message-content thead th {
  background: #f7f8fa;
  color: #1a2a4a;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.BrfAssistAI .bot-message .message-content th:last-child,
.BrfAssistAI .bot-message .message-content td:last-child {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.BrfAssistAI .bot-message .message-content img,
.BrfAssistAI .bot-message .message-content video,
.BrfAssistAI .bot-message .message-content iframe {
  max-width: 100%;
  height: auto;
}

.BrfAssistAI .bot-message .message-content pre,
.BrfAssistAI .bot-message .message-content code {
  white-space: pre-wrap;
  word-break: break-word;
}

/* === Copy Button === */
.BrfAssistAI .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  background: #ffffff;
  border: 1px solid #dbe2ef;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  opacity: 0.9;
  transition:
    transform 150ms ease,
    opacity 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.BrfAssistAI .copy-btn img {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.BrfAssistAI .copy-btn:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.BrfAssistAI .copy-btn:active {
  transform: scale(0.96);
}

.BrfAssistAI .copy-btn.copied {
  background: #e8f3ff;
  border-color: #9cc4ff;
  animation: copy-pop 450ms ease;
}

/* === Follow-Up Buttons === */
.BrfAssistAI .followup-question {
  display: block;
  background: #ffffff;
  border: 2px solid #3574f0;
  color: #1a58e7;
  padding: 10px 14px;
  font-size: 0.95em;
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  margin: 10px 0 0 0;
}

.BrfAssistAI .followup-question:hover {
  background: #3574f0;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

/* === Scroll-To-Latest Button === */
.BrfAssistAI .scroll-to-latest-wrapper {
  position: sticky;
  margin: 0 auto;
  bottom: -15px;
  display: flex;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  z-index: 1100;
}

.BrfAssistAI .scroll-to-latest-wrapper.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.BrfAssistAI .scroll-to-latest-wrapper.is-pulsing .scroll-to-latest-btn {
  animation: scroll-hint-pulse 2.4s ease-in-out infinite;
}

.BrfAssistAI .scroll-to-latest-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(26, 42, 74, 0.3);
  background: rgba(253, 253, 255, 0.9);
  color: #1b2a4a;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(15, 31, 63, 0.12);
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
  backdrop-filter: blur(8px);
}

.BrfAssistAI .scroll-to-latest-btn:hover {
  border-color: rgba(53, 116, 240, 0.8);
  background: rgba(53, 116, 240, 0.14);
  box-shadow: 0 12px 26px rgba(53, 116, 240, 0.28);
  transform: translateY(-1px);
}

.BrfAssistAI .scroll-to-latest-btn:active {
  transform: scale(0.96);
}

.BrfAssistAI .scroll-hint-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.BrfAssistAI .scroll-hint-icon svg {
  width: 16px;
  height: 16px;
}

@keyframes scroll-hint-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(53, 116, 240, 0.35);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(53, 116, 240, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(53, 116, 240, 0);
  }
}

/* === Footer & Input === */
.BrfAssistAI .chat-footer {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  background: #fff;
  border-top: 1px solid #e5e8ef;
  order: 3;
}

.BrfAssistAI .chat-footer input[type="text"] {
  flex: 1;
  padding: 10px 16px;
  border-radius: 24px;
  border: 1px solid #cfd8e3;
  margin-right: 10px;
  font-size: 1em;
  background: #fff;
  color: #7f7f7f;
}

.BrfAssistAI .chat-footer input[type="text"]::placeholder {
  color: #7f7f7f;
}

.BrfAssistAI .chat-footer input[type="text"]:disabled {
  background: #f1f3f6;
  color: #9aa3b5;
  cursor: not-allowed;
}

.BrfAssistAI #send-message {
  width: 40px;
  height: 40px;
  cursor: pointer;
  opacity: 0.85;
  transition: transform 0.2s cubic-bezier(0.17, 0.67, 0.83, 0.67);
}

.BrfAssistAI #send-message.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.6);
  animation: send-busy-pulse 1.6s ease-in-out infinite alternate;
}

.BrfAssistAI #send-message.is-policy-disabled {
  opacity: 0.5;
  filter: grayscale(0.7);
  cursor: not-allowed;
}

.BrfAssistAI .chat-usage {
  padding: 5px 18px 5px 18px;
  background: #f7f8fa;
  border: none;
  font-size: 0.85em;
  color: #4b5f86;
  text-align: center;
  order: 2;
}

.BrfAssistAI #send-message:not(.is-disabled):hover {
  transform: scale(1.15);
}

.BrfAssistAI #send-message:not(.is-disabled):active {
  background: #e8f3ff;
  border-color: #9cc4ff;
  animation: copy-pop 450ms ease;
}

.BrfAssistAI #send-message img,
.BrfAssistAI #send-message svg {
  pointer-events: none;
}

@keyframes send-busy-pulse {
  0% {
    opacity: 0.35;
    transform: scale(1);
  }
  100% {
    opacity: 0.5;
    transform: scale(1.05);
  }
}

/* === Thinking Text Variant === */
.BrfAssistAI .thinking-line2 {
  font-family: "Montserrat", sans-serif;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffffff, #5e5e5e, #ffffff);
  background-clip: text;
  color: transparent;
  animation: shimmer 5s linear infinite;
}

/* === Privacy Notice === */
.BrfAssistAI .chat-privacy {
  padding: 8px 18px 12px 18px;
  background: #fff;
  font-size: 12px;
  line-height: 1.28;
  color: #888;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
  border-top: 1px solid #f0f0f0;
  order: 5;
}

.BrfAssistAI .feedback-banner {
  order: 4;
}

.BrfAssistAI .chat-privacy a {
  color: #1a2a4a;
  text-decoration: underline;
}

/* Final warning CTA style (Silver-only message). Keep dark + underlined to match mock. */
.BrfAssistAI .policy-upgrade-link {
  color: #1a2a4a;
  font-weight: 700;
  text-decoration: underline;
}

/* === Animations === */
@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes copy-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

/* === Fullscreen Overrides === */
.BrfAssistAI .chat-window.chat-window-fullscreen {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  min-height: 100vh;
  border-radius: 0;
  resize: none;
}

.BrfAssistAI .chat-window.chat-window-fullscreen .chat-header {
  cursor: default;
  user-select: auto;
  -webkit-user-select: auto;
  touch-action: auto;
}

.BrfAssistAI .chat-window::after {
  display: none !important;
  content: none !important;
}

/* === Resizers === */
.BrfAssistAI .chat-resizer-left,
.BrfAssistAI .chat-resizer-top {
  position: absolute;
  z-index: 2;
  background: transparent;
}

.BrfAssistAI .chat-resizer-left {
  left: -4px;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
}

.BrfAssistAI .chat-resizer-top {
  top: -4px;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
}

.BrfAssistAI .chat-window.chat-window-fullscreen .chat-resizer-left,
.BrfAssistAI .chat-window.chat-window-fullscreen .chat-resizer-top {
  display: none;
}


