/* LLM Chat styles */
#llm-chat-container {
    position: fixed;
    bottom: 1rem;
    right: 0.5rem;
    z-index: 9000;
    font-family: inherit;
}

#llm-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--main-color);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#llm-chat-toggle:hover {
    transform: scale(1.1);
}

#llm-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s, transform 0.3s;
}

#llm-chat-window.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.hidden {
    display: none !important;
}

#llm-chat-header {
    padding: 1rem;
    background: var(--main-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

#llm-chat-actions {
    display: flex;
    gap: 0.5rem;
}

#llm-chat-actions button {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 5px;
    opacity: 0.8;
}

#llm-chat-actions button:hover {
    opacity: 1;
}

#llm-chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.chat-message {
    padding: 0.8rem 1rem;
    border-radius: 15px;
    max-width: 85%;
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--main-color);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-message.ai {
    align-self: flex-start;
    background: #eef2f5;
    color: #333;
    border-bottom-left-radius: 2px;
}

.chat-message.error {
    align-self: center;
    background: #ffe5e5;
    color: #d00;
    font-size: 0.85rem;
}

.chat-message.system {
    align-self: center;
    background: #f0f0f0;
    color: #666;
    font-size: 0.8rem;
    font-style: italic;
}

#llm-chat-thinking {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

#llm-chat-input-container {
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
    background: white;
    border-top: 1px solid #eee;
}

#llm-chat-input {
    flex-grow: 1;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
}

#llm-chat-input:focus {
    border-color: var(--main-color);
}

#llm-chat-send,
#llm-chat-stop {
    color: white;
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

#llm-chat-send {
    background: var(--main-color);
}

#llm-chat-stop {
    background: #ffffff;
    font-size: 1.2rem;
}

#llm-chat-send:hover,
#llm-chat-stop:hover {
    opacity: 0.9;
}

/* Animation for menu item highlight when linked from chat */
@keyframes itemBlink {

    0%,
    100% {
        background-color: white;
        box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    }

    16.66%,
    50%,
    83.33% {
        background-color: var(--attenuated-color);
        box-shadow: 0 0 20px var(--attenuated-color);
    }

    33.33%,
    66.66% {
        background-color: white;
        box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    }
}

.menu-item.highlight-blink {
    animation: itemBlink 2s ease-in-out;
}

.menu-item-link {}

/* Embedded mode (print studio modal — right column div only) */
.print-studio-chat-mount .llm-chat--embedded,
.llm-chat--embedded {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    height: 100%;
    z-index: auto;
}

.print-studio-chat-mount > .llm-chat-container.llm-chat--embedded {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.llm-chat--embedded .llm-chat-window,
.llm-chat--embedded [id^="llm-chat-window-"] {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 8px;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    box-shadow: none;
}

.llm-chat--embedded [id^="llm-chat-window-"].hidden {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
}

/* Embedded uses dynamic ids — mirror #llm-chat-messages scroll rules */
.llm-chat--embedded [id^="llm-chat-messages-"],
.llm-chat--embedded #llm-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    -webkit-overflow-scrolling: touch;
}

.llm-chat--embedded [id^="llm-chat-window-"] > div:first-child,
.llm-chat--embedded #llm-chat-header {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    background: var(--main-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.llm-chat--embedded [id^="llm-chat-thinking-"],
.llm-chat--embedded #llm-chat-thinking {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.llm-chat--embedded #llm-chat-input-container {
    flex-shrink: 0;
}

/* Embedded uses dynamic ids — mirror #llm-chat-input and send/stop button rules */
.llm-chat--embedded textarea[id^="llm-chat-input-"] {
    flex-grow: 1;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
}

.llm-chat--embedded textarea[id^="llm-chat-input-"]:focus {
    border-color: var(--main-color);
}

.llm-chat--embedded [id^="llm-chat-send-"],
.llm-chat--embedded [id^="llm-chat-stop-"] {
    color: white;
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.llm-chat--embedded [id^="llm-chat-send-"] {
    background: var(--main-color);
}

.llm-chat--embedded [id^="llm-chat-stop-"] {
    background: #ffffff;
    font-size: 1.2rem;
}

.llm-chat--embedded [id^="llm-chat-send-"]:hover,
.llm-chat--embedded [id^="llm-chat-stop-"]:hover {
    opacity: 0.9;
}
