/* Main Toggle Button */
#atheaico-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #1A73E8, #8AB4F8);
    border-radius: 50%;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#atheaico-chat-toggle:hover {
    transform: scale(1.05);
}

#atheaico-chat-toggle .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    line-height: 32px;
}

/* Sidebar Container */
#atheaico-chat-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    /* Hidden start */
    width: 380px;
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
    z-index: 100001;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

#atheaico-chat-sidebar.open {
    right: 0;
}

/* Header */
.atheaico-chat-header {
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.atheaico-chat-title {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    cursor: pointer;
    color: #444;
}

.atheaico-chat-title:hover {
    color: #444;
}

.atheaico-chat-menu-toggle {
    color: #5f6368;
    cursor: pointer;
}

.atheaico-chat-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.atheaico-chat-actions .dashicons {
    cursor: pointer;
    color: #5f6368;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-radius: 50%;
    background-color: #f1f3f4;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

.atheaico-chat-actions .dashicons:hover {
    color: #1A73E8;
    background-color: #e8f0fe;
}

/* Drawer (Topics List) */
.atheaico-chat-drawer {
    position: absolute;
    top: 60px;
    left: 0;
    width: 100%;
    height: calc(100% - 60px);
    background: #f1f3f4;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 10;
    border-right: 1px solid #f0f0f0;
}

.atheaico-chat-drawer.open {
    transform: translateX(0);
}

.atheaico-chat-drawer-header {
    padding: 20px;
}

.atheaico-chat-drawer-header h3 {
    margin: 0;
    font-size: 14px;
    color: #5f6368;
}

.atheaico-chat-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    height: calc(100% - 60px);
}

.atheaico-chat-list li {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    color: #3c4043;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.atheaico-chat-list li:hover {
    background: #fff;
}

.atheaico-chat-list li.active {
    background: #fff;
    color: #1A73E8;
    font-weight: 500;
}

.atheaico-chat-list .delete-topic {
    opacity: 0;
    font-size: 16px;
    color: #aaa;
}

.atheaico-chat-list li:hover .delete-topic {
    opacity: 1;
}

.atheaico-chat-list .delete-topic:hover {
    color: #d93025;
}

/* Messages Area */
.atheaico-chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.atheaico-chat-welcome {
    text-align: center;
    margin-top: 40px;
    color: #1A73E8;
    /* Gemini Blue */
}

.atheaico-chat-welcome h3 {
    font-size: 24px;
    font-weight: 400;
}

/* Message Bubbles */
.atheaico-msg {
    display: flex;
    flex-direction: column;
    max-width: 90%;
    font-size: 14px;
    line-height: 1.5;
}

.atheaico-msg-user {
    align-self: flex-end;
    background: #f1f3f4;
    padding: 12px 16px;
    border-radius: 12px 12px 2px 12px;
    color: #373737;
}

.atheaico-msg-ai {
    align-self: flex-start;
    color: #373737;
    width: 100%;
}

.atheaico-msg-ai .sender-name {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #1A73E8;
    font-size: 12px;
}

.atheaico-msg-ai .content {
    white-space: pre-wrap;
}

.atheaico-msg-ai ul {
    margin: 5px 0 10px 0;
    padding-left: 20px;
    list-style-type: disc;
    list-style-position: outside;
}

.atheaico-msg-ai li {
    margin-bottom: 4px;
    padding-left: 5px;
    /* Small space between bullet and text */
    text-indent: 0;
    margin-left: 0;
}

.atheaico-msg-ai pre {
    background: #f1f3f4;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid #dadce0;
    margin: 10px 0;
    max-width: 100%;
}

.atheaico-msg-ai code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #c7254e;
    background-color: #f9f2f4;
    padding: 2px 4px;
    border-radius: 4px;
}

.atheaico-msg-ai pre code {
    padding: 0;
    color: inherit;
    background-color: transparent;
    border-radius: 0;
}

