/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

.agent-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: white;
}

.chat-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  background: white;
}

.chat-toolbar-controls {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.toolbar-item {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.chat-content-wrapper {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: row;
}

// Main chat column (messages + input)
.chat-main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 85%;

  &.user-message {
    align-self: flex-end;
    .message-content {
      background: #1890ff;
      color: white;
    }
  }

  &.ai-message {
    align-self: flex-start;
    .message-content {
      background: #f5f5f5;
      color: #262626;
    }
  }

  &.loading-message .message-content {
    background: #e6f7ff;
    border: 1px solid #91d5ff;
  }
}

.message-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 12px;
  color: #8c8c8c;

  i {
    font-size: 14px;
  }
}

.message-content {
  padding: 8px 12px;
  border-radius: 6px;
  line-height: 1.5;
  word-wrap: break-word;
  font-size: 14px;
  user-select: text;

  ::ng-deep markdown {
    display: block;

    p {
      margin: 0 0 8px 0;
      &:last-child {
        margin-bottom: 0;
      }
    }

    code {
      background: rgba(0, 0, 0, 0.06);
      padding: 2px 6px;
      border-radius: 3px;
      font-size: 13px;
    }

    pre {
      background: rgba(0, 0, 0, 0.06);
      padding: 12px;
      border-radius: 4px;
      overflow-x: auto;
      margin: 8px 0;
      code {
        background: transparent;
        padding: 0;
      }
    }

    ul,
    ol {
      margin: 8px 0;
      padding-left: 24px;
    }

    li {
      margin: 4px 0;
    }

    blockquote {
      border-left: 3px solid rgba(0, 0, 0, 0.1);
      padding-left: 12px;
      margin: 8px 0;
      color: rgba(0, 0, 0, 0.65);
    }

    a {
      color: #1890ff;
      text-decoration: none;
      &:hover {
        text-decoration: underline;
      }
    }
  }
}

.user-message .message-content ::ng-deep markdown {
  code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
  }

  pre {
    background: rgba(255, 255, 255, 0.15);
    code {
      color: white;
    }
  }

  blockquote {
    border-left-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.9);
  }

  a {
    color: #e6f7ff;
    &:hover {
      color: white;
    }
  }
}

.input-area {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid #f0f0f0;
  background: #ffffff;
  align-items: center;

  textarea {
    flex: 1;
  }

  button {
    align-self: flex-end;
  }
}

.connection-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff7e6;
  border-top: 1px solid #ffd666;
  color: #d46b08;
  font-size: 12px;

  i {
    color: #faad14;
  }
}

// Agent Settings Modal Styles
.settings-section {
  padding: 12px 0;
}

.settings-prompt-display {
  background: #fafafa;
  padding: 12px;
  border-radius: 4px;
  border: 1px solid #d9d9d9;
  max-height: 500px;
  overflow-y: auto;
}

.settings-tools-list {
  max-height: 400px;
  overflow-y: auto;
}

.settings-tool-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;

  &:last-child {
    border-bottom: none;
  }

  .settings-tool-info {
    flex: 1;
    min-width: 0;

    .settings-tool-name {
      display: block;
      font-weight: 500;
      color: #262626;
      font-size: 13px;
      font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    }

    .settings-tool-description {
      display: block;
      color: #8c8c8c;
      font-size: 12px;
      line-height: 1.4;
      margin-top: 2px;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }
  }
}

.settings-param-item {
  margin-bottom: 16px;

  .settings-param-label {
    display: block;
    font-weight: 500;
    color: #262626;
    margin-bottom: 8px;
  }

  .settings-param-input {
    display: flex;
    align-items: center;
    gap: 12px;

    .settings-param-hint {
      color: #8c8c8c;
      font-size: 12px;
    }
  }
}
