:root {
    --antimanual_primary_color: #0066cc;
    --antimanual_white_color: #ffffff;
    --antimanual_input_border: #86B7FE;
    --antimanual_input_outline: #C2DBFE;
    --black_25: #f9f9f9;
    --black_50: #f2f2f2;
    --black_75: #eeeeee;
    --black_100: #d6d9dc;
    --black_150: #c8ccd0;
    --black_200: #bbc0c4;
    --black_300: #9fa6ad;
    --black_350: #9199a1;
    --black_400: #848d95;
    --black_500: #6a737c;
    --black_600: #535a60;
    --black_700: #3c4146;
    --black_750: #2f3337;
    --black_800: #242729;
    --black_900: #0c0d0e;
    --bs-white: #ffffff;
    --bs_sm: 0 1px 2px rgb(0 0 0 / 5%), 0 1px 4px rgb(0 0 0 / 5%), 0 2px 8px rgb(0 0 0 / 5%);
    --bs_md: 0 1px 3px rgb(0 0 0 / 6%), 0 2px 6px rgb(0 0 0 / 6%), 0 3px 8px rgb(0 0 0 / 9%);
    --bs_lg: 0 1px 4px rgb(0 0 0 / 9%), 0 3px 8px rgb(0 0 0 / 9%), 0 4px 13px rgb(0 0 0 / 13%);
}

.bs-sm {
    box-shadow: var(--bs_sm) !important;
}

.bs-md {
    box-shadow: var(--bs_md) !important;
}

.bs-lg {
    box-shadow: var(--bs_lg) !important;
}

/** Hover Classes **/
.h\:bs-md:hover {
    box-shadow: var(--bs_md) !important;
}

.h\:bs-lg:hover {
    box-shadow: var(--bs_md) !important;
}

/* Chat-bubble friendly typography — compact, native chatbot feel.
   Sized in em so it inherits the message's base font-size. */
.atml-msg-html {
    line-height: 1.5;
    color: var(--black_800);
    word-wrap: break-word;
    overflow-wrap: anywhere;

    /* Trim outer whitespace so the bubble hugs the content */
    > *:first-child { margin-top: 0; }
    > *:last-child  { margin-bottom: 0; }

    p {
        margin: 0.45em 0;
    }

    h1, h2, h3, h4, h5, h6 {
        margin: 0.7em 0 0.25em;
        font-weight: 600;
        line-height: 1.3;
        color: var(--black_900);
        border: 0;
        padding: 0;

        &:first-child { margin-top: 0; }
    }

    h1 { font-size: 1.08em; }
    h2 { font-size: 1.05em; }
    h3 { font-size: 1em; color: var(--black_700); }
    h4, h5, h6 { font-size: 0.95em; color: var(--black_700); }

    strong { font-weight: 600; color: var(--black_900); }
    em     { font-style: italic; color: var(--black_700); }

    a {
        color: var(--antimanual_primary_color);
        text-decoration: underline;
        text-decoration-thickness: 1px;
        text-underline-offset: 2px;
        transition: opacity 0.15s ease;
        word-break: break-word;

        &:hover { opacity: 0.75; }
    }

    /* Inline code */
    code {
        background: var(--black_50);
        padding: 1px 5px;
        border-radius: 4px;
        font-family: ui-monospace, "SF Mono", "Fira Code", Menlo, Consolas, monospace;
        font-size: 0.87em;
        color: var(--black_900);
        word-break: break-word;
    }

    /* Block code */
    pre {
        background: var(--black_50);
        padding: 8px 10px;
        margin: 0.5em 0;
        border-radius: 6px;
        font-family: ui-monospace, "SF Mono", "Fira Code", Menlo, Consolas, monospace;
        font-size: 0.85em;
        line-height: 1.45;
        overflow-x: auto;

        code {
            background: transparent;
            padding: 0;
            border-radius: 0;
            font-size: 1em;
            color: inherit;
            white-space: pre;
        }
    }

    img {
        max-width: 100%;
        height: auto;
        border-radius: 6px;
        margin: 0.4em 0;
        display: block;
    }

    /* Lists — tight, no excess indent. padding-left holds bullets inside
       the bubble; margins are minimal. */
    ul, ol {
        margin: 0.35em 0;
        padding-left: 1.25em;
    }

    li {
        margin: 0.12em 0;
        line-height: 1.5;
        color: var(--black_800);

        > p { margin: 0; }

        ul, ol { margin: 0.15em 0; }
    }

    ul { list-style: disc; }
    ol { list-style: decimal; }

    /* Blockquote — soft accent rail, not a heavy quote */
    blockquote {
        margin: 0.5em 0;
        padding: 0.15em 0.75em;
        border-left: 2px solid var(--antimanual_primary_color);
        color: var(--black_600);
        background: transparent;
    }

    /* Horizontal rule — slim divider between thoughts */
    hr {
        border: 0;
        border-top: 1px solid var(--black_75);
        margin: 0.7em 0;
    }

    /* Tables — narrow bubbles can't hold wide tables, so let them scroll */
    table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        border-collapse: collapse;
        margin: 0.5em 0;
        font-size: 0.93em;

        th, td {
            padding: 4px 8px;
            border: 1px solid var(--black_75);
            text-align: left;
        }

        th {
            background: var(--black_25);
            font-weight: 600;
        }
    }
}

