/* --- Make the chat panel open full size by default and fill area --- */
.aouai-chat-overlay { 
  z-index: 10060 !important; /* above bubble and drawers */
}

/* Anchor panel to bottom-right so it grows upward from the bubble area */
.aouai-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;               /* stick to bottom */
  top: auto;                  /* allow growth upward */
  width: 360px !important;
  height: 460px !important;
  display: flex;
  flex-direction: column;
}


/* Open animation: grow from bottom-right */
.aouai-chat-panel {
  transform-origin: bottom right;          /* anchor growth */
  transform: translateY(10px) scale(0.98); /* slight offset before open */
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}

/* When overlay opens, animate into place */
.aouai-chat-overlay.open .aouai-chat-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Make the log scroll stable and not bubble to page */
.aouai-chat-body #openai_chat_log {
  overscroll-behavior: contain;
  scroll-behavior: auto; /* JS handles precise jumps; auto is safer */
}



/* Make the chat-body a flex column so the log fills vertically, control bar sticks at bottom */
.aouai-chat-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;              /* allows flex children to shrink properly */
}

/* Move the OpenAI Chat DOM into the bubble and make it fill the body */
.aouai-chat-body section.block_openai_chat.block,
.aouai-chat-body .aouchat-embedded {
  display: flex !important;
  flex-direction: column;
  height: 100%;
  border: 0 !important;
  margin: 0 !important;
}

/* Make the log scroll and occupy available space */
.aouai-chat-body #openai_chat_log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px 10px;
}

/* Keep control bar pinned at bottom */
.aouai-chat-body #control_bar {
  flex: 0 0 auto;
  margin-top: 8px;
}

/* Hide the bubble while chat is open so it doesn't overlap anything */
body.aouchat-open .aouai-chat-button {
  opacity: 0;
  pointer-events: none;
}

/* If you prefer not to hide the bubble, then ensure the panel is above it. 
   Already handled by z-index (overlay 10060, panel higher than button 10050). */
/* .aouai-chat-button { z-index: 10050; }  (keep as is if you set earlier) */

/* Optional: make resize handle easier to grab (if you have one) */
.aouai-chat-resize-handle {
  right: auto; left: 8px; bottom: 0; top: 0;
  cursor: nwse-resize;
}





/* Hide OpenAI block in side regions when NOT editing (avoid duplicate UI).
   Still movable (we'll relocate the DOM into the bubble). */
/* Hide OpenAI Chat block only when it's in a block region and we're NOT editing.
   Do NOT hide when we move it into the bubble. */

body:not(.editing) .block-region section.block_openai_chat.block,
body:not(.editing) [data-region="blocks-column"] section.block_openai_chat.block,
body:not(.editing) [data-region="side-pre"] section.block_openai_chat.block,
body:not(.editing) [data-region="side-post"] section.block_openai_chat.block {
  display: none !important;
}


/* When the block is inside the AOU chat bubble, show and fit it nicely */
aouai-chat-body
.aouai-chat-body section.block_openai_chat.block {
  display: flex !important;
  flex-direction: column;
  height: 100%;
  border: 0 !important;
  margin: 0 !important;
}

/* Fill bubble height */
.aouai-chat-body .block_openai_chat .card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  height: 100%;
}

/* Hide block title + popout button in bubble */
.aouai-chat-body .block_openai_chat h3.card-title,
.aouai-chat-body .block_openai_chat .openai_input_popout_btn {
  display: none !important;
}

/* Chat log scrolls; stays above input bar */
.aouai-chat-body #openai_chat_log {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 140px;
  background: #fff;
  border-radius: 8px;
}

/* Input bar anchored bottom */
.aouai-chat-body #control_bar {
  flex: 0 0 auto;
}

/* Optional: textarea behavior */
.aouai-chat-body .openai_input_bar textarea#openai_input {
  max-height: 160px;
}



  .aouai-chat-button .aouai-logo{
  width:120px; height:120px !important;
  display:block;
  transition: transform 160ms ease;
  transform-origin:center;
  will-change: transform;
}

.aouai-chat-button:hover .aouai-logo,
.aouai-chat-button .aouai-logo:hover{
  transform: scale(1.10); /* +10% */
}


  
  .aouai-chat-button{
  background: white !important; 
   }


   .aouai-chat-actions button:hover{
  background: #f1f5f9 !important;
  color: #0f172a !important;
}


