.aichat-container {
    display: block !important;
    position: fixed;
    z-index: 9999;
    bottom: var(--toggle-bottom-spacing, 20px);
    right: var(--toggle-side-spacing, 20px);
    width: 360px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Import interactive tools styles */
@import url('../css/interactive-tools.css');

.aichat-bottom-right {
    right: 20px;
}

.aichat-bottom-left {
    left: 20px;
}

.aichat-box {
    display: none;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.aichat-open .aichat-box {
    display: flex;
}

.aichat-header {
    background-color: var(--header-bg);
    padding: 15px;
    border-radius: 10px 10px 0 0;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 10001;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.aichat-drawer {
    position: absolute;
    top: 70px;
    /* Approximate header height */
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 300px;
    background: #fff;
    z-index: 10000;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    border-radius: 0 0 0 10px;
}

.aichat-header-title {
    color: var(--header-text-color);
    font-size: var(--header-font-size);
    font-family: var(--header-font-family);
    margin: 0;
    flex: 1;
}

.aichat-header-credits {
    margin-right: 15px;
    text-align: right;
}

.aichat-credits {
    font-size: 0.9em;
    color: #666;
}

.aichat-close {
    position: relative;
    /* Changed from absolute */
    right: auto;
    top: auto;
    transform: none;
    background: none;
    border: none;
    color: var(--header-text-color);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    margin-left: auto;
    /* Push to right */
}

.aichat-close:hover {
    opacity: 1;
}

.aichat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.aichat-message {
    margin-bottom: 15px;
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
}

.aichat-user {
    margin-left: auto;
    background: #2271b1;
    color: #fff;
}

.aichat-assistant {
    margin-right: auto;
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.aichat-message-content {
    padding: 10px 15px;
    border-radius: 15px;
    line-height: 1.4;
}

.aichat-user .aichat-message-content {
    background: #2271b1;
    color: #fff;
}

.aichat-bot .aichat-message-content {
    background: #f0f2f5;
    color: #1a1a1a;
}

.aichat-error .aichat-message-content {
    background: #fee2e2;
    color: #991b1b;
}

.aichat-input {
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.aichat-input textarea {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 8px 15px;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    min-height: var(--message-box-height);
}

.aichat-send {
    background-color: var(--send-btn-bg) !important;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.aichat-send svg {
    width: 20px;
    height: 20px;
}

.aichat-send svg path {
    fill: var(--send-btn-icon-color);
}

.aichat-send:hover {
    opacity: 0.9;
}

.aichat-send:disabled {
    background-color: #cccccc !important;
    cursor: not-allowed;
    opacity: 0.7;
}

.aichat-send:disabled svg path {
    fill: #666666;
}

@media (max-width: 480px) {
    .aichat-container {
        width: calc(100% - 40px);
    }
}

/* Add these styles for the typing indicator */
.aichat-typing {
    background-color: var(--ai-msg-bg);
    color: #fff;
    padding: 10px 15px;
    border-radius: 15px;
    margin: 5px 10px;
    max-width: 80%;
    display: flex;
    align-items: center;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-text {
    order: 1;
    font-size: 14px;
    white-space: nowrap;
}

.typing-dots {
    order: 2;
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--header-text-color);
    border-radius: 50%;
    display: inline-block;
    animation: typing 1s infinite ease-in-out;
}

/* Add text to indicate AI is typing */
.typing-indicator:before {
    content: none;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 200ms;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 300ms;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 400ms;
}

@keyframes typing {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    50% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Update existing styles */
.aichat-message.bot {
    background: #f5f5f5;
    margin-right: auto;
    margin-left: 10px;
    position: relative;
}

.aichat-input textarea:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

.aichat-send:disabled {
    background-color: #cccccc !important;
    cursor: not-allowed;
    opacity: 0.7;
}

.typing-text {
    font-size: 12px;
    color: #666;
    margin-right: 8px;
}

/* Remove the :before content since we're using a span now */
.typing-indicator:before {
    content: none;
}

/* Message styling */
.aichat-message.aichat-user {
    background-color: var(--user-msg-bg);
    color: #fff;
    margin-left: auto;
    margin-right: 10px;
    border-radius: 15px;
}

.aichat-message.aichat-assistant {
    background-color: var(--ai-msg-bg);
    color: #fff;
    margin-right: auto;
    margin-left: 10px;
    border-radius: 15px;
}

/* Typing indicator container */
.aichat-typing {
    background-color: var(--ai-msg-bg);
    color: #fff;
    padding: 10px 15px;
    border-radius: 15px;
    margin: 5px 10px;
    max-width: 80%;
    display: flex;
    align-items: center;
}

.typing-text {
    font-size: 14px;
    color: inherit;
    margin-right: 8px;
    white-space: nowrap;
}



/* Send button icon color */
.aichat-send svg {
    fill: #fff;
}

/* Mobile optimization */
@media (max-width: 480px) {
    .aichat-container {
        width: 100% !important;
        max-width: 360px;
        bottom: 0;
        right: 0;
    }

    .typing-text {
        font-size: 12px;
    }
}

/* Chat toggle button */
.aichat-toggle {
    display: block;
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.3s ease;
}

.aichat-toggle:hover {
    transform: scale(1.1);
}

.aichat-toggle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0;
    background: transparent;
}

/* Remove any focus styles that might add background */
.aichat-toggle:focus {
    outline: none;
    background: transparent;
    box-shadow: none;
}

/* Remove any default button styles */
.aichat-toggle:active,
.aichat-toggle:hover {
    background: transparent;
    box-shadow: none;
}

/* Chat states */
.aichat-box {
    display: none;
}

.aichat-open .aichat-box {
    display: flex;
}

.aichat-open .aichat-toggle {
    display: none;
}

/* Adjust toggle position based on chat position */
.aichat-bottom-left .aichat-toggle-wrapper {
    left: var(--toggle-side-spacing, 20px);
    right: auto;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .aichat-toggle {
        width: 50px;
        height: 50px;
        bottom: 10px;
        right: 10px;
    }

    .aichat-bottom-left .aichat-toggle-wrapper {
        left: 10px;
    }
}

/* Toggle wrapper and online status */
.aichat-toggle-wrapper {
    position: fixed;
    display: flex;
    align-items: center;
    gap: var(--online-status-spacing, 10px);
    z-index: 9999;
    bottom: var(--toggle-bottom-spacing, 20px);
    right: var(--toggle-side-spacing, 20px);
    flex-direction: var(--online-status-direction, row);
}

.aichat-bottom-right .aichat-toggle-wrapper {
    right: var(--toggle-side-spacing, 20px);
}

.aichat-bottom-left .aichat-toggle-wrapper {
    left: var(--toggle-side-spacing, 20px);
}

.aichat-online-status {
    display: var(--online-status-display, flex);
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    background: rgba(255, 255, 255, var(--online-bg-opacity, 0.9));
    padding: var(--online-padding, 8px) 12px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.online-status-top {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 2px;
}

.online-name {
    font-weight: 500;
    font-size: var(--online-name-size, 14px);
    color: #333;
    line-height: 1.2;
}

.online-description {
    font-size: var(--online-desc-size, 12px);
    color: #666;
    line-height: 1.2;
}

.online-text {
    color: #666;
    font-size: calc(var(--online-name-size, 14px) - 2px);
}

/* Update mobile styles */
@media (max-width: 480px) {
    .aichat-toggle-wrapper {
        bottom: 10px;
        right: 10px;
    }

    .aichat-bottom-left .aichat-toggle-wrapper {
        left: 10px;
    }

    .aichat-online-status {
        padding: 4px 10px;
    }
}

/* Hide online status when chat is open */
.aichat-open .aichat-online-status {
    display: none !important;
}

/* Add back the online indicator styles */
.online-indicator {
    width: 8px;
    height: 8px;
    background-color: #2ecc71;
    border-radius: 50%;
    display: inline-block;
}

.online-status-top {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 2px;
}

.online-text {
    color: #666;
    font-size: calc(var(--online-name-size, 14px) - 2px);
}

/* =========================================
   Chat Drawer & Navigation Styles
   ========================================= */

.aichat-drawer {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 300px;
    background: #fff;
    z-index: 10000;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    border-radius: 0 0 0 10px;
}

.aichat-drawer.open {
    transform: translateX(0);
}

.aichat-drawer-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 10px 0 0 0;
}

.aichat-drawer-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.aichat-drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: #666;
}

.aichat-drawer-close:hover {
    color: #333;
}

.aichat-conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.aichat-conversation-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.aichat-conversation-item:hover {
    background: #f5f5f5;
}

.aichat-conversation-item.active {
    background: #eef5fa;
    border-left: 3px solid var(--header-bg, #2271b1);
}

.aichat-conversation-title {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.aichat-conversation-date {
    font-size: 11px;
    color: #999;
    margin-left: 10px;
}

.aichat-conversation-delete {
    background: none;
    border: none;
    color: #cc0000;
    cursor: pointer;
    padding: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.aichat-conversation-item:hover .aichat-conversation-delete {
    opacity: 1;
}

.aichat-hamburger {
    background: none;
    border: none;
    color: var(--header-text-color);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    margin-right: 10px;
}

.aichat-new-chat {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--header-text-color);
    cursor: pointer;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-right: 20px;
    /* Increased spacing */
}

.aichat-new-chat .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aichat-hamburger:hover {
    opacity: 1;
}

.aichat-new-chat:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

/* Last Chat Summary Card */
.aichat-last-summary-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 15px;
    /* Match message radius */
    padding: 15px;
    margin: 10px 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    animation: fadeIn 0.5s ease;
    border-left: 4px solid var(--header-bg, #2271b1);
    /* Add accent color */
}

.summary-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    font-size: 14px;
}

.summary-excerpt {
    font-size: 13px;
    color: #888;
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-style: italic;
}

.summary-continue-text {
    font-size: 9px;
    color: #666;
    margin-bottom: 8px;
    font-style: italic;
    letter-spacing: 0.3px;
    font-weight: 600;
}

.summary-resume-btn {
    background: var(--header-bg, #2271b1);
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.summary-resume-btn:hover {
    opacity: 0.9;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aichat-drawer-loading {
    display: flex;
    justify-content: center;
    padding: 20px;
    color: #666;
}

/* Trigger Words Styling */
.aichat-triggers-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 15px;
    margin-bottom: 10px;
    animation: fadeIn 0.5s ease;
}

.aichat-trigger-chip {
    background: #fff;
    border: 1px solid var(--header-bg, #2271b1);
    /* Use theme color */
    border-radius: 12px;
    /* Less pill-like, more like chat bubble */
    padding: 12px 14px;
    font-size: 13px;
    color: var(--header-bg, #2271b1);
    /* Use theme color */
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.aichat-trigger-chip:hover {
    background: var(--header-bg, #2271b1);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Welcome UI Container */
.aichat-welcome-ui {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
    width: 100%;
    padding-bottom: 10px;
}

/* Ensure messages container handles flex children correctly */
.aichat-messages {
    display: flex;
    flex-direction: column;
}

/* Adjust welcome message styling within container */
.aichat-welcome-ui .aichat-welcome-message {
    margin-bottom: 5px;
}

.summary-tool-usage {
    opacity: 0.7;
    font-style: italic;
}



.aichat-drawer-loading .spin {
    animation: spin 2s infinite linear;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}