.atheaico-msg-ai h1,
.atheaico-msg-ai h2,
.atheaico-msg-ai h3,
.atheaico-msg-ai h4 {
    margin: 24px 0 0px 0;
    font-weight: 600;
    line-height: 1.3;
}

.atheaico-msg-ai h1 {
    font-size: 1.4em;
}

.atheaico-msg-ai h2 {
    font-size: 1.25em;
}

.atheaico-msg-ai h3 {
    font-size: 1.1em;
}

.atheaico-msg-ai h4 {
    font-size: 1em;
}

/* Copy Button */
.atheaico-copy-btn {
    align-self: flex-start;
    margin-top: 10px;
    font-size: 13px;
    color: #5f6368;
    background: none;
    border: 1px solid #dadce0;
    border-radius: 4px;
    padding: 6px 8px 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.atheaico-copy-btn .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
    vertical-align: middle;
}

.atheaico-copy-btn:hover {
    background: #f1f3f4;
    color: #1A73E8;
    border-color: #1A73E8;
}

/* Input Area */
.atheaico-chat-input-area {
    padding: 15px 20px;
    background: #fff;
    position: relative;
    border-top: 1px solid #fff;
    /* Blend in */
}

.atheaico-chat-input-area textarea {
    width: 100%;
    border: 1px solid #dadce0;
    border-radius: 24px;
    padding: 12px 45px 12px 20px;
    resize: none;
    outline: none;
    max-height: 150px;
    font-family: inherit;
    font-size: 14px;
    transition: box-shadow 0.2s, border-color 0.2s;
    background: #f8f9fa;
    scrollbar-width: none;
    /* Firefox */
}

.atheaico-chat-input-area textarea::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari */
}

.atheaico-chat-input-area textarea:focus {
    background: #fff;
    box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
    border-color: transparent;
}

#atheaico-chat-send-btn {
    position: absolute;
    right: 30px;
    bottom: 27px;
    /* Center in relation to textarea default height */
    background: none;
    border: none;
    color: #1A73E8;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s;
}

#atheaico-chat-send-btn:hover {
    transform: translateX(2px);
}

#atheaico-chat-send-btn:disabled {
    color: #ccc;
    cursor: not-allowed;
}

/* Loading Dots */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 5px 0;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #dadce0;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: scale(1);
        background: #dadce0;
    }

    30% {
        transform: scale(1.5);
        background: #8AB4F8;
    }
}

/* Admin Push Transition */
body.atheaico-sidebar-open {
    margin-right: 380px;
    transition: margin-right 0.3s;
}

body.atheaico-sidebar-open.wide {
    margin-right: 760px;
}

/* Admin Bar Fix */
#atheaico-chat-sidebar {
    top: 32px;
    height: calc(100vh - 32px);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
}

#atheaico-chat-sidebar.wide {
    width: 760px;
    right: -800px;
}

#atheaico-chat-sidebar.open {
    right: 0 !important;
}

/* Settings Dropdown */
.atheaico-chat-settings-wrapper {
    position: relative;
    display: inline-block;
}

.atheaico-chat-settings-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 150px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    margin-top: 5px;
}

.atheaico-chat-settings-dropdown.open {
    display: block;
}

.atheaico-chat-setting-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #444;
}

.atheaico-chat-setting-item:hover {
    background: #f1f3f4;
}

.atheaico-chat-setting-item.active {
    background: #e8f0fe;
    color: #1A73E8;
    font-weight: 500;
}

.atheaico-chat-setting-item .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 16px;
}

@media only screen and (max-width: 782px) {
    #atheaico-chat-sidebar {
        top: 46px;
        height: calc(100vh - 46px);
        width: 100%;
        max-width: 100%;
        right: -100%;
    }

    #atheaico-chat-sidebar.wide {
        width: 100%;
        /* On mobile, wide is just full width anyway */
    }

    body.atheaico-sidebar-open,
    body.atheaico-sidebar-open.wide {
        margin-right: 0;
    }
}