/* 自定义模型管理 - 现代视觉设计 */
#custom-models .section-header {
    margin-bottom: 1.5rem;
}

#custom-models .pool-description {
    margin-bottom: 1.5rem;
}

#custom-models .highlight-note {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(to right, var(--primary-10), transparent);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-sm) var(--radius-xl) var(--radius-xl) var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#custom-models .highlight-note i {
    color: var(--primary-color);
    font-size: 1.1rem;
}

/* 容器与表格 */
.custom-models-container {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition);
}

.custom-models-container .table-responsive {
    overflow-x: auto;
}

.custom-models-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 820px;
    font-size: 0.875rem;
    line-height: 1.45;
}

.custom-models-table th {
    background: var(--bg-secondary);
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0;
    border-bottom: 1px solid var(--border-color);
}

.custom-models-table th:nth-child(3),
.custom-models-table td:nth-child(3) {
    min-width: 170px;
}

.custom-models-table th:nth-child(4),
.custom-models-table td:nth-child(4) {
    min-width: 220px;
}

.custom-models-table td {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-primary);
    font-size: inherit;
    font-weight: 500;
    line-height: inherit;
}

.custom-models-table tr:last-child td {
    border-bottom: none;
}

.custom-models-table tr:hover {
    background: var(--bg-secondary);
}

.model-name-cell {
    font-weight: 500;
    color: var(--text-primary);
}

/* 空状态 */
.table-empty-state {
    padding: 4rem 0 !important;
    text-align: center;
}

.table-empty-state .empty-icon {
    font-size: 3rem;
    color: var(--text-tertiary);
    opacity: 0.3;
    margin-bottom: 1rem;
}

.table-empty-state .empty-text {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.table-empty-state .empty-hint {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
}

/* 模型 ID 样式 */
.model-id-cell {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.model-id-cell .main-id {
    font-family: inherit;
    font-weight: 600;
    color: var(--text-primary);
    font-size: inherit;
    line-height: inherit;
}

.model-id-cell .alias-tag {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* 提供商 Badge */
.provider-route-cell {
    display: flex;
    align-items: center;
    max-width: 190px;
}

.actual-route-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
    max-width: 260px;
}

.model-list-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: 100%;
    height: 1.8rem;
    padding: 0 0.55rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
}

.model-list-chip .chip-icon {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: currentColor;
    opacity: 0.82;
}

.model-list-chip .chip-icon i {
    font-size: 0.7rem;
    line-height: 1;
}

.model-list-chip .chip-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.provider-badge {
    background: var(--info-bg);
    color: var(--info-text);
    border: 1px solid var(--info-border);
}

.route-provider-badge {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-color);
}

.actual-model-chip {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* 实际 ID */
.actual-id-code {
    display: block;
    max-width: 100%;
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: var(--text-secondary);
    border: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 参数标签组 */
.params-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.param-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 1.8rem;
    padding: 0 0.55rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
}

.param-pill i {
    width: 1rem;
    text-align: center;
    font-size: 0.7rem;
    opacity: 0.82;
}

.param-pill.ctx { background: var(--info-bg-light); color: var(--info-text); border: 1px solid var(--info-border); }
.param-pill.temp { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
.param-pill.topp { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-color); }
.param-pill.tokens { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }

/* 操作按钮 */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.icon-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.icon-btn.delete:hover {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

/* 弹窗样式优化 - 使用 ID 确保精确匹配 */
#customModelModal.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 1rem;
    opacity: 0;
}

#customModelModal.modal-overlay.show {
    display: flex;
    opacity: 1;
}

#customModelModal .modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 640px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#customModelModal.modal-overlay.show .modal-content {
    transform: scale(1);
}

#customModelModal .modal-header {
    background: var(--bg-secondary);
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

#customModelModal .modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#customModelModal .modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

#customModelModal .modal-footer {
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    border-top: 1px solid var(--border-color);
}


.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 640px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-header {
    background: var(--bg-secondary);
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

#custom-models .modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-tertiary);
    cursor: pointer;
    line-height: 1;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--danger-color);
}

#custom-models .modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

#custom-models .modal-footer {
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    border-top: 1px solid var(--border-color);
}

/* 表单行优化 */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* 响应式适配 */
@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .custom-models-table th:nth-child(5),
    .custom-models-table td:nth-child(5) {
        display: none; /* 在移动端隐藏不太重要的列 */
    }

    .modal-content {
        max-height: 90vh;
    }
}
