/* Portal Assistant container */
.nowl-portal-assistant {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: inherit;
    color: var(--global-palette3);
}

/* Toggle button */
.nowl-portal-assistant .assistant-toggle {
    background: none;
    border-radius: 8px;
    padding: 0.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    transition: transform 0.2s ease-out;
}

.nowl-portal-assistant .assistant-toggle:hover {
    transform: scale(1.05);
}

.nowl-portal-assistant.open .assistant-toggle {
    border: 2px solid var(--global-palette2);
}

.nowl-portal-assistant .assistant-toggle-icon {
    object-fit: contain;
    display: block;
}

/* Panel */
.nowl-portal-assistant .assistant-panel {
    display: none;
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 320px;
    background: var(--global-palette9);
    border: 1px solid var(--outline-color);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    font-size: 0.9rem;
    max-height: 70vh; /* Cap height to viewport */
    flex-direction: column;
    overflow: hidden;
}

/* Show panel when open */
.nowl-portal-assistant.open .assistant-panel {
    display: flex;
}

/* Tab content wrapper */
.assistant-content {
    background: var(--global-palette9);
    flex: 1;                 /* Grow to fill space */
    overflow-y: auto;        /* Scroll only content */
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-bar-color) transparent;
    display: flex;
    flex-direction: column;
}

/* WebKit scrollbar style */
.assistant-content::-webkit-scrollbar {
    width: 6px;
}
.assistant-content::-webkit-scrollbar-track {
    background: transparent;
}
.assistant-content::-webkit-scrollbar-thumb {
    background-color: var(--scroll-bar-color);
    border-radius: 3px;
}

/* Tabs stay pinned at bottom */
.assistant-tabs {
    display: flex;
    border-top: 1px solid var(--outline-color);
    background: var(--global-palette8);
    flex-shrink: 0; /* Prevent collapsing */
}

.assistant-tab {
    flex: 1;
    padding: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--global-palette5);
    text-align: center;
    transition: background 0.2s ease;
    border-radius: 0;
    border-bottom: 3px solid transparent;
}

.assistant-tab:focus, .assistant-tab.active, .assistant-tab:hover {
    background: none;
}

.assistant-tab:hover, .assistant-tab.active {
    border-bottom: 3px solid var(--global-palette2);
}

/* Tab panels */
.assistant-tab-panel {
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.assistant-tab-panel.active {
    display: flex;
}

.assistant-content-header {
    font-size: 1.2rem;
    font-weight: 500;
    padding: 1rem;
}

.assistant-content-body {
    overflow: scroll;
    padding: 0 1rem 1rem;
}


/* Checklist progress */
.checklist-progress {
    font-size: 0.8rem;
    color: var(--muted-text);
    margin-bottom: 0.75rem;
}

/* Checklist items */
.checklist-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.checklist-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--global-palette3);
    gap: 0.5rem;
}

.checklist-item.done {
    opacity: 0.7;
    text-decoration: line-through;
}

.checklist-checkbox {
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.checklist-items a {
    color: var(--global-palette2);
    text-decoration: none;
}

.checklist-items a:hover {
    text-decoration: underline;
}

/* Checklist footer actions */
.checklist-actions {
    margin-top: 1rem;
    font-size: 0.8rem;
    text-align: right;
    color: var(--muted-text);
}

.checklist-actions a {
    color: var(--global-palette2);
    cursor: pointer;
    text-decoration: none;
}

.checklist-actions a:hover {
    text-decoration: underline;
}

/* ------------------------
   Chatbot inside Portal Assistant
------------------------- */
/* -------- Chatbot Tab Overrides -------- */

/* Remove padding/scroll for chatbot tab */
.nowl-portal-assistant #assistant-chatbot.assistant-tab-panel {
    padding: 0;
    height: 100%;
    overflow: hidden;
}

#assistant-chatbot.assistant-tab-panel .assistant-content-body {
    padding: 0;
    overflow: hidden;
}

    /* Ensure chatbot container fills space */
