/* ai-sidebar.css - AI侧边栏结构样式 */

.ai-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background-color: #ffffff;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 5000;
    transition: transform 300ms ease;
    border-left: 1px solid #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.ai-sidebar.ai-sidebar-expanded {
    transform: translateX(0);
}

.ai-sidebar.ai-sidebar-collapsed {
    transform: translateX(400px);
}

/* 切换按钮 */
.ai-sidebar-toggle {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background-color: #1a73e8;
    color: white;
    border: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    transition: all 300ms ease;
    z-index: 8000;
    padding: 0;
    margin: 0;
}

.ai-sidebar-toggle:hover {
    background-color: #0d62d9;
    width: 52px;
}

.ai-sidebar-toggle-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* 头部 */
.ai-sidebar-header {
    padding: 16px 20px;
    background-color: #1a73e8;
    color: white;
    border-bottom: 1px solid #1565c0;
    flex-shrink: 0;
}

.ai-sidebar-header h2 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
}

.ai-status-indicator {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
}

.ai-status-indicator:before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #d93025;
    margin-right: 6px;
}

.ai-status-indicator.connected:before {
    background-color: #34a853;
}

.ai-status-indicator.ai-thinking:before {
    background-color: #fbbc05;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* 内容区域 */
.ai-sidebar-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 验证界面 */
.ai-auth-view {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.ai-auth-header {
    margin-bottom: 24px;
}

.ai-auth-header h3 {
    margin: 0 0 8px 0;
    color: #202124;
    font-size: 20px;
}

.ai-auth-header p {
    margin: 0;
    color: #5f6368;
    font-size: 14px;
    line-height: 1.5;
}

.ai-auth-form {
    margin-bottom: 24px;
}

.ai-form-group {
    margin-bottom: 20px;
}

.ai-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #3c4043;
    font-size: 14px;
}

.ai-api-key-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.ai-api-key-input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.ai-form-hint {
    font-size: 12px;
    color: #5f6368;
    margin: 6px 0 0 0;
}

.ai-primary-btn {
    background-color: #1a73e8;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.2s;
}

.ai-primary-btn:hover {
    background-color: #0d62d9;
}

.ai-primary-btn:disabled {
    background-color: #b3d4fc;
    cursor: not-allowed;
}

.ai-error-msg {
    color: #d93025;
    font-size: 13px;
    margin: 8px 0 0 0;
    min-height: 20px;
}

.ai-auth-info {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-top: 24px;
    border-left: 4px solid #1a73e8;
}

.ai-auth-info h4 {
    margin: 0 0 12px 0;
    color: #202124;
    font-size: 16px;
}

.ai-auth-info ol {
    margin: 0 0 12px 0;
    padding-left: 20px;
    color: #5f6368;
    font-size: 14px;
    line-height: 1.6;
}

.ai-auth-info li {
    margin-bottom: 6px;
}

.ai-auth-info a {
    color: #1a73e8;
    text-decoration: none;
}

.ai-auth-info a:hover {
    text-decoration: underline;
}

.ai-security-note {
    font-size: 13px;
    color: #d93025;
    margin: 12px 0 0 0;
    padding: 8px 12px;
    background-color: #fce8e6;
    border-radius: 4px;
    border-left: 3px solid #d93025;
}

/* 对话界面 */
.ai-chat-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ai-chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.ai-message-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ai-message-item {
    max-width: 90%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message-item.ai-message-user {
    align-self: flex-end;
    background-color: #1a73e8;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message-item.ai-message-assistant {
    align-self: flex-start;
    background-color: #f8f9fa;
    color: #202124;
    border-bottom-left-radius: 4px;
    border: 1px solid #e0e0e0;
}

.ai-message-item.ai-message-assistant-streaming {
    border-color: #1a73e8;
    box-shadow: 0 0 0 1px rgba(26, 115, 232, 0.1);
}

.ai-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
}

.ai-message-item.ai-message-user .ai-message-header {
    color: rgba(255, 255, 255, 0.9);
}

.ai-message-item.ai-message-assistant .ai-message-header {
    color: #5f6368;
}

.ai-message-role {
    font-weight: 600;
}

.ai-streaming-indicator {
    font-size: 11px;
    color: #1a73e8;
    font-style: italic;
    animation: pulse 2s infinite;
}

/* 底部输入区域 */
.ai-sidebar-footer {
    border-top: 1px solid #e0e0e0;
    padding: 16px;
    background-color: #ffffff;
    flex-shrink: 0;
}

.ai-input-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-input-area {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#ai-message-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #dadce0;
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

#ai-message-input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.ai-send-btn {
    background-color: #1a73e8;
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
    position: relative;
    z-index: 20002;
}

.ai-send-btn svg {
    display: block;
    width: 20px;
    height: 20px;
    color: inherit;
}

.ai-send-btn svg path,
.ai-send-btn svg line,
.ai-send-btn svg polygon,
.ai-send-btn svg rect {
    stroke: currentColor !important;
    fill: none !important;
}

.ai-send-btn:hover {
    background-color: #0d62d9;
}

.ai-send-btn:disabled {
    background-color: #b3d4fc;
    cursor: not-allowed;
}

.ai-chat-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #5f6368;
}

.ai-new-chat-btn {
    background: none;
    border: 1px solid #dadce0;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    color: #5f6368;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-new-chat-btn:hover {
    background-color: #f8f9fa;
    border-color: #c6c9ce;
}

.ai-context-info {
    font-size: 11px;
    opacity: 0.7;
}

/* 响应式 */
@media (max-width: 768px) {
    .ai-sidebar {
        width: 100%;
        max-width: 100%;
    }
    .ai-sidebar.ai-sidebar-collapsed {
        transform: translateX(100%);
    }
    .ai-sidebar-toggle {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

/* 宽度拖动条 */
.ai-sidebar-resizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    cursor: ew-resize;
    background: transparent;
    z-index: 10001;
}
.ai-sidebar-resizer:hover,
.ai-sidebar-resizer:active {
    background: rgba(0, 0, 0, 0.1);
}