/* ================================================
   COLOR UTILITIES
   ================================================ */

.antimanual-bg-primary,
.antimanual-bg-primary:hover,
.antimanual-bg-primary:focus,
.antimanual-bg-primary-foreground {
  background-color: var(--antimanual_primary_color) !important;
}

.antimanual-text-primary-foreground {
  color: var(--antimanual_white_color);
}

/* ================================================
   RESET & BASE STYLES
   ================================================ */

img.antimanual_icons {
  width: 16px;
}

/* ================================================
   EAZYDOCS INTEGRATION
   ================================================ */

.assistant-content[tab-content="antimanual_merge_eazydocs"] {
  height: 720px;
  #antimanual-chatbox {
    display: block !important;
    position: unset;
    margin: 0;
    height: 100%;
    width: 100%;
  }

  &.active {
    margin: -100px -11px 0 -15px;

    #antimanual-chatbox-inner-wrapper {
      height: calc(100% - 60px);
      position: absolute;
      bottom: 0;
      top: 60px;
      left: 0;
    }

    #antimanual-chatbox-header {
      background-color: var(--bs-white);
      padding: 12px 15px 12px;

      &.atml-empty {
        padding: 8px;

        #atml-chat-reset {
          position: absolute;
          right: 15px;
          top: 0;
          transform: translateY(-100%);
        }
      }
    }

    .antimanual-chatbox-header-actions {
      display: none;
    }
  }

  #antimanual-input-container {
    margin-bottom: 15px;
  }

  #antimanual-chatbox-header-text {
    text-align: left;
  }
}

/* ================================================
   CHATBOX CONTAINER
   ================================================ */

#antimanual-chatbox {
  width: min(400px, calc(100vw - 32px));
  height: min(700px, calc(100vh - 108px));
  margin: 16px 16px 92px 16px;
  position: fixed;
  left: auto;
  right: 0;
  bottom: 0;
  transform: none;
  margin-right: 30px;
  background-color: var(--antimanual_white_color);
  border-radius: 16px;
  box-shadow: rgba(9, 14, 21, 0.16) 0 5px 40px 0;
  overflow: hidden;
  z-index: 10001;
  display: none;
  flex-direction: column;

  &.iframe-wrapper {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
  }

  /* Focus States for Accessibility */
  button:focus-visible {
    outline: 2px solid var(--antimanual_primary_color, #2563eb);
    outline-offset: 2px;
  }
}

/* ================================================
   INNER WRAPPER
   ================================================ */

#antimanual-chatbox-inner-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background-color: var(--bs-white, #fff);
}

/* ================================================
   HEADER
   ================================================ */

#antimanual-chatbox-header {
  justify-self: start;
  background-color: var(--black_25);
  color: var(--black_800);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--black_75);
}

#antimanual-chatbox-header-text {
  color: var(--antimanual_header_text_color, var(--black_800));

  strong {
    font-size: 16px;
    font-weight: 600;
    color: var(--black_800);
  }

  p {
    font-size: 13px;
    margin: 2px 0 0;
    color: var(--black_500);
    line-height: 1.4;
  }
}

#atml-chat-reset,
#atml-chat-close {
  border: none;
  outline: none;
  background: transparent;
  color: var(--black_400);
  padding: 4px;
  cursor: pointer;
  transition: color 0.2s ease;
  border-radius: 6px;

  .antimanual-icon {
    width: 14px;
  }

  &:hover {
    color: var(--black_700);
  }

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

.antimanual-chatbox-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ================================================
   OFFLINE BANNER
   ================================================ */

.antimanual-offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 16px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #78350f;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-bottom: 1px solid rgba(253, 211, 77, 0.5);

  &.show {
    display: flex;
    animation: antimanual-offline-slide-down 0.3s ease-out;
  }

  svg {
    width: 14px;
    height: 14px;
    opacity: 0.8;
    flex-shrink: 0;
  }

  span {
    line-height: 1;
  }

  /* Pulsing status dot */
  &::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #d97706;
    flex-shrink: 0;
    animation: antimanual-offline-pulse 2s ease-in-out infinite;
  }
}

@keyframes antimanual-offline-slide-down {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes antimanual-offline-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ================================================
   CHAT AREA
   ================================================ */

.antimanualchatbox {
  flex-grow: 1;
  padding: 16px;
  overflow-y: auto;

  /* Smooth Scrollbar */
  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: transparent;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--black_200, #d1d5db);
    border-radius: 3px;

    &:hover {
      background: var(--black_300, #9ca3af);
    }
  }
}