.nowl-portal-assistant #assistant-chatbot .mwai-chatbot-container {
    height: 100%;
}

/* Conversation scrolls inside */
.nowl-portal-assistant #assistant-chatbot .mwai-conversation {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem; /* keep some breathing room */
}

/* Container */
.nowl-portal-assistant .mwai-chatbot-container {
    overflow: hidden;
    width: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--global-palette9);
    font-size: 0.85rem;
}

.nowl-portal-assistant .mwai-chat {
    display: flex;
    height: 100%;
    overflow: hidden;
}


.nowl-portal-assistant .mwai-window-box {
    width: 100%;
}

/* Chat area */
.nowl-portal-assistant .mwai-conversation {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
    display: flex;
    height: 100%;
    flex-direction: column;
    row-gap: 1rem;
    background-color: var(--global-palette9);
    scrollbar-color: var(--scroll-bar-color) transparent;
    scrollbar-width: thin;
}

.nowl-portal-assistant .mwai-body {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.nowl-portal-assistant .mwai-conversation::-webkit-scrollbar {
    width: 6px;
}
.nowl-portal-assistant .mwai-conversation::-webkit-scrollbar-thumb {
    background-color: var(--scroll-bar-color);
    border-radius: 3px;
}

/* Messages */
.nowl-portal-assistant .mwai-reply {
    display: flex;
    align-items: flex-start;
    column-gap: 0.5rem;
    font-size: 0.85rem;
}
.nowl-portal-assistant .mwai-reply > div {
    background-color: var(--global-palette7);
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    color: var(--mwai-fontColor, #fff);
    position: relative;
}
.nowl-portal-assistant .mwai-user {
    align-self: flex-end;
}
.nowl-portal-assistant .mwai-user > div {
    background-color: var(--global-palette1);
    color: var(--global-palette3);
}

/* Avatar */
.nowl-portal-assistant .mwai-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nowl-portal-assistant .mwai-avatar img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 50%;
}

/* Reply actions (copy, etc.) */
.nowl-portal-assistant .mwai-reply-actions {
    display: flex;
    margin-left: 0.25rem;
}
.nowl-portal-assistant .mwai-copy-button,
.nowl-portal-assistant .mwai-action-button {
    width: 18px;
    height: 18px;
    margin-top: 0.25rem;
    cursor: pointer;
}
.nowl-portal-assistant .mwai-copy-button svg,
.nowl-portal-assistant .mwai-action-button svg {
    width: 100%;
    height: 100%;
    fill: var(--global-palette5);
    transition: fill 0.2s ease;
}
.nowl-portal-assistant .mwai-copy-button svg:hover,
.nowl-portal-assistant .mwai-action-button svg:hover {
    fill: var(--global-palette2);
}

/* Input area */
.nowl-portal-assistant .mwai-input {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    background-color: var(--global-palette8);
    border-top: 1px solid var(--outline-color);
    column-gap: 0.5rem;
}
.nowl-portal-assistant .mwai-input-text {
    flex: 1;
    background-color: var(--global-palette7);
    border: 1px solid var(--outline-color);
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    display: flex;
    align-items: center;
}
.nowl-portal-assistant .mwai-input-text textarea {
    flex: 1;
    border: none;
    resize: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--global-palette3);
}
.nowl-portal-assistant .mwai-input .mwai-microphone {
    display: flex;
    align-items: center;
}

/* Send button */
.nowl-portal-assistant .mwai-input-submit {
    background: var(--global-palette1);
    color: var(--global-palette3);
    border: none;
    border-radius: 4px !important;
    padding: 0.4rem 0.8rem !important;
    cursor: pointer;
    font-size: 0.9rem !important;
    height: 100%;
}
.nowl-portal-assistant .mwai-input-submit:hover {
    background: var(--global-palette2);
}

.nowl-portal-assistant .mwai-footer {
    display: none;
}