.llm-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale
}

.llm-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px #667eea66;
    transition: all .3s ease;
    z-index: 999;
    font-size: 24px
}

.llm-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px #667eea99
}

.llm-chat-toggle:active {
    transform: scale(.95)
}

.llm-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 40px #00000029;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    animation: slideUp .3s ease-out
}

@keyframes slideUp {
    0% {
        opacity: 0;
        transform: translateY(20px)
    }
    to {
        opacity: 1;
        transform: translateY(0)
    }
}

.llm-chat-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0
}

.llm-chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600
}

.llm-chat-header-actions {
    display: flex;
    gap: 8px;
    align-items: center
}

.llm-clear-btn, .llm-close-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .2s ease;
    font-size: 16px
}

.llm-clear-btn svg, .llm-close-btn svg {
    stroke: currentColor
}

.llm-clear-btn:hover:not(:disabled), .llm-close-btn:hover {
    opacity: .8
}

.llm-clear-btn:active:not(:disabled), .llm-close-btn:active {
    opacity: .6
}

.llm-clear-btn:disabled {
    opacity: .4;
    cursor: not-allowed
}

.llm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fff
}

.llm-chat-messages::-webkit-scrollbar {
    width: 6px
}

.llm-chat-messages::-webkit-scrollbar-track {
    background: transparent
}

.llm-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px
}

.llm-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af
}

.llm-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    text-align: center
}

.llm-empty-state p {
    margin: 8px 0;
    font-size: 14px
}

.llm-empty-state p:first-child {
    font-size: 32px;
    margin-bottom: 12px
}

.llm-message {
    display: flex;
    gap: 8px;
    animation: fadeIn .3s ease-out
}

@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px)
    }
    to {
        opacity: 1;
        transform: translateY(0)
    }
}

.llm-message.user {
    flex-direction: row-reverse
}

.llm-message-avatar {
    flex-shrink: 0;
    font-size: 20px
}

.llm-message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px
}

.llm-message-content p {
    margin: 0;
    padding: 10px 12px;
    border-radius: 8px;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
    font-size: 14px
}

.llm-message.assistant .llm-message-content p {
    background: #f3f4f6;
    color: #111827;
    border-bottom-left-radius: 2px
}

.llm-message.user .llm-message-content p {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-bottom-right-radius: 2px
}

.llm-error-banner {
    padding: 12px 16px;
    background-color: #fee2e2;
    color: #991b1b;
    border-bottom: 1px solid #fecaca;
    font-size: 14px;
    flex-shrink: 0
}

.llm-chat-input-form {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    background: #fff
}

.llm-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end
}

.llm-input-field {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    outline: none;
    transition: border-color .2s ease
}

.llm-input-field:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px #667eea1a
}

.llm-input-field:disabled {
    background-color: #f9fafb;
    color: #d1d5db;
    cursor: not-allowed
}

.llm-send-btn {
    padding: 10px 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .2s ease
}

.llm-send-btn:hover:not(:disabled) {
    opacity: .9
}

.llm-send-btn:disabled {
    opacity: .5;
    cursor: not-allowed
}

.llm-spinner-icon {
    animation: spin 1s linear infinite
}

@keyframes spin {
    to {
        transform: rotate(360deg)
    }
}

@media (max-width: 512px) {
    .llm-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 90px;
        right: 20px;
        max-height: none
    }
}