/* OPTIONAL: keep page interactive while chat open (no dim) */
.aouai-chat-overlay {
  background: transparent !important;   /* remove dim */
  pointer-events: none;                 /* overlay doesn't block */
}
.aouai-chat-panel {
  pointer-events: auto;                 /* panel remains clickable */
}



.block_openai_chat {
    position: relative;
}

.block_openai_chat #openai_chat_log {
    display: flex;
    flex-direction: column;
    max-height: 20rem;
    overflow-y: scroll;
    margin-bottom: 0.5rem;
}

.block_openai_chat #openai_chat_log p {
    margin: 0;
}

.block_openai_chat #openai_chat_log a {
    color: white;
    text-decoration: underline;
}

.block_openai_chat #control_bar {
    display: flex;
    gap: 0.5rem;
}

.block_openai_chat #control_bar button:hover {
    filter: brightness(0.8);
}

.block_openai_chat #control_bar #go {
    border-radius: 0 0.5rem 0.5rem 0;
}

.block_openai_chat #control_bar button  {
    transition: filter 0.2s ease;
    border: none;
    border-radius: 0.5rem;
    width: 2.5rem;
}

.openai_input_submit_btn {
    background-color: var(--primary);
    color: var(--white);
}

.openai_input_refresh_btn {
    background-color: var(--secondary);
    color: black;
}

.block_openai_chat .openai_input_popout_btn {
    visibility: hidden;
    position: absolute;
    top: 0.75rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    border-radius: 99rem;
    padding: 0.4rem;
    display: flex;
    border: none;
    z-index: 2;
}
.block_openai_chat .openai_input_popout_btn img {
    max-width: 1.25rem;
    pointer-events: none;
}
.drawercontent {
    position: unset;
}

.openai_input_submit_btn_icon,
.openai_input_refresh_btn_icon {
    width: 80%;
}

.openai_input_bar {
    display: flex;
    width: 100%;
}

.block_openai_chat img {
    transform: scale(0.7);
}

.block_openai_chat #openai_input,
.openai_input_bar input {
    padding: 0.5rem;
    border-radius: 0.5rem 0 0 0.5rem;
    border: 1px solid gray;
    width: 100%;
    transition: background 0.4s ease;
}

.block_openai_chat #openai_input.error {
    border: 1px solid red;
}

.block_openai_chat .openai_message {
    margin-right: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f4f4f4;
    border-radius: 0.5rem;
    margin-bottom: 1.75rem;
    width: fit-content;
    max-width: 90%;
    animation: block_openai_chat_popup 0.4s cubic-bezier(0.87, 0, 0.13, 1);
    position: relative;
}

.block_openai_chat .openai_message:before {
    position: absolute;
    top: -1.5rem;
    left: 0;
    color: gray;
    opacity: 0;
    animation: block_openai_chat_fade-in 0.4s ease 0.4s forwards;
}

.block_openai_chat .openai_message.user {
    align-self: flex-end;
    text-align: right;
}

.block_openai_chat .openai_message.user:before {
    right: 0;
    left: unset;
}

.block_openai_chat .openai_message.bot {
    background: var(--blue);
    color: var(--white);
}

.block_openai_chat .openai_message.loading {
    animation: block_openai_chat_thinking 1s ease infinite;
}

.block_openai_chat .openai_message.loading:before {
    animation: none;
    opacity: 0;
}

.block_openai_chat.disabled,
.block_openai_chat .disabled {
    opacity: 0.25;
    pointer-events: none;
}

.block_openai_chat.expanded {
    position: fixed;
    height: 70vh;
    width: 30rem;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    outline: 100vw solid #00000029;
    z-index: 2;
    background-color: white !important;
}

.block_openai_chat.expanded .card-body {
    overflow-y: auto;
}

.block_openai_chat.expanded #openai_chat_log {
    max-height: unset;
    overflow-y: unset;
    padding-bottom: 3rem !important;
    padding-top: 1rem;
    min-height: 2rem;
}

.block_openai_chat.expanded #control_bar {
    display: flex;
    gap: .5rem;
    position: fixed;
    bottom: 1rem;
    width: calc(100% - 2rem);
}

