/* components.css - 基础UI组件样式 */

/* 按钮基础样式 */
button {
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: 4px;
  width: 100%;
  text-align: center;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(66, 99, 235, 0.2);
}

button:active {
  transform: translateY(1px);
  opacity: 0.9;
}

/* 按钮变体 */
button.primary-btn { 
  background-color: var(--primary); 
  color: var(--text-light); 
  border-color: var(--primary); 
}

button.primary-btn:hover { 
  background-color: var(--primary-hover); 
  border-color: var(--primary-hover); 
}

button.primary-btn:disabled {
  background-color: var(--gray-400);
  color: var(--gray-600);
  cursor: not-allowed;
  box-shadow: none;
  border-color: var(--gray-400);
}

button.secondary-btn {
  background-color: var(--surface-1);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

button.secondary-btn:hover { 
  background-color: var(--surface-2); 
  border-color: var(--gray-400); 
  color: var(--text-primary); 
}

button.secondary-btn:disabled { 
  background-color: var(--surface-2); 
  color: var(--text-muted); 
  border-color: var(--border-color-light); 
  cursor: not-allowed; 
}

button.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--border-radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
}

button.icon-text-btn {
  padding: 8px 12px;
  gap: 6px;
  width: auto;
}

button.icon-text-btn .icon {
  width: 16px;
  height: 16px;
}

button.compact-btn {
  padding: 6px 10px;
  font-size: 13px;
}

button.action-btn {
  background-color: var(--secondary);
  color: var(--text-light);
  border-color: var(--secondary);
}

button.action-btn:hover {
  background-color: var(--secondary-hover);
  border-color: var(--secondary-hover);
}

button.action-btn:disabled {
  background-color: var(--gray-400);
  color: var(--gray-600);
  cursor: not-allowed;
  box-shadow: none;
  border-color: var(--gray-400);
}

button.text-btn {
  background-color: transparent;
  color: var(--primary);
  border-color: transparent;
  padding: 4px 8px;
  font-weight: 400;
}

button.text-btn:hover {
  background-color: var(--primary-light);
  color: var(--primary-hover);
}

button.send-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--border-radius-circle);
  background-color: var(--primary); 
  color: var(--text-light);
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  font-size: 0;
  position: relative;
}

button.send-btn::before {
  content: '';
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='22' y1='2' x2='11' y2='13'%3E%3C/line%3E%3Cpolygon points='22 2 15 22 11 13 2 9 22 2'%3E%3C/polygon%3E%3C/svg%3E");
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  display: block;
}

button.send-btn:hover { 
  background-color: var(--primary-hover); 
}

button.send-btn:disabled {
  background-color: var(--gray-400);
  cursor: not-allowed;
  box-shadow: none;
}

/* 输入框基础样式 */
input[type="text"], 
input[type="password"], 
input[type="number"],
input[type="email"],
textarea, 
select {
  width: 100%; 
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 8px;
  transition: all var(--transition-fast);
  background-color: var(--surface-1);
  color: var(--text-primary);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(66, 99, 235, 0.15);
  outline: none;
}

input[type="password"] {
  letter-spacing: 0.1em;
}

input.with-icon {
  padding-right: 40px;
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
}

input#api-key {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23adb5bd' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'%3E%3C/path%3E%3C/svg%3E");
}

textarea {
  min-height: 100px;
  resize: vertical;
}

textarea#user-input {
  flex-grow: 1; 
  resize: none; 
  margin-bottom: 0;
  min-height: 24px;
  max-height: 150px;
  overflow-y: auto;
  padding: 12px 16px;
  border-radius: var(--border-radius-pill);
  line-height: 1.5;
  font-size: 15px;
  transition: all var(--transition-fast);
}

select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23868e96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  cursor: pointer;
}

/* 复选框和单选框 */
.checkbox-group, .radio-group {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}

input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

/* 开关控件 */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  margin-bottom: 8px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-300);
  transition: var(--transition-normal);
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition-normal);
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* 滑块控件 */
.slider-control {
  width: 100%;
  margin-bottom: 12px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.slider-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.slider-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.slider-input {
  width: 100%;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--gray-200);
  outline: none;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.slider-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 状态标签 */
.status {
  border-radius: var(--border-radius-sm);
  text-align: center;
  font-size: 12px;
  padding: 2px 6px;
}

.status.error-text { color: var(--error); }
.status.success-text { color: var(--success); }
.status.warning-text { color: var(--warning); }

.status.error {
  background-color: rgba(224, 49, 49, 0.1);
  color: var(--error);
  padding: 4px 8px;
  border: 1px solid rgba(224, 49, 49, 0.2);
}

.api-status {
  font-size: 12px;
  padding: 2px 6px;
  min-height: 18px;
  line-height: 14px;
  text-align: right;
  flex-grow: 1;
  margin-left: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
}

/* 折叠面板 */
.collapsible {
  margin-bottom: 12px;
}

.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background-color: var(--surface-2);
  border: 1px solid var(--border-color-light);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.collapsible-header:hover {
  background-color: var(--gray-200);
}

.collapsible-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
}

.collapsible-icon {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-fast);
}

.collapsible.open .collapsible-icon {
  transform: rotate(180deg);
}

.collapsible-content {
  padding: 12px;
  border: 1px solid var(--border-color-light);
  border-top: none;
  border-bottom-left-radius: var(--border-radius);
  border-bottom-right-radius: var(--border-radius);
  background-color: var(--surface-1);
  display: none;
}

.collapsible.open .collapsible-content {
  display: block;
}

/* 徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge.primary {
  background-color: var(--primary-light);
  color: var(--primary);
}

.badge.success {
  background-color: rgba(55, 178, 77, 0.12);
  color: var(--success);
  border: 1px solid rgba(55, 178, 77, 0.2);
}

.badge.warning {
  background-color: rgba(245, 159, 0, 0.12);
  color: var(--warning);
  border: 1px solid rgba(245, 159, 0, 0.2);
}

.badge.error {
  background-color: rgba(224, 49, 49, 0.12);
  color: var(--error);
  border: 1px solid rgba(224, 49, 49, 0.2);
}

.feature-pill {
  display: inline-flex;
  align-items: center;
  background-color: rgba(55, 178, 77, 0.12);
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--success);
  border: 1px solid rgba(55, 178, 77, 0.2);
}

