/* Chat Interface Styles */

#chat-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 400px;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    z-index: 1000;
}

#chat-header {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

#chat-toggle {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 5px;
}

#chat-toggle:hover {
    color: #333;
}

#chat-footer {
    padding: 6px 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    justify-content: flex-end;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#model-selector {
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 3px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    outline: none;
    transition: all 0.15s ease;
    font-weight: 400;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#model-selector:hover {
    background: rgba(255, 255, 255, 0.25);
    opacity: 0.9;
}

#model-selector:focus {
    background: rgba(255, 255, 255, 0.2);
    opacity: 0.9;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    max-height: 400px;
}

.chat-message {
    padding: 10px 12px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
}

.chat-message.user {
    align-self: flex-end;
    background: rgba(0, 122, 255, 0.8);
    color: white;
}

.chat-message.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.6);
    color: #333;
}

.chat-message.assistant-thinking {
    align-self: flex-start;
    background: rgba(173, 216, 230, 0.4);
    color: #2c5282;
    border-left: 3px solid rgba(0, 122, 255, 0.6);
    font-style: italic;
    font-size: 13px;
}

.chat-message.system {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.5);
    color: #333;
    font-size: 12px;
    font-style: italic;
    max-width: 95%;
    border-radius: 6px;
}

.chat-message.error {
    align-self: center;
    background: rgba(220, 53, 69, 0.3);
    color: #721c24;
    font-size: 12px;
}

.chat-message.reconnecting {
    align-self: center;
    background: rgba(255, 193, 7, 0.3);
    color: #856404;
    font-size: 12px;
    max-width: 95%;
    border-radius: 6px;
}

#chat-input-container {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    gap: 8px;
}

#chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.5);
    color: #333;
    font-size: 14px;
}

#chat-input:focus {
    outline: none;
    border-color: rgba(0, 122, 255, 0.5);
    background: rgba(255, 255, 255, 0.7);
}

#chat-send {
    padding: 10px 16px;
    background: rgba(0, 122, 255, 0.8);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

#chat-send:hover {
    background: rgba(0, 122, 255, 1);
}

#chat-send:disabled {
    background: rgba(128, 128, 128, 0.5);
    cursor: not-allowed;
}

.chat-message pre {
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 12px;
}

.chat-message code {
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

/* Collapsed state */
#chat-container.collapsed {
    max-height: 60px;
}

#chat-container.collapsed #chat-messages,
#chat-container.collapsed #chat-input-container {
    display: none;
}

/* Loading indicator */
.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '';
    }

    40% {
        content: '.';
    }

    60% {
        content: '..';
    }

    80%,
    100% {
        content: '...';
    }
}

/* Scrollbar styling */
#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Query progress indicators */
.query-progress {
    margin-bottom: 8px;
    padding: 10px 12px;
    background: rgba(240, 248, 255, 0.7);
    border-left: 3px solid rgba(0, 122, 255, 0.5);
    border-radius: 4px;
}

.query-progress strong {
    color: #2c5282;
}

.query-progress .description {
    margin-top: 6px;
    font-size: 13px;
    color: #4a5568;
}

.query-progress details {
    margin-top: 8px;
    font-size: 12px;
}

.query-progress summary {
    cursor: pointer;
    user-select: none;
    color: #4a90e2;
    font-weight: 500;
}

.query-progress summary:hover {
    color: #2c5282;
}

.query-progress pre {
    margin-top: 8px;
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    max-height: 200px;
}

/* Thinking indicator */
#thinking-indicator {
    opacity: 0.7;
}

/* Thinking indicator when inline in tool results */
.thinking-inline {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 14px;
    opacity: 0.7;
}

/* Tool proposal and results use same style as assistant */
.chat-message.tool-proposal,
.chat-message.tool-results {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.6);
    color: #333;
}

/* Buttons for tool approval */
.tool-approval-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.approve-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    background: #28a745;
    color: white;
    transition: background 0.2s;
}

.approve-btn:hover:not(:disabled) {
    background: #218838;
}

.approve-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Glass-style buttons for query fold/unfold */
.query-summary-btn {
    display: inline-block;
    padding: 6px 12px 6px 26px;
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #2c5282;
    font-weight: 500;
    font-size: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
}

.query-summary-btn::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #2c5282;
    transition: transform 0.2s ease;
}

details[open]>.query-summary-btn::before {
    transform: translateY(-50%) rotate(180deg);
}

.query-summary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(0, 122, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.1);
    transform: translateY(-1px);
}

.query-summary-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}