.block_openai_chat.expanded .openai_message {
    width: fit-content !important;
}

.block_openai_chat .recording {
    width: 0.5rem;
    height: 0.5rem;
    background: #ff0000;
    position: absolute;
    top: 1.5rem;
    right: 3rem;
    border-radius: 99rem;
    filter: opacity(0.5);
    animation: block_openai_chat_thinking 3s linear infinite;
}

.block_openai_chat input {
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid grey;
}

.block_openai_chat .report_container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* dumbass remui styles */
.block_openai_chat.expanded .block-header-wrapper {
    padding: 1rem !important;
}
.block_openai_chat.expanded .edw-block-body {
    box-shadow: none !important;
}
.block_openai_chat .edw-block-body #popout {
    top: 0;
}
.block_openai_chat .edw-block-body .recording {
    top: 0.75rem;
}
.block_openai_chat.expanded .edw-block-body #popout {
    top: 0.75rem;
}
.block_openai_chat.expanded .edw-block-body .recording {
    top: 1.5rem;
}
.block_openai_chat.expanded .edw-block-body #control_bar {
    width: calc(100% - 4rem);
}
.block_openai_chat.expanded .block-body-wrapper {
    height: calc(100% - 4rem);
    overflow: auto;
}
#block-region-side-pre .block_openai_chat.expanded .block-body-wrapper {
    margin-left: 0;
    margin-right: 0;
    padding: 0 2rem;
}
.drawer {
    filter: unset !important;
}

@media screen and (max-width: 750px) {
    .drawerheader {
        pointer-events: none;
    }
    .drawerheader button {
        pointer-events: all;
    }
    .block_openai_chat.expanded {
        transform: unset;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
    }
    .block_openai_chat.expanded .openai_input_popout_btn {
        right: 3rem;
    }
    .block_openai_chat.expanded .recording {
        right: 5.5rem;
    }
    .block_openai_chat .report_container {
        flex-direction: column;
    }
}

@keyframes block_openai_chat_popup {
    0% {
        opacity: 0;
        transform: translateY(5px);
    }

    70% {
        opacity: 1;
        transform: translateY(-2.5px);
    }

    85% {
        transform: translateY(2.5px);
    }

    100% {
        transform: translateY(0);
    }
}

@keyframes block_openai_chat_thinking {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.25;
    }

    100% {
        opacity: 1;
    }
}

@keyframes block_openai_chat_fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}



.aouai-chat-button{
  background: white !important;
}


/* ——— Make the OpenAI block fill the AOU panel ——— */
.aouai-chat-body section.block_openai_chat.block {
  display: flex !important;
  flex-direction: column !important;
  height: 90% !important;
  width: 100% !important;
  border: 0 !important;
  margin: 0 !important;
  background: transparent !important;
}

/* The inner content container must also flex to fill the panel */
.aouai-chat-body .block_openai_chat .card-body,
.aouai-chat-body .block_openai_chat .card-text.content {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  height: 100% !important;
  min-height: 0 !important;
  padding: 8px 10px !important;
  margin: 0 !important;
}

/* The chat log must expand and be scrollable */
.aouai-chat-body #openai_chat_log {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;      /* override the plugin’s 20rem */
  overflow: auto !important;
  padding: 8px 10px !important;
  overscroll-behavior: contain;
}

/* Input bar anchored at bottom */
.aouai-chat-body #control_bar {
  flex: 0 0 auto !important;
  margin-top: 8px !important;
}

/* Hide the block title and popout button inside the bubble */
.aouai-chat-body .block_openai_chat h3.card-title,
.aouai-chat-body .block_openai_chat .openai_input_popout_btn {
  display: none !important;
}

/* Kill any “expanded” modal behavior from the block when inside bubble */
.aouai-chat-body .block_openai_chat.expanded {
  position: static !important;
  height: auto !important;
  width: auto !important;
  outline: none !important;
  transform: none !important;
}

/* Ensure the AOU panel stays fixed and full size (your requirement) */
.aouai-chat-panel {
  width: 360px !important;
  height: 460px !important;
  right: 24px;
  bottom: 24px; /* grow upward from bottom-right */
  transform-origin: bottom right;
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}
.aouai-chat-overlay.open .aouai-chat-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}
